Statistics
| Branch: | Tag: | Revision:

root / htools / live-test.sh @ 2e5eb96a

History | View | Annotate | Download (4.8 kB)

1 31728b11 Iustin Pop
#!/bin/bash
2 31728b11 Iustin Pop
3 1c78dbd2 Iustin Pop
# Copyright (C) 2009, 2010, 2011 Google Inc.
4 31728b11 Iustin Pop
5 31728b11 Iustin Pop
# This program is free software; you can redistribute it and/or modify
6 31728b11 Iustin Pop
# it under the terms of the GNU General Public License as published by
7 31728b11 Iustin Pop
# the Free Software Foundation; either version 2 of the License, or
8 31728b11 Iustin Pop
# (at your option) any later version.
9 31728b11 Iustin Pop
10 31728b11 Iustin Pop
# This program is distributed in the hope that it will be useful, but
11 31728b11 Iustin Pop
# WITHOUT ANY WARRANTY; without even the implied warranty of
12 31728b11 Iustin Pop
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 31728b11 Iustin Pop
# General Public License for more details.
14 31728b11 Iustin Pop
15 31728b11 Iustin Pop
# You should have received a copy of the GNU General Public License
16 31728b11 Iustin Pop
# along with this program; if not, write to the Free Software
17 31728b11 Iustin Pop
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 31728b11 Iustin Pop
# 02110-1301, USA.
19 31728b11 Iustin Pop
20 31728b11 Iustin Pop
# This is a live-testing script for most/all of the htools
21 31728b11 Iustin Pop
# programs. It needs either to run on a live cluster or access to a
22 31728b11 Iustin Pop
# cluster via ssh and an exported LUXI interface (via socat, for
23 57df9cb3 Iustin Pop
# example). The cluster must not be empty (otherwise the hail relocate
24 57df9cb3 Iustin Pop
# test will fail).
25 31728b11 Iustin Pop
26 31728b11 Iustin Pop
# Use: if running on a cluster master, just running it should be
27 31728b11 Iustin Pop
# enough. If running remotely, set env vars as follows: LUXI to the
28 31728b11 Iustin Pop
# export unix socket, RAPI to the cluster IP, CLUSTER to the command
29 1a3cc8ad Iustin Pop
# used to login on the cluster (e.g. CLUSTER="ssh root@cluster"). Note
30 1a3cc8ad Iustin Pop
# that when run against a multi-group cluster, the GROUP variable
31 1a3cc8ad Iustin Pop
# should be set to one of the groups (some operations work only on one
32 1a3cc8ad Iustin Pop
# group)
33 31728b11 Iustin Pop
34 31728b11 Iustin Pop
set -e
35 31728b11 Iustin Pop
: ${RAPI:=localhost}
36 1a3cc8ad Iustin Pop
GROUP=${GROUP:+-G $GROUP}
37 1a3cc8ad Iustin Pop
38 31728b11 Iustin Pop
T=`mktemp -d`
39 31728b11 Iustin Pop
trap 'rm -rf $T' EXIT
40 31728b11 Iustin Pop
echo Using $T as temporary dir
41 31728b11 Iustin Pop
42 b880f1d1 Iustin Pop
echo Checking command line
43 b880f1d1 Iustin Pop
for prog in hscan hbal hail hspace; do
44 b880f1d1 Iustin Pop
    ./$prog --version
45 b880f1d1 Iustin Pop
    ./$prog --help
46 b7478ce1 Iustin Pop
    ! ./$prog --no-such-option
