root / htools / offline-test.sh @ 55ffacfa
History | View | Annotate | Download (6.8 kB)
1 | 42089b55 | Iustin Pop | #!/bin/bash |
---|---|---|---|
2 | 42089b55 | Iustin Pop | |
3 | 42089b55 | Iustin Pop | # Copyright (C) 2012 Google Inc. |
4 | 42089b55 | Iustin Pop | |
5 | 42089b55 | Iustin Pop | # This program is free software; you can redistribute it and/or modify |
6 | 42089b55 | Iustin Pop | # it under the terms of the GNU General Public License as published by |
7 | 42089b55 | Iustin Pop | # the Free Software Foundation; either version 2 of the License, or |
8 | 42089b55 | Iustin Pop | # (at your option) any later version. |
9 | 42089b55 | Iustin Pop | |
10 | 42089b55 | Iustin Pop | # This program is distributed in the hope that it will be useful, but |
11 | 42089b55 | Iustin Pop | # WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 42089b55 | Iustin Pop | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | 42089b55 | Iustin Pop | # General Public License for more details. |
14 | 42089b55 | Iustin Pop | |
15 | 42089b55 | Iustin Pop | # You should have received a copy of the GNU General Public License |
16 | 42089b55 | Iustin Pop | # along with this program; if not, write to the Free Software |
17 | 42089b55 | Iustin Pop | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | 42089b55 | Iustin Pop | # 02110-1301, USA. |
19 | 42089b55 | Iustin Pop | |
20 | 42089b55 | Iustin Pop | # This is an offline testing script for most/all of the htools |
21 | 42089b55 | Iustin Pop | # programs, checking basic command line functionality. |
22 | 42089b55 | Iustin Pop | |
23 | 42089b55 | Iustin Pop | set -e |
24 | 42089b55 | Iustin Pop | |
25 | 42089b55 | Iustin Pop | . $(dirname $0)/cli-tests-defs.sh |
26 | 42089b55 | Iustin Pop | |
27 | 3e7220e4 | Iustin Pop | T=`mktemp -d` |
28 | 3e7220e4 | Iustin Pop | trap 'rm -rf $T' EXIT |
29 | 3e7220e4 | Iustin Pop | trap 'echo FAIL' ERR |
30 | 3e7220e4 | Iustin Pop | echo Using $T as temporary dir |
31 | 3e7220e4 | Iustin Pop | |
32 | 3e7220e4 | Iustin Pop | echo Checking command line basic options |
33 | 42089b55 | Iustin Pop | for prog in $ALL_ROLES; do |
34 | 42089b55 | Iustin Pop | $prog --version >/dev/null |
35 | 42089b55 | Iustin Pop | $prog --help >/dev/null |
36 | 42089b55 | Iustin Pop | ! $prog --no-such-option 2>/dev/null |
37 | 42089b55 | Iustin Pop | done |
38 | 3e7220e4 | Iustin Pop | echo OK |
39 | 3e7220e4 | Iustin Pop | |
40 | 3e7220e4 | Iustin Pop | echo Checking missing backend failure |
41 | 3e7220e4 | Iustin Pop | for prog in hspace hinfo hbal; do |
42 | 3e7220e4 | Iustin Pop | ! $prog 2>/dev/null |
43 | 3e7220e4 | Iustin Pop | done |
44 | 3e7220e4 | Iustin Pop | echo OK |
45 | 3e7220e4 | Iustin Pop | |
46 | 3e7220e4 | Iustin Pop | echo Checking hail missing input file |
47 | 3e7220e4 | Iustin Pop | ! hail 2>/dev/null |
48 | 3e7220e4 | Iustin Pop | echo OK |
49 | 3e7220e4 | Iustin Pop | |
50 | 3e7220e4 | Iustin Pop | echo Checking extra arguments |
51 | 3e7220e4 | Iustin Pop | for prog in hspace hbal hinfo; do |
52 | 3e7220e4 | Iustin Pop | ! $prog unexpected-argument 2>&1 | \ |
53 | 3e7220e4 | Iustin Pop | grep -q "Error: this program doesn't take any arguments" |
54 | 3e7220e4 | Iustin Pop | done |
55 | 3e7220e4 | Iustin Pop | echo OK |
56 | 3e7220e4 | Iustin Pop | |
57 | 3e7220e4 | Iustin Pop | echo Checking failure on multiple backends |
58 | 3e7220e4 | Iustin Pop | (! hbal -t /dev/null -m localhost 2>&1 ) | \ |
59 | 3e7220e4 | Iustin Pop | grep -q "Error: Only one of the rapi, luxi, and data files options should be given." |
60 | 3e7220e4 | Iustin Pop | echo OK |
61 | 3e7220e4 | Iustin Pop | |
62 | 3e7220e4 | Iustin Pop | echo Checking hspace machine-readable mode |
63 | 3e7220e4 | Iustin Pop | hspace --simu p,4,8T,64g,16 --machine-readable \ |
64 | 3e7220e4 | Iustin Pop | --disk-template drbd -l 8 >$T/capacity |
65 | 3e7220e4 | Iustin Pop | ( . $T/capacity && test "$HTS_OK" = "1" ) |
66 | 3e7220e4 | Iustin Pop | echo OK |
67 | 3e7220e4 | Iustin Pop | |
68 | 3e7220e4 | Iustin Pop | echo Checking hspace simulation to hinfo to hbal |
69 | 3e7220e4 | Iustin Pop | # this cluster spec should be fine |
70 | 3e7220e4 | Iustin Pop | hspace --simu p,4,8T,64g,16 -S $T/simu-onegroup \ |
71 | 3e7220e4 | Iustin Pop | --disk-template drbd -l 8 -v -v -v >/dev/null 2>&1 |
72 | 3e7220e4 | Iustin Pop | # results in .tiered and .standard |
73 | 3e7220e4 | Iustin Pop | for suffix in standard tiered; do |
74 | 3e7220e4 | Iustin Pop | BACKEND="-t$T/simu-onegroup.$suffix" |
75 | 3e7220e4 | Iustin Pop | hinfo -v -v -p --print-instances $BACKEND >/dev/null 2>&1 |
76 | 3e7220e4 | Iustin Pop | hbal -v -v -p --print-instances $BACKEND >/dev/null 2>&1 |
77 | 3e7220e4 | Iustin Pop | # hbal should not be able to balance |
78 | 3e7220e4 | Iustin Pop | hbal $BACKEND | grep -qE "(Nothing to do, exiting|No solution found)" |
79 | 3e7220e4 | Iustin Pop | done |
80 | 3e7220e4 | Iustin Pop | echo OK |
81 | 3e7220e4 | Iustin Pop | |
82 | 3e7220e4 | Iustin Pop | echo Checking hinfo and hbal on multi-nodegroup |
83 | 3e7220e4 | Iustin Pop | hspace --simu p,4,8T,64g,16 --simu p,4,8T,64g,16 \ |
84 | 3e7220e4 | Iustin Pop | -S $T/simu-twogroups --disk-template drbd -l 8 >/dev/null 2>&1 |
85 | 3e7220e4 | Iustin Pop | # results in .tiered and .standard |
86 | 3e7220e4 | Iustin Pop | for suffix in standard tiered; do |
87 | 3e7220e4 | Iustin Pop | BACKEND="-t$T/simu-twogroups.$suffix" |
88 | 3e7220e4 | Iustin Pop | hinfo -v -v -p --print-instances $BACKEND >/dev/null 2>&1 |
89 | 3e7220e4 | Iustin Pop | ! hbal $BACKEND >/dev/null 2>&1 |
90 | 3e7220e4 | Iustin Pop | # hbal should not be able to balance |
91 | 3e7220e4 | Iustin Pop | ! hbal $BACKEND 2>&1 | grep -q "Found multiple node groups" |
92 | 3e7220e4 | Iustin Pop | # but hbal should be able to balance one node group |
93 | 3e7220e4 | Iustin Pop | hbal $BACKEND -G group-01 >/dev/null |
94 | 3e7220e4 | Iustin Pop | # and it should not find an invalid group |
95 | 3e7220e4 | Iustin Pop | ! hbal $BACKEND -G no-such-group >/dev/null 2>&1 |
96 | 3e7220e4 | Iustin Pop | done |
97 | 3e7220e4 | Iustin Pop | echo OK |
98 | 42089b55 | Iustin Pop | |
99 | 16197d69 | Iustin Pop | echo Checking rebalancing |
100 | 16197d69 | Iustin Pop | # we generate a cluster with two node groups, one with unallocable |
101 | 16197d69 | Iustin Pop | # policy, then we change all nodes from this group to the allocable |
102 | 16197d69 | Iustin Pop | # one, and we check for rebalancing |
103 | 16197d69 | Iustin Pop | FROOT="$T/simu-rebal-orig" |
104 | 6bbd76d2 | Iustin Pop | hspace --simu u,4,8T,64g,16 --simu p,4,8T,64g,16 \ |
105 | 16197d69 | Iustin Pop | -S $FROOT --disk-template drbd -l 8 >/dev/null 2>&1 |
106 | 16197d69 | Iustin Pop | for suffix in standard tiered; do |
107 | 16197d69 | Iustin Pop | RELOC="$T/simu-rebal-merged.$suffix" |
108 | 16197d69 | Iustin Pop | # this relocates the nodes |
109 | 16197d69 | Iustin Pop | sed -re 's/^(node-.*|fake-uuid-)-02(|.*)/\1-01\2/' \ |
110 | 16197d69 | Iustin Pop | < $FROOT.$suffix > $RELOC |
111 | 16197d69 | Iustin Pop | BACKEND="-t$RELOC" |
112 | 16197d69 | Iustin Pop | hinfo -v -v -p --print-instances $BACKEND >/dev/null 2>&1 |
113 | 16197d69 | Iustin Pop | hbal -v -v -v -p --print-instances $BACKEND -G group-01 2>/dev/null | \ |
114 | 16197d69 | Iustin Pop | grep -qE -v "(Nothing to do, exiting|No solution found)" |
115 | 16197d69 | Iustin Pop | hbal $BACKEND -G group-01 -C$T/rebal-cmds.$suffix \ |
116 | 16197d69 | Iustin Pop | -S $T/simu-rebal.$suffix >/dev/null 2>&1 |
117 | 16197d69 | Iustin Pop | grep -qE "gnt-instance (failover|migrate|replace-disks)" \ |
118 | 16197d69 | Iustin Pop | $T/rebal-cmds.$suffix |
119 | 16197d69 | Iustin Pop | hbal $BACKEND -G group-01 -C \ |
120 | 16197d69 | Iustin Pop | -S $T/simu-rebal.$suffix 2>/dev/null | \ |
121 | 16197d69 | Iustin Pop | grep -qE "gnt-instance (failover|migrate|replace-disks)" |
122 | 16197d69 | Iustin Pop | # state saved by hbal should be original |
123 | 16197d69 | Iustin Pop | cmp $RELOC $T/simu-rebal.$suffix.original |
124 | 16197d69 | Iustin Pop | # and we can't double rebalance |
125 | 16197d69 | Iustin Pop | hbal -t $T/simu-rebal.$suffix.balanced \ |
126 | 16197d69 | Iustin Pop | -G group-01 | \ |
127 | 16197d69 | Iustin Pop | grep -qE "(Nothing to do, exiting|No solution found)" |
128 | 16197d69 | Iustin Pop | |
129 | 16197d69 | Iustin Pop | done |
130 | 16197d69 | Iustin Pop | echo OK |
131 | 16197d69 | Iustin Pop | |
132 | 6bbd76d2 | Iustin Pop | echo IAllocator checks |
133 | 6bbd76d2 | Iustin Pop | # test that on invalid files it can't parse the request |
134 | 6bbd76d2 | Iustin Pop | ! hail /dev/null 2>&1 | grep -q "Invalid JSON" |
135 | 6bbd76d2 | Iustin Pop | ! hail <(echo '[]') >/dev/null 2>&1 |
136 | 6bbd76d2 | Iustin Pop | ! hail <(echo '{}') 2>&1 | grep -q "key 'request' not found" |
137 | 6bbd76d2 | Iustin Pop | ! hail <(echo '{"request": 0}') 2>&1 | grep -q "key 'request'" |
138 | 6bbd76d2 | Iustin Pop | ! hail $TESTDATA_DIR/hail-invalid-reloc.json >/dev/null 2>&1 |
139 | 6bbd76d2 | Iustin Pop | |
140 | 6bbd76d2 | Iustin Pop | # just test that it can read the file, print the cluster and generate |
141 | 6bbd76d2 | Iustin Pop | # pre and post allocation files |
142 | 6bbd76d2 | Iustin Pop | hail -v -v -v -p $TESTDATA_DIR/hail-alloc-drbd.json \ |
143 | 6bbd76d2 | Iustin Pop | -S $T/hail-alloc >/dev/null 2>&1 |
144 | 6bbd76d2 | Iustin Pop | ! cmp -s $T/hail-alloc.pre-ialloc $T/hail-alloc.post-ialloc |
145 | 6bbd76d2 | Iustin Pop | hail -v -v -v -p $TESTDATA_DIR/hail-reloc-drbd.json \ |
146 | 6bbd76d2 | Iustin Pop | -S $T/hail-reloc >/dev/null 2>&1 |
147 | 6bbd76d2 | Iustin Pop | ! cmp -s $T/hail-reloc.pre-ialloc $T/hail-reloc.post-ialloc |
148 | 6bbd76d2 | Iustin Pop | |
149 | 6bbd76d2 | Iustin Pop | # and now start the real tests |
150 | 6bbd76d2 | Iustin Pop | hail $TESTDATA_DIR/hail-alloc-drbd.json | \ |
151 | 6bbd76d2 | Iustin Pop | grep -q '"success":true,.*,"result":\["node2","node1"\]' |
152 | 6bbd76d2 | Iustin Pop | hail $TESTDATA_DIR/hail-reloc-drbd.json | \ |
153 | 6bbd76d2 | Iustin Pop | grep -q '"success":true,.*,"result":\["node1"\]' |
154 | 6bbd76d2 | Iustin Pop | |
155 | 6bbd76d2 | Iustin Pop | hail $TESTDATA_DIR/hail-node-evac.json | \ |
156 | 6bbd76d2 | Iustin Pop | grep -Fq '"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"' |
157 | 6bbd76d2 | Iustin Pop | |
158 | 6bbd76d2 | Iustin Pop | hail $TESTDATA_DIR/hail-change-group.json | \ |
159 | 6bbd76d2 | Iustin Pop | grep -Fq '"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"' |
160 | 6bbd76d2 | Iustin Pop | |
161 | 6bbd76d2 | Iustin Pop | for evac_mode in primary-only secondary-only all; do |
162 | 6bbd76d2 | Iustin Pop | sed -e 's/"evac_mode": "all"/"evac_mode": "'${evac_mode}'"/' \ |
163 | 6bbd76d2 | Iustin Pop | < $TESTDATA_DIR/hail-node-evac.json \ |
164 | 6bbd76d2 | Iustin Pop | > $T/hail-node-evac.json.$evac_mode |
165 | 6bbd76d2 | Iustin Pop | hail $T/hail-node-evac.json.$evac_mode | \ |
166 | 6bbd76d2 | Iustin Pop | grep -q '"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"' |
167 | 6bbd76d2 | Iustin Pop | done |
168 | 6bbd76d2 | Iustin Pop | |
169 | 6bbd76d2 | Iustin Pop | # check that hail can use the simu and text backends |
170 | 6bbd76d2 | Iustin Pop | hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json | \ |
171 | 6bbd76d2 | Iustin Pop | grep -q '"success":true,' |
172 | 6bbd76d2 | Iustin Pop | hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json | \ |
173 | 6bbd76d2 | Iustin Pop | grep -q '"success":true,' |
174 | 6bbd76d2 | Iustin Pop | echo OK |
175 | 6bbd76d2 | Iustin Pop | |
176 | 55ffacfa | Iustin Pop | echo Checking file-based RAPI |
177 | 55ffacfa | Iustin Pop | mkdir -p $T/hscan |
178 | 55ffacfa | Iustin Pop | URL="file://$TESTDATA_DIR/rapi" |
179 | 55ffacfa | Iustin Pop | hinfo -v -v -p --print-instances -m $URL >/dev/null 2>&1 |
180 | 55ffacfa | Iustin Pop | hbal -v -v -p --print-instances -m $URL >/dev/null 2>&1 |
181 | 55ffacfa | Iustin Pop | hscan -d $T/hscan/ -p -v -v $URL >/dev/null 2>&1 |
182 | 55ffacfa | Iustin Pop | # check that we file parsing is correct, i.e. hscan saves correct text |
183 | 55ffacfa | Iustin Pop | # files, and is idempotent (rapi+text == rapi) |
184 | 55ffacfa | Iustin Pop | HS="$(ls $T/hscan/*.data|head -n1)" |
185 | 55ffacfa | Iustin Pop | hinfo -p --print-instances -m $URL > $T/hscan/direct.hinfo 2>&1 |
186 | 55ffacfa | Iustin Pop | hinfo -p --print-instances -t $HS > $T/hscan/fromtext.hinfo 2>&1 |
187 | 55ffacfa | Iustin Pop | cmp -s $T/hscan/direct.hinfo $T/hscan/fromtext.hinfo |
188 | 55ffacfa | Iustin Pop | echo OK |
189 | 55ffacfa | Iustin Pop | |
190 | 42089b55 | Iustin Pop | echo All OK |