root / htools / offline-test.sh @ 3e7220e4
History | View | Annotate | Download (3 kB)
1 |
#!/bin/bash |
---|---|
2 |
|
3 |
# Copyright (C) 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 an offline testing script for most/all of the htools |
21 |
# programs, checking basic command line functionality. |
22 |
|
23 |
set -e |
24 |
|
25 |
. $(dirname $0)/cli-tests-defs.sh |
26 |
|
27 |
T=`mktemp -d` |
28 |
trap 'rm -rf $T' EXIT |
29 |
trap 'echo FAIL' ERR |
30 |
echo Using $T as temporary dir |
31 |
|
32 |
echo Checking command line basic options |
33 |
for prog in $ALL_ROLES; do |
34 |
$prog --version >/dev/null |
35 |
$prog --help >/dev/null |
36 |
! $prog --no-such-option 2>/dev/null |
37 |
done |
38 |
echo OK |
39 |
|
40 |
echo Checking missing backend failure |
41 |
for prog in hspace hinfo hbal; do |
42 |
! $prog 2>/dev/null |
43 |
done |
44 |
echo OK |
45 |
|
46 |
echo Checking hail missing input file |
47 |
! hail 2>/dev/null |
48 |
echo OK |
49 |
|
50 |
echo Checking extra arguments |
51 |
for prog in hspace hbal hinfo; do |
52 |
! $prog unexpected-argument 2>&1 | \ |
53 |
grep -q "Error: this program doesn't take any arguments" |
54 |
done |
55 |
echo OK |
56 |
|
57 |
echo Checking failure on multiple backends |
58 |
(! hbal -t /dev/null -m localhost 2>&1 ) | \ |
59 |
grep -q "Error: Only one of the rapi, luxi, and data files options should be given." |
60 |
echo OK |
61 |
|
62 |
echo Checking hspace machine-readable mode |
63 |
hspace --simu p,4,8T,64g,16 --machine-readable \ |
64 |
--disk-template drbd -l 8 >$T/capacity |
65 |
( . $T/capacity && test "$HTS_OK" = "1" ) |
66 |
echo OK |
67 |
|
68 |
echo Checking hspace simulation to hinfo to hbal |
69 |
# this cluster spec should be fine |
70 |
hspace --simu p,4,8T,64g,16 -S $T/simu-onegroup \ |
71 |
--disk-template drbd -l 8 -v -v -v >/dev/null 2>&1 |
72 |
# results in .tiered and .standard |
73 |
for suffix in standard tiered; do |
74 |
BACKEND="-t$T/simu-onegroup.$suffix" |
75 |
hinfo -v -v -p --print-instances $BACKEND >/dev/null 2>&1 |
76 |
hbal -v -v -p --print-instances $BACKEND >/dev/null 2>&1 |
77 |
# hbal should not be able to balance |
78 |
hbal $BACKEND | grep -qE "(Nothing to do, exiting|No solution found)" |
79 |
done |
80 |
echo OK |
81 |
|
82 |
echo Checking hinfo and hbal on multi-nodegroup |
83 |
hspace --simu p,4,8T,64g,16 --simu p,4,8T,64g,16 \ |
84 |
-S $T/simu-twogroups --disk-template drbd -l 8 >/dev/null 2>&1 |
85 |
# results in .tiered and .standard |
86 |
for suffix in standard tiered; do |
87 |
BACKEND="-t$T/simu-twogroups.$suffix" |
88 |
hinfo -v -v -p --print-instances $BACKEND >/dev/null 2>&1 |
89 |
! hbal $BACKEND >/dev/null 2>&1 |
90 |
# hbal should not be able to balance |
91 |
! hbal $BACKEND 2>&1 | grep -q "Found multiple node groups" |
92 |
# but hbal should be able to balance one node group |
93 |
hbal $BACKEND -G group-01 >/dev/null |
94 |
# and it should not find an invalid group |
95 |
! hbal $BACKEND -G no-such-group >/dev/null 2>&1 |
96 |
done |
97 |
echo OK |
98 |
|
99 |
echo All OK |