Statistics
| Branch: | Tag: | Revision:

root / htools / live-test.sh @ 9afa0de1

History | View | Annotate | Download (5 kB)

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/selection
89
./hbal -t$T/$RAPI.data $GROUP --exclude-instances=$FI
90
./hbal -t$T/$RAPI.data $GROUP --select-instances=$FI
91
! ./hbal -t$T/$RAPI.data --exclude-instances=no_such_instance
92
! ./hbal -t$T/$RAPI.data --select-instances=no_such_instance
93
echo Testing hbal/text with tag exclusion
94
./hbal -t $T/$RAPI.data $GROUP --exclusion-tags=no_such_tag
95
echo Testing hbal multiple backend failure
96
! ./hbal -t $T/$RAPI.data -L$LUXI
97
echo Testing hbal no backend failure
98
! ./hbal
99

    
100
echo Getting data files for hail
101
for dtemplate in plain drbd; do
102
  $CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
103
      --disks 128m -t $dtemplate -o no_such_os no_such_instance \
104
      > $T/h-alloc-$dtemplate.json
105
done
106
$CLUSTER gnt-debug allocator --dir in --mode relocate \
107
    -o no_such_os $FI > $T/h-reloc.json
108
$CLUSTER gnt-debug allocator --dir in --mode multi-evacuate \
109
    $FN > $T/h-evacuate.json
110
for dtemplate in plain drbd; do
111
  echo Testing hail/allocate-$dtemplate
112
  ./hail $T/h-alloc-$dtemplate.json
113
done
114
echo Testing hail/relocate for instance $FI
115
./hail $T/h-reloc.json
116
echo Testing hail/evacuate for node $FN
117
./hail $T/h-evacuate.json
118

    
119
HOUT="$T/hspace.out"
120

    
121
check_hspace_out() {
122
    set -u
123
    set -e
124
    source "$HOUT"
125
    echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
126
    echo TSPEC=$HTS_TSPEC
127
    echo OK=$HTS_OK
128
}
129

    
130
TIER="--tiered 102400,8192,2"
131
SIMU="--simu=preferred,10,6835937,32768,4"
132
echo Testing hspace/luxi
133
./hspace -L$LUXI $TIER -v > $HOUT
134
( check_hspace_out ) || exit 1
135
echo Testing hspace/rapi
136
./hspace -m$RAPI $TIER -v > $HOUT
137
( check_hspace_out ) || exit 1
138
echo Testing hspace/text
139
./hspace -t$T/$RAPI.data $TIER -v > $HOUT
140
( check_hspace_out ) || exit 1
141
echo Testing hspace/simu
142
# ~6T disk space, 32G ram, 4 VCPUs
143
./hspace $SIMU $TIER -v > $HOUT
144
( check_hspace_out ) || exit 1
145
# Wrong tiered spec input
146
! ./hspace $SIMU --tiered 1,2,3x
147
! ./hspace $SIMU --tiered 1,2,x
148
! ./hspace $SIMU --tiered 1,2
149
# Wrong simu spec
150
! ./hspace --simu=1,2,x
151

    
152
echo All OK