Statistics
| Branch: | Tag: | Revision:

root / live-test.sh @ 306cccd5

History | View | Annotate | Download (4.5 kB)

1 31728b11 Iustin Pop
#!/bin/bash
2 31728b11 Iustin Pop
3 31728b11 Iustin Pop
# Copyright (C) 2009 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 31728b11 Iustin Pop
# used to login on the cluster (e.g. CLUSTER="ssh root@cluster").
30 31728b11 Iustin Pop
31 31728b11 Iustin Pop
set -e
32 31728b11 Iustin Pop
: ${RAPI:=localhost}
33 31728b11 Iustin Pop
T=`mktemp -d`
34 31728b11 Iustin Pop
trap 'rm -rf $T' EXIT
35 31728b11 Iustin Pop
echo Using $T as temporary dir
36 31728b11 Iustin Pop
37 b880f1d1 Iustin Pop
echo Checking command line
38 b880f1d1 Iustin Pop
for prog in hscan hbal hail hspace; do
39 b880f1d1 Iustin Pop
    ./$prog --version
40 b880f1d1 Iustin Pop
    ./$prog --help
41 b7478ce1 Iustin Pop
    ! ./$prog --no-such-option
42 b880f1d1 Iustin Pop
done
43 b880f1d1 Iustin Pop
44 b880f1d1 Iustin Pop
echo Testing hscan/rapi
45 b880f1d1 Iustin Pop
./hscan -d$T $RAPI -p
46 b880f1d1 Iustin Pop
echo Testing hscan/luxi
47 b880f1d1 Iustin Pop
./hscan -d$T -L$LUXI -p
48 b880f1d1 Iustin Pop
echo Comparing hscan results...
49 b880f1d1 Iustin Pop
diff -u $T/$RAPI.data $T/LOCAL.data
50 31728b11 Iustin Pop
51 b7478ce1 Iustin Pop
FN=$(head -n1 $T/$RAPI.data|cut -d \| -f1)
52 b7478ce1 Iustin Pop
FI=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list)
53 b7478ce1 Iustin Pop
54 b7478ce1 Iustin Pop
55 31728b11 Iustin Pop
echo Testing hbal/luxi
56 b880f1d1 Iustin Pop
./hbal -L$LUXI -p --print-instances -C$T/hbal-luxi-cmds.sh
57 b880f1d1 Iustin Pop
bash -n $T/hbal-luxi-cmds.sh
58 31728b11 Iustin Pop
echo Testing hbal/rapi
59 b880f1d1 Iustin Pop
./hbal -m$RAPI -p --print-instances -C$T/hbal-rapi-cmds.sh
60 b880f1d1 Iustin Pop
bash -n $T/hbal-rapi-cmds.sh
61 31728b11 Iustin Pop
echo Testing hbal/text
62 b880f1d1 Iustin Pop
./hbal -t$T/$RAPI.data -p --print-instances -C$T/hbal-text-cmds.sh
63 b880f1d1 Iustin Pop
bash -n $T/hbal-text-cmds.sh
64 b7478ce1 Iustin Pop
echo Comparing hbal results
65 b7478ce1 Iustin Pop
diff -u $T/hbal-luxi-cmds.sh $T/hbal-rapi-cmds.sh
66 b7478ce1 Iustin Pop
diff -u $T/hbal-luxi-cmds.sh $T/hbal-text-cmds.sh
67 b7478ce1 Iustin Pop
68 b880f1d1 Iustin Pop
69 b880f1d1 Iustin Pop
echo Testing hbal/text with evacuation mode
70 b880f1d1 Iustin Pop
./hbal -t$T/$RAPI.data -E
71 b7478ce1 Iustin Pop
echo Testing hbal/text with no disk moves
72 b7478ce1 Iustin Pop
./hbal -t$T/$RAPI.data --no-disk-moves
73 b880f1d1 Iustin Pop
echo Testing hbal/text with offline node mode
74 b880f1d1 Iustin Pop
./hbal -t$T/$RAPI.data -O$FN
75 b7478ce1 Iustin Pop
echo Testing hbal/text with utilization data
76 b7478ce1 Iustin Pop
echo "$FI 2 2 2 2" > $T/util.data
77 b7478ce1 Iustin Pop
./hbal -t$T/$RAPI.data -U $T/util.data
78 b7478ce1 Iustin Pop
echo Testing hbal/text with bad utilization data
79 b7478ce1 Iustin Pop
echo "$FI 2 a 3b" > $T/util.data
80 b7478ce1 Iustin Pop
! ./hbal -t$T/$RAPI.data -U $T/util.data
81 b7478ce1 Iustin Pop
echo Testing hbal/text with instance exclusion
82 b7478ce1 Iustin Pop
./hbal -t$T/$RAPI.data --exclude-instances=$FI
83 b7478ce1 Iustin Pop
! ./hbal -t$T/$RAPI.data --exclude-instances=no_such_instance
84 b7478ce1 Iustin Pop
echo Testing hbal/text with tag exclusion
85 b7478ce1 Iustin Pop
./hbal -t $T/$RAPI.data --exclusion-tags=no_such_tag
86 b7478ce1 Iustin Pop
echo Testing hbal multiple backend failure
87 b7478ce1 Iustin Pop
! ./hbal -t $T/$RAPI.data -L$LUXI
88 b7478ce1 Iustin Pop
echo Testing hbal no backend failure
89 b7478ce1 Iustin Pop
! ./hbal
90 31728b11 Iustin Pop
91 31728b11 Iustin Pop
echo Getting data files for hail
92 b880f1d1 Iustin Pop
for dtemplate in plain drbd; do
93 b880f1d1 Iustin Pop
  $CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
