Statistics
| Branch: | Tag: | Revision:

root / test / hs / offline-test.sh @ 5f7d4181

History | View | Annotate | Download (3.9 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
# Optional argument that specifies the test files to run. If not
24
# specified, then all tests are run.
25
#
26
# For example, a value of 'balancing' runs the file
27
# 'shelltests/htools-balancing.test'.  Multiple files can be specified
28
# using shell notation, for example, '{balancing,basic}'.
29
TESTS=${1:-*}
30

    
31
set -e
32
set -o pipefail
33

    
34
. $(dirname $0)/cli-tests-defs.sh
35

    
36
echo Running offline htools tests
37

    
38
export T=`mktemp -d`
39
trap 'rm -rf $T' EXIT
40
trap 'echo FAIL to build test files' ERR
41
echo Using $T as temporary dir
42

    
43
echo -n Generating hspace simulation data for hinfo and hbal...
44
# this cluster spec should be fine
45
./test/hs/hspace --simu p,4,8T,64g,16 -S $T/simu-onegroup \
46
  --disk-template drbd -l 8 -v -v -v >/dev/null 2>&1
47
echo OK
48

    
49
echo -n Generating hinfo and hbal test files for multi-group...
50
./test/hs/hspace --simu p,4,8T,64g,16 --simu p,4,8T,64g,16 \
51
  -S $T/simu-twogroups --disk-template drbd -l 8 >/dev/null 2>&1
52
echo OK
53

    
54
echo -n Generating test files for rebalancing...
55
# we generate a cluster with two node groups, one with unallocable
56
# policy, then we change all nodes from this group to the allocable
57
# one, and we check for rebalancing
58
FROOT="$T/simu-rebal-orig"
59
./test/hs/hspace --simu u,4,8T,64g,16 --simu p,4,8T,64g,16 \
60
  -S $FROOT --disk-template drbd -l 8 >/dev/null 2>&1
61
for suffix in standard tiered; do
62
  RELOC="$T/simu-rebal-merged.$suffix"
63
  # this relocates the nodes
64
  sed -re 's/^(node-.*|fake-uuid-)-02(|.*)/\1-01\2/' \
65
    < $FROOT.$suffix > $RELOC
66
done
67
export BACKEND_BAL_STD="-t$T/simu-rebal-merged.standard"
68
export BACKEND_BAL_TIER="-t$T/simu-rebal-merged.tiered"
69
echo OK
70

    
71
# For various tests
72
export BACKEND_DYNU="-t $T/simu-onegroup.standard"
73
export BACKEND_EXCL="-t $T/simu-onegroup.standard"
74

    
75
echo -n Generating data files for IAllocator checks...
76
for evac_mode in primary-only secondary-only all; do
77
  sed -e 's/"evac_mode": "all"/"evac_mode": "'${evac_mode}'"/' \
78
    -e 's/"spindles": [0-9]\+,//' \
79
    < $TESTDATA_DIR/hail-node-evac.json \
80
    > $T/hail-node-evac.json.$evac_mode
81
done
82
for bf in hail-alloc-drbd hail-alloc-invalid-twodisks hail-alloc-twodisks \
83
  hail-change-group hail-node-evac hail-reloc-drbd hail-alloc-spindles; do
84
  f=$bf.json
85
  sed -e 's/"exclusive_storage": false/"exclusive_storage": true/' \
86
    < $TESTDATA_DIR/$f > $T/$f.excl-stor
87
  sed -e 's/"exclusive_storage": false/"exclusive_storage": true/' \
88
    -e 's/"spindles": [0-9]\+,//' \
89
    < $TESTDATA_DIR/$f > $T/$f.fail-excl-stor
90
done
91
echo OK
92

    
93
echo -n Checking file-based RAPI...
94
mkdir -p $T/hscan
95
export RAPI_URL="file://$TESTDATA_DIR/rapi"
96
./test/hs/hscan -d $T/hscan/ -p -v -v $RAPI_URL >/dev/null 2>&1
97
# check that we file parsing is correct, i.e. hscan saves correct text
98
# files, and is idempotent (rapi+text == rapi); more is tested in
99
# shelltest later
100
RAPI_TXT="$(ls $T/hscan/*.data|head -n1)"
101
./test/hs/hinfo -p --print-instances -m $RAPI_URL > $T/hscan/direct.hinfo 2>&1
102
./test/hs/hinfo -p --print-instances -t $RAPI_TXT > $T/hscan/fromtext.hinfo 2>&1
103
echo OK
104

    
105
echo Running shelltest...
106

    
107
shelltest $SHELLTESTARGS \
108
  ${TOP_SRCDIR:-.}/test/hs/shelltests/htools-$TESTS.test