live-test.sh 4.77 KB
Newer Older
Iustin Pop's avatar
Iustin Pop committed
1
2
#!/bin/bash

3
# Copyright (C) 2009, 2010 Google Inc.
Iustin Pop's avatar
Iustin Pop committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

# This is a live-testing script for most/all of the htools
# programs. It needs either to run on a live cluster or access to a
# cluster via ssh and an exported LUXI interface (via socat, for
23
24
# example). The cluster must not be empty (otherwise the hail relocate
# test will fail).
Iustin Pop's avatar
Iustin Pop committed
25
26
27
28

# Use: if running on a cluster master, just running it should be
# enough. If running remotely, set env vars as follows: LUXI to the
# export unix socket, RAPI to the cluster IP, CLUSTER to the command
29
30
31
32
# used to login on the cluster (e.g. CLUSTER="ssh root@cluster"). Note
# that when run against a multi-group cluster, the GROUP variable
# should be set to one of the groups (some operations work only on one
# group)
Iustin Pop's avatar
Iustin Pop committed
33
34
35

set -e
: ${RAPI:=localhost}
36
37
GROUP=${GROUP:+-G $GROUP}

Iustin Pop's avatar
Iustin Pop committed
38
39
40
41
T=`mktemp -d`
trap 'rm -rf $T' EXIT
echo Using $T as temporary dir

Iustin Pop's avatar
Iustin Pop committed
42
43
44
45
echo Checking command line
for prog in hscan hbal hail hspace; do
    ./$prog --version
    ./$prog --help
Iustin Pop's avatar
Iustin Pop committed
46
    ! ./$prog --no-such-option
Iustin Pop's avatar
Iustin Pop committed
47
48
49
50
51
52
53
54
done

echo Testing hscan/rapi
./hscan -d$T $RAPI -p
echo Testing hscan/luxi
./hscan -d$T -L$LUXI -p
echo Comparing hscan results...
diff -u $T/$RAPI.data $T/LOCAL.data
Iustin Pop's avatar
Iustin Pop committed
55

56
FN=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_node_list)
Iustin Pop's avatar
Iustin Pop committed
57
58
59
FI=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list)


Iustin Pop's avatar
Iustin Pop committed
60
echo Testing hbal/luxi
61
./hbal -L$LUXI $GROUP -p --print-instances -C$T/hbal-luxi-cmds.sh
Iustin Pop's avatar
Iustin Pop committed
62
bash -n $T/hbal-luxi-cmds.sh
Iustin Pop's avatar
Iustin Pop committed
63
echo Testing hbal/rapi
64
./hbal -m$RAPI $GROUP -p --print-instances -C$T/hbal-rapi-cmds.sh
Iustin Pop's avatar
Iustin Pop committed
65
bash -n $T/hbal-rapi-cmds.sh
Iustin Pop's avatar
Iustin Pop committed
66
echo Testing hbal/text
67
./hbal -t$T/$RAPI.data $GROUP -p --print-instances -C$T/hbal-text-cmds.sh
Iustin Pop's avatar
Iustin Pop committed
68
bash -n $T/hbal-text-cmds.sh
Iustin Pop's avatar
Iustin Pop committed
69
70
71
72
echo Comparing hbal results
diff -u $T/hbal-luxi-cmds.sh $T/hbal-rapi-cmds.sh
diff -u $T/hbal-luxi-cmds.sh $T/hbal-text-cmds.sh

Iustin Pop's avatar
Iustin Pop committed
73
74

echo Testing hbal/text with evacuation mode
75
./hbal -t$T/$RAPI.data $GROUP -E
Iustin Pop's avatar
Iustin Pop committed
76
echo Testing hbal/text with no disk moves
77
./hbal -t$T/$RAPI.data $GROUP --no-disk-moves
Iustin Pop's avatar
Iustin Pop committed
78
echo Testing hbal/text with offline node mode
79
./hbal -t$T/$RAPI.data $GROUP -O$FN
Iustin Pop's avatar
Iustin Pop committed
80
81
echo Testing hbal/text with utilization data
echo "$FI 2 2 2 2" > $T/util.data
82
./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
Iustin Pop's avatar
Iustin Pop committed
83
84
echo Testing hbal/text with bad utilization data
echo "$FI 2 a 3b" > $T/util.data
85
! ./hbal -t$T/$RAPI.data $GROUP -U $T/util.data
Iustin Pop's avatar
Iustin Pop committed
86
echo Testing hbal/text with instance exclusion
87
./hbal -t$T/$RAPI.data $GROUP --exclude-instances=$FI
Iustin Pop's avatar
Iustin Pop committed
88
89
! ./hbal -t$T/$RAPI.data --exclude-instances=no_such_instance
echo Testing hbal/text with tag exclusion
90
./hbal -t $T/$RAPI.data $GROUP --exclusion-tags=no_such_tag
Iustin Pop's avatar
Iustin Pop committed
91
92
93
94
echo Testing hbal multiple backend failure
! ./hbal -t $T/$RAPI.data -L$LUXI
echo Testing hbal no backend failure
! ./hbal
Iustin Pop's avatar
Iustin Pop committed
95
96

echo Getting data files for hail
Iustin Pop's avatar
Iustin Pop committed
97
98
99
100
101
102
for dtemplate in plain drbd; do
  $CLUSTER gnt-debug allocator --dir in --mode allocate --mem 128m \
      --disks 128m -t $dtemplate -o no_such_os no_such_instance \
      > $T/h-alloc-$dtemplate.json
done
$CLUSTER gnt-debug allocator --dir in --mode relocate \
Iustin Pop's avatar
Iustin Pop committed
103
    -o no_such_os $FI > $T/h-reloc.json
Iustin Pop's avatar
Iustin Pop committed
104
105
106
107
108
109
$CLUSTER gnt-debug allocator --dir in --mode multi-evacuate \
    $FN > $T/h-evacuate.json
for dtemplate in plain drbd; do
  echo Testing hail/allocate-$dtemplate
  ./hail $T/h-alloc-$dtemplate.json
done
Iustin Pop's avatar
Iustin Pop committed
110
echo Testing hail/relocate for instance $FI
Iustin Pop's avatar
Iustin Pop committed
111
./hail $T/h-reloc.json
Iustin Pop's avatar
Iustin Pop committed
112
113
echo Testing hail/evacuate for node $FN
./hail $T/h-evacuate.json
Iustin Pop's avatar
Iustin Pop committed
114
115
116
117
118
119
120
121
122
123
124
125
126

HOUT="$T/hspace.out"

check_hspace_out() {
    set -u
    set -e
    source "$HOUT"
    echo ALLOC_INSTANCES=$HTS_ALLOC_INSTANCES
    echo TSPEC=$HTS_TSPEC
    echo OK=$HTS_OK
}

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

Iustin Pop's avatar
Iustin Pop committed
148
echo All OK