Statistics
| Branch: | Tag: | Revision:

root / htools / live-test.sh @ 4892d955

History | View | Annotate | Download (5 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 9da4dc31 Guido Trotter
echo Testing hbal/text with no instance moves
79 9da4dc31 Guido Trotter
./hbal -t$T/$RAPI.data $GROUP --no-instance-moves
80 b880f1d1 Iustin Pop
echo Testing hbal/text with offline node mode
81 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP -O$FN
82 b7478ce1 Iustin Pop
echo Testing hbal/text with utilization data
83 b7478ce1 Iustin Pop
echo "$FI 2 2 2 2" > $T/util.data
84 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
85 b7478ce1 Iustin Pop
echo Testing hbal/text with bad utilization data
86 b7478ce1 Iustin Pop
echo "$FI 2 a 3b" > $T/util.data
87 1a3cc8ad Iustin Pop
! ./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
88 9afa0de1 Guido Trotter
echo Testing hbal/text with instance exclusion/selection
89 1a3cc8ad Iustin Pop
./hbal -t$T/$RAPI.data $GROUP --exclude-instances=$FI
90 9afa0de1 Guido Trotter
./hbal -t$T/$RAPI.data $GROUP --select-instances=$FI
91 b7478ce1 Iustin Pop
! ./hbal -t$T/$RAPI.data --exclude-instances=no_such_instance
92 9afa0de1 Guido Trotter
! ./hbal -t$T/$RAPI.data --select-instances=no_such_instance
93 b7478ce1 Iustin Pop
echo Testing hbal/text with tag exclusion
94 1a3cc8ad Iustin Pop
./hbal -t $T/$RAPI.data $GROUP --exclusion-tags=no_such_tag
95 b7478ce1 Iustin Pop
echo Testing hbal multiple backend failure
96 b7478ce1 Iustin Pop
! ./hbal -t $T/$RAPI.data -L$LUXI
97 b7478ce1 Iustin Pop
echo Testing hbal no backend failure
98 b7478ce1 Iustin Pop
! ./hbal
99 31728b11 Iustin Pop
100 31728b11 Iustin Pop
echo Getting data files for hail
101 b880f1d1 Iustin Pop
for dtemplate in plain drbd; do
102 b880f1d1 Iustin Pop
  $CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
103 b880f1d1 Iustin Pop
      --disks 128m -t $dtemplate -o no_such_os no_such_instance \
104 b880f1d1 Iustin Pop
      > $T/h-alloc-$dtemplate.json
105 b880f1d1 Iustin Pop
done
106 b880f1d1 Iustin Pop
$CLUSTER gnt-debug allocator --dir in --mode relocate \
107 b7478ce1 Iustin Pop
    -o no_such_os $FI > $T/h-reloc.json
108 b880f1d1 Iustin Pop
$CLUSTER gnt-debug allocator --dir in --mode multi-evacuate \
109 b880f1d1 Iustin Pop
    $FN > $T/h-evacuate.json
110 b880f1d1 Iustin Pop
for dtemplate in plain drbd; do
111 b880f1d1 Iustin Pop
  echo Testing hail/allocate-$dtemplate
112 b880f1d1 Iustin Pop
  ./hail $T/h-alloc-$dtemplate.json
113 b880f1d1 Iustin Pop
done
114 b7478ce1 Iustin Pop
echo Testing hail/relocate for instance $FI
115 31728b11 Iustin Pop
./hail $T/h-reloc.json
116 b880f1d1 Iustin Pop
echo Testing hail/evacuate for node $FN
117 b880f1d1 Iustin Pop
./hail $T/h-evacuate.json
118 31728b11 Iustin Pop
119 31728b11 Iustin Pop
HOUT="$T/hspace.out"
120 31728b11 Iustin Pop
121 31728b11 Iustin Pop
check_hspace_out() {
122 31728b11 Iustin Pop
    set -u
123 31728b11 Iustin Pop
    set -e
124 31728b11 Iustin Pop
    source "$HOUT"
125 31728b11 Iustin Pop
    echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
126 31728b11 Iustin Pop
    echo TSPEC=$HTS_TSPEC
127 31728b11 Iustin Pop
    echo OK=$HTS_OK
128 31728b11 Iustin Pop
}
129 31728b11 Iustin Pop
130 31728b11 Iustin Pop
TIER="--tiered 102400,8192,2"
131 1c78dbd2 Iustin Pop
SIMU="--simu=preferred,10,6835937,32768,4"
132 31728b11 Iustin Pop
echo Testing hspace/luxi
133 b880f1d1 Iustin Pop
./hspace -L$LUXI $TIER -v > $HOUT
134 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
135 31728b11 Iustin Pop
echo Testing hspace/rapi
136 b880f1d1 Iustin Pop
./hspace -m$RAPI $TIER -v > $HOUT
137 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
138 31728b11 Iustin Pop
echo Testing hspace/text
139 b880f1d1 Iustin Pop
./hspace -t$T/$RAPI.data $TIER -v > $HOUT
140 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
141 31728b11 Iustin Pop
echo Testing hspace/simu
142 31728b11 Iustin Pop
# ~6T disk space, 32G ram, 4 VCPUs
143 b7478ce1 Iustin Pop
./hspace $SIMU $TIER -v > $HOUT
144 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
145 b7478ce1 Iustin Pop
# Wrong tiered spec input
146 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2,3x
147 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2,x
148 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2
149 b7478ce1 Iustin Pop
# Wrong simu spec
150 b7478ce1 Iustin Pop
! ./hspace --simu=1,2,x
151 b7478ce1 Iustin Pop
152 31728b11 Iustin Pop
echo All OK