3 # Copyright (C) 2009, 2010, 2011 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 no instance moves
79 ./hbal -t$T/$RAPI.data $GROUP --no-instance-moves
80 echo Testing hbal/text with offline node mode
81 ./hbal -t$T/$RAPI.data $GROUP -O$FN
82 echo Testing hbal/text with utilization data
83 echo "$FI 2 2 2 2" > $T/util.data
84 ./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
85 echo Testing hbal/text with bad utilization data
86 echo "$FI 2 a 3b" > $T/util.data
87 ! ./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
88 echo Testing hbal/text with instance exclusion
89 ./hbal -t$T/$RAPI.data $GROUP --exclude-instances=$FI
90 ! ./hbal -t$T/$RAPI.data --exclude-instances=no_such_instance
91 echo Testing hbal/text with tag exclusion
92 ./hbal -t $T/$RAPI.data $GROUP --exclusion-tags=no_such_tag
93 echo Testing hbal multiple backend failure
94 ! ./hbal -t $T/$RAPI.data -L$LUXI
95 echo Testing hbal no backend failure
98 echo Getting data files for hail
99 for dtemplate in plain drbd; do
100 $CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
101 --disks 128m -t $dtemplate -o no_such_os no_such_instance \
102 > $T/h-alloc-$dtemplate.json
104 $CLUSTER gnt-debug allocator --dir in --mode relocate \
105 -o no_such_os $FI > $T/h-reloc.json
106 $CLUSTER gnt-debug allocator --dir in --mode multi-evacuate \
107 $FN > $T/h-evacuate.json
108 for dtemplate in plain drbd; do
109 echo Testing hail/allocate-$dtemplate
110 ./hail $T/h-alloc-$dtemplate.json
112 echo Testing hail/relocate for instance $FI
113 ./hail $T/h-reloc.json
114 echo Testing hail/evacuate for node $FN
115 ./hail $T/h-evacuate.json
123 echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
124 echo TSPEC=$HTS_TSPEC
128 TIER="--tiered 102400,8192,2"
129 SIMU="--simu=preferred,10,6835937,32768,4"
130 echo Testing hspace/luxi
131 ./hspace -L$LUXI $TIER -v > $HOUT
132 ( check_hspace_out ) || exit 1
133 echo Testing hspace/rapi
134 ./hspace -m$RAPI $TIER -v > $HOUT
135 ( check_hspace_out ) || exit 1
136 echo Testing hspace/text
137 ./hspace -t$T/$RAPI.data $TIER -v > $HOUT
138 ( check_hspace_out ) || exit 1
139 echo Testing hspace/simu
140 # ~6T disk space, 32G ram, 4 VCPUs
141 ./hspace $SIMU $TIER -v > $HOUT
142 ( check_hspace_out ) || exit 1
143 # Wrong tiered spec input
144 ! ./hspace $SIMU --tiered 1,2,3x
145 ! ./hspace $SIMU --tiered 1,2,x
146 ! ./hspace $SIMU --tiered 1,2
148 ! ./hspace --simu=1,2,x