3 # Copyright (C) 2009, 2010 Google Inc.
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.
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.
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
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
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"). Note
30 # that when run against a multi-group cluster, the GROUP variable
31 # should be set to one of the groups (some operations work only on one
36 GROUP=${GROUP:+-G $GROUP}
40 echo Using $T as temporary dir
42 echo Checking command line
43 for prog in hscan hbal hail hspace; do
46 ! ./$prog --no-such-option
49 echo Testing hscan/rapi
51 echo Testing hscan/luxi
52 ./hscan -d$T -L$LUXI -p
53 echo Comparing hscan results...
54 diff -u $T/$RAPI.data $T/LOCAL.data
56 FN=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_node_list)
57 FI=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list)
60 echo Testing hbal/luxi
61 ./hbal -L$LUXI $GROUP -p --print-instances -C$T/hbal-luxi-cmds.sh
62 bash -n $T/hbal-luxi-cmds.sh
63 echo Testing hbal/rapi
64 ./hbal -m$RAPI $GROUP -p --print-instances -C$T/hbal-rapi-cmds.sh
65 bash -n $T/hbal-rapi-cmds.sh
66 echo Testing hbal/text
67 ./hbal -t$T/$RAPI.data $GROUP -p --print-instances -C$T/hbal-text-cmds.sh
68 bash -n $T/hbal-text-cmds.sh
69 echo Comparing hbal results
70 diff -u $T/hbal-luxi-cmds.sh $T/hbal-rapi-cmds.sh
71 diff -u $T/hbal-luxi-cmds.sh $T/hbal-text-cmds.sh
74 echo Testing hbal/text with evacuation mode
75 ./hbal -t$T/$RAPI.data $GROUP -E
76 echo Testing hbal/text with no disk moves
77 ./hbal -t$T/$RAPI.data $GROUP --no-disk-moves
78 echo Testing hbal/text with offline node mode
79 ./hbal -t$T/$RAPI.data $GROUP -O$FN
80 echo Testing hbal/text with utilization data
81 echo "$FI 2 2 2 2" > $T/util.data
82 ./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
83 echo Testing hbal/text with bad utilization data
84 echo "$FI 2 a 3b" > $T/util.data
85 ! ./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
86 echo Testing hbal/text with instance exclusion
87 ./hbal -t$T/$RAPI.data $GROUP --exclude-instances=$FI
88 ! ./hbal -t$T/$RAPI.data --exclude-instances=no_such_instance
89 echo Testing hbal/text with tag exclusion
90 ./hbal -t $T/$RAPI.data $GROUP --exclusion-tags=no_such_tag
91 echo Testing hbal multiple backend failure
92 ! ./hbal -t $T/$RAPI.data -L$LUXI
93 echo Testing hbal no backend failure
96 echo Getting data files for hail
97 for dtemplate in plain drbd; do
98 $CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
99 --disks 128m -t $dtemplate -o no_such_os no_such_instance \
100 > $T/h-alloc-$dtemplate.json
102 $CLUSTER gnt-debug allocator --dir in --mode relocate \
103 -o no_such_os $FI > $T/h-reloc.json
104 $CLUSTER gnt-debug allocator --dir in --mode multi-evacuate \
105 $FN > $T/h-evacuate.json
106 for dtemplate in plain drbd; do
107 echo Testing hail/allocate-$dtemplate
108 ./hail $T/h-alloc-$dtemplate.json
110 echo Testing hail/relocate for instance $FI
111 ./hail $T/h-reloc.json
112 echo Testing hail/evacuate for node $FN
113 ./hail $T/h-evacuate.json
121 echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
122 echo TSPEC=$HTS_TSPEC
126 TIER="--tiered 102400,8192,2"
127 SIMU="--simu=10,6835937,32768,4"
128 echo Testing hspace/luxi
129 ./hspace -L$LUXI $TIER -v > $HOUT
130 ( check_hspace_out ) || exit 1
131 echo Testing hspace/rapi
132 ./hspace -m$RAPI $TIER -v > $HOUT
133 ( check_hspace_out ) || exit 1
134 echo Testing hspace/text
135 ./hspace -t$T/$RAPI.data $TIER -v > $HOUT
136 ( check_hspace_out ) || exit 1
137 echo Testing hspace/simu
138 # ~6T disk space, 32G ram, 4 VCPUs
139 ./hspace $SIMU $TIER -v > $HOUT
140 ( check_hspace_out ) || exit 1
141 # Wrong tiered spec input
142 ! ./hspace $SIMU --tiered 1,2,3x
143 ! ./hspace $SIMU --tiered 1,2,x
144 ! ./hspace $SIMU --tiered 1,2
146 ! ./hspace --simu=1,2,x