94 b880f1d1 Iustin Pop
      --disks 128m -t $dtemplate -o no_such_os no_such_instance \
95 b880f1d1 Iustin Pop
      > $T/h-alloc-$dtemplate.json
96 b880f1d1 Iustin Pop
done
97 b880f1d1 Iustin Pop
$CLUSTER gnt-debug allocator --dir in --mode relocate \
98 b7478ce1 Iustin Pop
    -o no_such_os $FI > $T/h-reloc.json
99 b880f1d1 Iustin Pop
$CLUSTER gnt-debug allocator --dir in --mode multi-evacuate \
100 b880f1d1 Iustin Pop
    $FN > $T/h-evacuate.json
101 b880f1d1 Iustin Pop
for dtemplate in plain drbd; do
102 b880f1d1 Iustin Pop
  echo Testing hail/allocate-$dtemplate
103 b880f1d1 Iustin Pop
  ./hail $T/h-alloc-$dtemplate.json
104 b880f1d1 Iustin Pop
done
105 b7478ce1 Iustin Pop
echo Testing hail/relocate for instance $FI
106 31728b11 Iustin Pop
./hail $T/h-reloc.json
107 b880f1d1 Iustin Pop
echo Testing hail/evacuate for node $FN
108 b880f1d1 Iustin Pop
./hail $T/h-evacuate.json
109 31728b11 Iustin Pop
110 31728b11 Iustin Pop
HOUT="$T/hspace.out"
111 31728b11 Iustin Pop
112 31728b11 Iustin Pop
check_hspace_out() {
113 31728b11 Iustin Pop
    set -u
114 31728b11 Iustin Pop
    set -e
115 31728b11 Iustin Pop
    source "$HOUT"
116 31728b11 Iustin Pop
    echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
117 31728b11 Iustin Pop
    echo TSPEC=$HTS_TSPEC
118 31728b11 Iustin Pop
    echo OK=$HTS_OK
119 31728b11 Iustin Pop
}
120 31728b11 Iustin Pop
121 31728b11 Iustin Pop
TIER="--tiered 102400,8192,2"
122 b7478ce1 Iustin Pop
SIMU="--simu=10,6835937,32768,4"
123 31728b11 Iustin Pop
echo Testing hspace/luxi
124 b880f1d1 Iustin Pop
./hspace -L$LUXI $TIER -v > $HOUT
125 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
126 31728b11 Iustin Pop
echo Testing hspace/rapi
127 b880f1d1 Iustin Pop
./hspace -m$RAPI $TIER -v > $HOUT
128 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
129 31728b11 Iustin Pop
echo Testing hspace/text
130 b880f1d1 Iustin Pop
./hspace -t$T/$RAPI.data $TIER -v > $HOUT
131 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
132 31728b11 Iustin Pop
echo Testing hspace/simu
133 31728b11 Iustin Pop
# ~6T disk space, 32G ram, 4 VCPUs
134 b7478ce1 Iustin Pop
./hspace $SIMU $TIER -v > $HOUT
135 31728b11 Iustin Pop
( check_hspace_out ) || exit 1
136 b7478ce1 Iustin Pop
# Wrong tiered spec input
137 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2,3x
138 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2,x
139 b7478ce1 Iustin Pop
! ./hspace $SIMU --tiered 1,2
140 b7478ce1 Iustin Pop
# Wrong simu spec
141 b7478ce1 Iustin Pop
! ./hspace --simu=1,2,x
142 b7478ce1 Iustin Pop
143 31728b11 Iustin Pop
echo All OK