47 b880f1d1 Iustin Pop
done
48 b880f1d1 Iustin Pop
49 b880f1d1 Iustin Pop
echo Testing hscan/rapi
50 b880f1d1 Iustin Pop
./hscan -d$T $RAPI -p
51 b880f1d1 Iustin Pop
echo Testing hscan/luxi
52 b880f1d1 Iustin Pop
./hscan -d$T -L$LUXI -p
53 b880f1d1 Iustin Pop
echo Comparing hscan results...
54 b880f1d1 Iustin Pop
diff -u $T/$RAPI.data $T/LOCAL.data
55 31728b11 Iustin Pop
56 e4d8071d Iustin Pop
FN=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_node_list)
57 b7478ce1 Iustin Pop
FI=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list)
58 b7478ce1 Iustin Pop
59 b7478ce1 Iustin Pop
60 31728b11 Iustin Pop
echo Testing hbal/luxi
61 1a3cc8ad Iustin Pop
./hbal -L$LUXI $GROUP -p --print-instances -C$T/hbal-luxi-cmds.sh
62 b880f1d1 Iustin Pop
bash -n $T/hbal-luxi-cmds.sh
63 31728b11 Iustin Pop
echo Testing hbal/rapi
64 1a3cc8ad Iustin Pop
./hbal -m$RAPI $GROUP -p --print-instances -C$T/hbal-rapi-cmds.sh
65 b880f1d1 Iustin Pop
bash -n $T/hbal-rapi-cmds.sh
66 31728b11 Iustin Pop
echo Testing hbal/text
67 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP -p --print-instances -C$T/hbal-text-cmds.sh
68 b880f1d1 Iustin Pop
bash -n $T/hbal-text-cmds.sh
69 b7478ce1 Iustin Pop
echo Comparing hbal results
70 b7478ce1 Iustin Pop
diff -u $T/hbal-luxi-cmds.sh $T/hbal-rapi-cmds.sh
71 b7478ce1 Iustin Pop
diff -u $T/hbal-luxi-cmds.sh $T/hbal-text-cmds.sh
72 b7478ce1 Iustin Pop
73 b880f1d1 Iustin Pop
74 b880f1d1 Iustin Pop
echo Testing hbal/text with evacuation mode
75 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP -E
76 b7478ce1 Iustin Pop
echo Testing hbal/text with no disk moves
77 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP --no-disk-moves
78 b880f1d1 Iustin Pop
echo Testing hbal/text with offline node mode
79 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP -O$FN
80 b7478ce1 Iustin Pop
echo Testing hbal/text with utilization data
81 b7478ce1 Iustin Pop
echo "$FI 2 2 2 2" > $T/util.data
82 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
83 b7478ce1 Iustin Pop
echo Testing hbal/text with bad utilization data
84 b7478ce1 Iustin Pop
echo "$FI 2 a 3b" > $T/util.data
85 1a3cc8ad Iustin Pop
! ./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
86 b7478ce1 Iustin Pop
echo Testing hbal/text with instance exclusion
87 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP --exclude-instances=$FI
88 b7478ce1 Iustin Pop
! ./hbal -t$T/$RAPI.data --exclude-instances=no_such_instance
89 b7478ce1 Iustin Pop
echo Testing hbal/text with tag exclusion
90 1a3cc8ad Iustin Pop
./hbal -t $T/$RAPI.data $GROUP --exclusion-tags=no_such_tag
91 b7478ce1 Iustin Pop
echo Testing hbal multiple backend failure
92 b7478ce1 Iustin Pop
! ./hbal -t $T/$RAPI.data -L$LUXI
93 b7478ce1 Iustin Pop
echo Testing hbal no backend failure
94 b7478ce1 Iustin Pop
! ./hbal
95 31728b11 Iustin Pop
96 31728b11 Iustin Pop
echo Getting data files for hail
97 b880f1d1 Iustin Pop
for dtemplate in plain drbd; do
98 b880f1d1 Iustin Pop
  $CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
99 b880f1d1 Iustin Pop
      --disks 128m -t $dtemplate -o no_such_os no_such_instance \
100 b880f1d1 Iustin Pop
      > $T/h-alloc-$dtemplate.json
101 b880f1d1 Iustin Pop
done
102 b880f1d1 Iustin Pop
$CLUSTER gnt-debug allocator --dir in --mode relocate \
103 b7478ce1 Iustin Pop
    -o no_such_os $FI > $T/h-reloc.json
104 b880f1d1 Iustin Pop
$CLUSTER gnt-debug allocator --dir in --mode multi-evacuate \
105 b880f1d1 Iustin Pop
    $FN > $T/h-evacuate.json
106 b880f1d1 Iustin Pop
for dtemplate in plain drbd; do
107 b880f1d1 Iustin Pop
  echo Testing hail/allocate-$dtemplate
108 b880f1d1 Iustin Pop
  ./hail $T/h-alloc-$dtemplate.json
109 b880f1d1 Iustin Pop
done
110 b7478ce1 Iustin Pop
echo Testing hail/relocate for instance $FI
111 31728b11 Iustin Pop
./hail $T/h-reloc.json
112 b880f1d1 Iustin Pop
echo Testing hail/evacuate for node $FN
113 b880f1d1 Iustin Pop
./hail $T/h-evacuate.json
114 31728b11 Iustin Pop
115 31728b11 Iustin Pop
HOUT="$T/hspace.out"
116 31728b11 Iustin Pop
117 31728b11 Iustin Pop
check_hspace_out() {
118 31728b11 Iustin Pop
    set -u
119 31728b11 Iustin Pop
    set -e
120 31728b11 Iustin Pop
    source "$HOUT"
121 31728b11 Iustin Pop
    echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
122 31728b11 Iustin Pop
    echo TSPEC=$HTS_TSPEC
123 31728b11 Iustin Pop
    echo OK=$HTS_OK
124 31728b11 Iustin Pop
}
125 31728b11 Iustin Pop
126 31728b11 Iustin Pop
TIER="--tiered 102400,8192,2"
127 1c78dbd2 Iustin Pop
SIMU="--simu=preferred,10,6835937,32768,4"
128 31728b11 Iustin Pop
echo Testing hspace/luxi
129 b880f1d1 Iustin Pop
./hspace -L$LUXI $TIER -v > $HOUT
130 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
131 31728b11 Iustin Pop
echo Testing hspace/rapi
132 b880f1d1 Iustin Pop
./hspace -m$RAPI $TIER -v > $HOUT
133 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
134 31728b11 Iustin Pop
echo Testing hspace/text
135 b880f1d1 Iustin Pop
./hspace -t$T/$RAPI.data $TIER -v > $HOUT
136 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
137 31728b11 Iustin Pop
echo Testing hspace/simu
138 31728b11 Iustin Pop
# ~6T disk space, 32G ram, 4 VCPUs
139 b7478ce1 Iustin Pop
./hspace $SIMU $TIER -v > $HOUT
140 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
141 b7478ce1 Iustin Pop
# Wrong tiered spec input
142 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2,3x
143 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2,x
144 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2
145 b7478ce1 Iustin Pop
# Wrong simu spec
146 b7478ce1 Iustin Pop
! ./hspace --simu=1,2,x
147 b7478ce1 Iustin Pop
148 31728b11 Iustin Pop
echo All OK