Statistics
| Branch: | Tag: | Revision:

root / test / hs / live-test.sh @ d78970ba

History | View | Annotate | Download (5 kB)

1
#!/bin/bash
2

    
3
# Copyright (C) 2009, 2010, 2011, 2012 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
. $(dirname $0)/cli-tests-defs.sh
39

    
40
T=`mktemp -d`
41
trap 'rm -rf $T' EXIT
42
echo Using $T as temporary dir
43

    
44
echo Checking command line
45
for prog in $ALL_ROLES; do
46
  $prog --version
47
  $prog --help >/dev/null
48
  ! $prog --no-such-option 2>/dev/null
49
done
50

    
51
echo Testing hscan/rapi
52
hscan -d$T $RAPI -p
53
echo Testing hscan/luxi
54
hscan -d$T -L$LUXI -p
55
echo Comparing hscan results...
56
diff -u $T/$RAPI.data $T/LOCAL.data
57

    
58
FN=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_node_list)
59
FI=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list)
60

    
61

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

    
75

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

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

    
121
HOUT="$T/hspace.out"
122

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

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

    
154
echo All OK