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