--select-instances hbal manpage update
[ganeti-local] / htools / live-test.sh
1 #!/bin/bash
2
3 # Copyright (C) 2009, 2010, 2011 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"). 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
32 # group)
33
34 set -e
35 : ${RAPI:=localhost}
36 GROUP=${GROUP:+-G $GROUP}
37
38 T=`mktemp -d`
39 trap 'rm -rf $T' EXIT
40 echo Using $T as temporary dir
41
42 echo Checking command line
43 for prog in hscan hbal hail hspace; do
44     ./$prog --version
45     ./$prog --help
46     ! ./$prog --no-such-option
47 done
48
49 echo Testing hscan/rapi
50 ./hscan -d$T $RAPI -p
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
55
56 FN=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_node_list)
57 FI=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list)
58
59
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
72
73
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
96 ! ./hbal
97
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
103 done
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
111 done
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
116
117 HOUT="$T/hspace.out"
118
119 check_hspace_out() {
120     set -u
121     set -e
122     source "$HOUT"
123     echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
124     echo TSPEC=$HTS_TSPEC
125     echo OK=$HTS_OK
126 }
127
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
147 # Wrong simu spec
148 ! ./hspace --simu=1,2,x
149
150 echo All OK