Commit 189b51fa authored by Iustin Pop's avatar Iustin Pop
Browse files

Move generated htools test stubs to htest/



This moves the last (I think) htools-related bits out of test/ under
htest/.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent b8a9c7f2
......@@ -81,13 +81,13 @@
/man/*.gen
/man/footer.man
# test
/test/hail
/test/hbal
/test/hcheck
/test/hinfo
/test/hscan
/test/hspace
# htest
/htest/hail
/htest/hbal
/htest/hcheck
/htest/hinfo
/htest/hscan
/htest/hspace
# tools
/tools/kvm-ifup
......
......@@ -361,7 +361,7 @@ HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
HS_ALL_PROGS = $(HS_PROGS) htest/test htest/hpc-htools htools/hconfd
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
......@@ -1212,7 +1212,7 @@ daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
daemons/ganeti-watcher: MODULE = ganeti.watcher
scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/%,%,$@)
$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst htest/%,%,$@)
$(PYTHON_BOOTSTRAP): Makefile | stamp-directories
test -n "$(MODULE)" || { echo Missing module; exit 1; }
......
......@@ -23,7 +23,8 @@ for hfile in htools; do
fi
done
for hfile in hpc-htools test offline-test.sh cli-tests-defs.sh; do
for hfile in hpc-htools test offline-test.sh cli-tests-defs.sh \
hbal hscan hspace hinfo hcheck hail; do
if [ -e htest/$hfile ]; then
cp -p htest/$hfile $tmpdir/htest/
fi
......
......@@ -34,12 +34,12 @@ echo Using $T as temporary dir
echo -n Generating hspace simulation data for hinfo and hbal...
# this cluster spec should be fine
./test/hspace --simu p,4,8T,64g,16 -S $T/simu-onegroup \
./htest/hspace --simu p,4,8T,64g,16 -S $T/simu-onegroup \
--disk-template drbd -l 8 -v -v -v >/dev/null 2>&1
echo OK
echo -n Generating hinfo and hbal test files for multi-group...
./test/hspace --simu p,4,8T,64g,16 --simu p,4,8T,64g,16 \
./htest/hspace --simu p,4,8T,64g,16 --simu p,4,8T,64g,16 \
-S $T/simu-twogroups --disk-template drbd -l 8 >/dev/null 2>&1
echo OK
......@@ -48,7 +48,7 @@ echo -n Generating test files for rebalancing...
# policy, then we change all nodes from this group to the allocable
# one, and we check for rebalancing
FROOT="$T/simu-rebal-orig"
./test/hspace --simu u,4,8T,64g,16 --simu p,4,8T,64g,16 \
./htest/hspace --simu u,4,8T,64g,16 --simu p,4,8T,64g,16 \
-S $FROOT --disk-template drbd -l 8 >/dev/null 2>&1
for suffix in standard tiered; do
RELOC="$T/simu-rebal-merged.$suffix"
......@@ -75,13 +75,13 @@ echo OK
echo -n Checking file-based RAPI...
mkdir -p $T/hscan
export RAPI_URL="file://$TESTDATA_DIR/rapi"
./test/hscan -d $T/hscan/ -p -v -v $RAPI_URL >/dev/null 2>&1
./htest/hscan -d $T/hscan/ -p -v -v $RAPI_URL >/dev/null 2>&1
# check that we file parsing is correct, i.e. hscan saves correct text
# files, and is idempotent (rapi+text == rapi); more is tested in
# shelltest later
RAPI_TXT="$(ls $T/hscan/*.data|head -n1)"
./test/hinfo -p --print-instances -m $RAPI_URL > $T/hscan/direct.hinfo 2>&1
./test/hinfo -p --print-instances -t $RAPI_TXT > $T/hscan/fromtext.hinfo 2>&1
./htest/hinfo -p --print-instances -m $RAPI_URL > $T/hscan/direct.hinfo 2>&1
./htest/hinfo -p --print-instances -t $RAPI_TXT > $T/hscan/fromtext.hinfo 2>&1
echo OK
echo Running shelltest...
......
### std tests
# test basic parsing
./test/hinfo -v -v -p --print-instances $BACKEND_BAL_STD
./htest/hinfo -v -v -p --print-instances $BACKEND_BAL_STD
>>>= 0
./test/hbal -v -v -v -p --print-instances $BACKEND_BAL_STD -G group-01
./htest/hbal -v -v -v -p --print-instances $BACKEND_BAL_STD -G group-01
>>> !/(Nothing to do, exiting|No solution found)/
>>>2 !/(Nothing to do, exiting|No solution found)/
>>>= 0
# test command output
./test/hbal $BACKEND_BAL_STD -G group-01 -C -S $T/simu-rebal.standard
./htest/hbal $BACKEND_BAL_STD -G group-01 -C -S $T/simu-rebal.standard
>>> /gnt-instance (failover|migrate|replace-disks)/
>>>= 0
# test saving commands
./test/hbal $BACKEND_BAL_STD -G group-01 -C$T/rebal-cmds.standard
./htest/hbal $BACKEND_BAL_STD -G group-01 -C$T/rebal-cmds.standard
>>>= 0
# and now check the file (depends on previous test)
cat $T/rebal-cmds.standard
......@@ -28,32 +28,32 @@ diff -u $T/simu-rebal-merged.standard $T/simu-rebal.standard.original
>>>= 0
# no double rebalance; depends on previous test
./test/hbal -t $T/simu-rebal.standard.balanced -G group-01
./htest/hbal -t $T/simu-rebal.standard.balanced -G group-01
>>> /(Nothing to do, exiting|No solution found)/
>>>= 0
# hcheck sees no reason to rebalance after rebalancing was already done
./test/hcheck -t$T/simu-rebal.standard.balanced --machine-readable
./htest/hcheck -t$T/simu-rebal.standard.balanced --machine-readable
>>> /HCHECK_INIT_CLUSTER_NEED_REBALANCE=0/
>>>= 0
### now tiered tests
# test basic parsing
./test/hinfo -v -v -p --print-instances $BACKEND_BAL_TIER
./htest/hinfo -v -v -p --print-instances $BACKEND_BAL_TIER
>>>= 0
./test/hbal -v -v -v -p --print-instances $BACKEND_BAL_TIER -G group-01
./htest/hbal -v -v -v -p --print-instances $BACKEND_BAL_TIER -G group-01
>>> !/(Nothing to do, exiting|No solution found)/
>>>2 !/(Nothing to do, exiting|No solution found)/
>>>= 0
# test command output
./test/hbal $BACKEND_BAL_TIER -G group-01 -C -S $T/simu-rebal.tiered
./htest/hbal $BACKEND_BAL_TIER -G group-01 -C -S $T/simu-rebal.tiered
>>> /gnt-instance (failover|migrate|replace-disks)/
>>>= 0
# test saving commands
./test/hbal $BACKEND_BAL_TIER -G group-01 -C$T/rebal-cmds.tiered
./htest/hbal $BACKEND_BAL_TIER -G group-01 -C$T/rebal-cmds.tiered
>>>= 0
# and now check the file (depends on previous test)
cat $T/rebal-cmds.tiered
......@@ -67,6 +67,6 @@ diff -u $T/simu-rebal-merged.tiered $T/simu-rebal.tiered.original
>>>= 0
# no double rebalance; depends on previous test
./test/hbal -t $T/simu-rebal.tiered.balanced -G group-01
./htest/hbal -t $T/simu-rebal.tiered.balanced -G group-01
>>> /(Nothing to do, exiting|No solution found)/
>>>= 0
# help/version tests
./test/hail --version
./htest/hail --version
>>>= 0
./test/hail --help
./htest/hail --help
>>>= 0
./test/hbal --version
./htest/hbal --version
>>>= 0
./test/hbal --help
./htest/hbal --help
>>>= 0
./test/hspace --version
./htest/hspace --version
>>>= 0
./test/hspace --help
./htest/hspace --help
>>>= 0
./test/hscan --version
./htest/hscan --version
>>>= 0
./test/hscan --help
./htest/hscan --help
>>>= 0
./test/hinfo --version
./htest/hinfo --version
>>>= 0
./test/hinfo --help
./htest/hinfo --help
>>>= 0
./test/hcheck --version
./htest/hcheck --version
>>>= 0
./test/hcheck --help
./htest/hcheck --help
>>>= 0
echo a > $T/dynu; ./test/hbal -U $T/dynu $BACKEND_DYNU
echo a > $T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
>>>2 /Cannot parse line/
>>>= !0
echo a b c d e f g h > $T/dynu; ./test/hbal -U $T/dynu $BACKEND_DYNU
echo a b c d e f g h > $T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
>>>2 /Cannot parse line/
>>>= !0
echo inst cpu mem dsk net >$T/dynu; ./test/hbal -U $T/dynu $BACKEND_DYNU
echo inst cpu mem dsk net >$T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
>>>2 /cannot parse string '(cpu|mem|dsk|net)'/
>>>= !0
# unknown instances are currently just ignored
echo no-such-inst 2 2 2 2 > $T/dynu; ./test/hbal -U $T/dynu $BACKEND_DYNU
echo no-such-inst 2 2 2 2 > $T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
>>>= 0
# new-0 is the name of the first instance allocated by hspace
echo new-0 2 2 2 2 > $T/dynu; ./test/hbal -U $T/dynu $BACKEND_DYNU
echo new-0 2 2 2 2 > $T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
>>>= 0
./test/hbal $BACKEND_EXCL --exclude-instances no-such-instance
./htest/hbal $BACKEND_EXCL --exclude-instances no-such-instance
>>>2 /Unknown instance/
>>>= !0
./test/hbal $BACKEND_EXCL --select-instances no-such-instances
./htest/hbal $BACKEND_EXCL --select-instances no-such-instances
>>>2 /Unknown instance/
>>>= !0
./test/hbal $BACKEND_EXCL --exclude-instances new-0 --select-instances new-1
./htest/hbal $BACKEND_EXCL --exclude-instances new-0 --select-instances new-1
>>>= 0
# test that on invalid files it can't parse the request
./test/hail /dev/null
./htest/hail /dev/null
>>>2 /Invalid JSON/
>>>= !0
# another invalid example
echo '[]' | ./test/hail -
echo '[]' | ./htest/hail -
>>>2 /Unable to read JSObject/
>>>= !0
# empty dict
echo '{}' | ./test/hail -
echo '{}' | ./htest/hail -
>>>2 /key 'request' not found/
>>>= !0
echo '{"request": 0}' | ./test/hail -
echo '{"request": 0}' | ./htest/hail -
>>>2 /key 'request'/
>>>= !0
./test/hail $TESTDATA_DIR/hail-invalid-reloc.json
./htest/hail $TESTDATA_DIR/hail-invalid-reloc.json
>>>2 /key 'name': Unable to read String/
>>>= !0
# and now start the real tests
./test/hail $TESTDATA_DIR/hail-alloc-drbd.json
./htest/hail $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,.*,"result":\["node2","node1"\]/
>>>= 0
./test/hail $TESTDATA_DIR/hail-reloc-drbd.json
./htest/hail $TESTDATA_DIR/hail-reloc-drbd.json
>>> /"success":true,.*,"result":\["node1"\]/
>>>= 0
./test/hail $TESTDATA_DIR/hail-node-evac.json
./htest/hail $TESTDATA_DIR/hail-node-evac.json
>>> /"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"/
>>>= 0
./test/hail $TESTDATA_DIR/hail-change-group.json
./htest/hail $TESTDATA_DIR/hail-change-group.json
>>> /"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"/
>>>= 0
# check that hail can use the simu backend
./test/hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json
./htest/hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,/
>>>= 0
# check that hail can use the text backend
./test/hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json
./htest/hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,/
>>>= 0
# check that hail can use the simu backend
./test/hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json
./htest/hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,/
>>>= 0
# check that hail pre/post saved state differs after allocation
./test/hail -v -v -v -p $TESTDATA_DIR/hail-alloc-drbd.json -S $T/hail-alloc >/dev/null 2>&1 && ! diff -q $T/hail-alloc.pre-ialloc $T/hail-alloc.post-ialloc
./htest/hail -v -v -v -p $TESTDATA_DIR/hail-alloc-drbd.json -S $T/hail-alloc >/dev/null 2>&1 && ! diff -q $T/hail-alloc.pre-ialloc $T/hail-alloc.post-ialloc
>>> /Files .* and .* differ/
>>>= 0
# check that hail pre/post saved state differs after relocation
./test/hail -v -v -v -p $TESTDATA_DIR/hail-reloc-drbd.json -S $T/hail-reloc >/dev/null 2>&1 && ! diff -q $T/hail-reloc.pre-ialloc $T/hail-reloc.post-ialloc
./htest/hail -v -v -v -p $TESTDATA_DIR/hail-reloc-drbd.json -S $T/hail-reloc >/dev/null 2>&1 && ! diff -q $T/hail-reloc.pre-ialloc $T/hail-reloc.post-ialloc
>>> /Files .* and .* differ/
>>>= 0
# evac tests
./test/hail $T/hail-node-evac.json.primary-only
./htest/hail $T/hail-node-evac.json.primary-only
>>> /"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"/
>>>= 0
./test/hail $T/hail-node-evac.json.secondary-only
./htest/hail $T/hail-node-evac.json.secondary-only
>>> /"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"/
>>>= 0
./test/hail $T/hail-node-evac.json.all
./htest/hail $T/hail-node-evac.json.all
>>> /"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"/
>>>= 0
# test that hspace machine readable output looks correct
./test/hspace --simu p,4,8T,64g,16 --machine-readable --disk-template drbd -l 8
./htest/hspace --simu p,4,8T,64g,16 --machine-readable --disk-template drbd -l 8
>>> /^HTS_OK=1/
>>>= 0
# test again via a file and shell parsing
./test/hspace --simu p,4,8T,64g,16 --machine-readable --disk-template drbd -l 8 > $T/capacity && sh -c ". $T/capacity && test x\$HTS_OK = x1"
./htest/hspace --simu p,4,8T,64g,16 --machine-readable --disk-template drbd -l 8 > $T/capacity && sh -c ". $T/capacity && test x\$HTS_OK = x1"
>>>= 0
# invalid option test
./test/hail --no-such-option
./htest/hail --no-such-option
>>>= 2
# invalid option test
./test/hbal --no-such-option
./htest/hbal --no-such-option
>>>= 2
# invalid option test
./test/hspace --no-such-option
./htest/hspace --no-such-option
>>>= 2
# invalid option test
./test/hscan --no-such-option
./htest/hscan --no-such-option
>>>= 2
# invalid option test
./test/hinfo --no-such-option
./htest/hinfo --no-such-option
>>>= 2
# invalid option test
./test/hcheck --no-such-option
./htest/hcheck --no-such-option
>>>= 2
# extra arguments
./test/hspace unexpected-argument
./htest/hspace unexpected-argument
>>>2
Error: this program doesn't take any arguments.
>>>=1
./test/hbal unexpected-argument
./htest/hbal unexpected-argument
>>>2
Error: this program doesn't take any arguments.
>>>=1
./test/hinfo unexpected-argument
./htest/hinfo unexpected-argument
>>>2
Error: this program doesn't take any arguments.
>>>=1
./test/hcheck unexpected-argument
./htest/hcheck unexpected-argument
>>>2
Error: this program doesn't take any arguments.
>>>=1
# standard multi-group tests
./test/hinfo -v -v -p --print-instances -t$T/simu-twogroups.standard
./htest/hinfo -v -v -p --print-instances -t$T/simu-twogroups.standard
>>>= 0
./test/hbal -t$T/simu-twogroups.standard
./htest/hbal -t$T/simu-twogroups.standard
>>>= !0
# hbal should not be able to balance
./test/hbal -t$T/simu-twogroups.standard
./htest/hbal -t$T/simu-twogroups.standard
>>>2 /Found multiple node groups/
>>>= !0
# but hbal should be able to balance one node group
./test/hbal -t$T/simu-twogroups.standard -G group-01
./htest/hbal -t$T/simu-twogroups.standard -G group-01
>>>= 0
# and it should not find an invalid group
./test/hbal -t$T/simu-twogroups.standard -G no-such-group
./htest/hbal -t$T/simu-twogroups.standard -G no-such-group
>>>= !0
# tiered allocs multi-group tests
./test/hinfo -v -v -p --print-instances -t$T/simu-twogroups.tiered
./htest/hinfo -v -v -p --print-instances -t$T/simu-twogroups.tiered
>>>= 0
./test/hbal -t$T/simu-twogroups.tiered
./htest/hbal -t$T/simu-twogroups.tiered
>>>= !0
# hbal should not be able to balance
./test/hbal -t$T/simu-twogroups.tiered
./htest/hbal -t$T/simu-twogroups.tiered
>>>2 /Found multiple node groups/
>>>= !0
# but hbal should be able to balance one node group
./test/hbal -t$T/simu-twogroups.tiered -G group-01
./htest/hbal -t$T/simu-twogroups.tiered -G group-01
>>>= 0
# and it should not find an invalid group
./test/hbal -t$T/simu-twogroups.tiered -G no-such-group
./htest/hbal -t$T/simu-twogroups.tiered -G no-such-group
>>>= !0
# hcheck should be able to run with multiple groups
./test/hcheck -t$T/simu-twogroups.tiered --machine-readable
./htest/hcheck -t$T/simu-twogroups.tiered --machine-readable
>>> /HCHECK_OK=1/
>>>= 0
# hcheck should be able to improve a group with split instances
./test/hbal -t $TESTDATA_DIR/hbal-split-insts.data -G group-01 -O node-01-001
./htest/hbal -t $TESTDATA_DIR/hbal-split-insts.data -G group-01 -O node-01-001
>>> /Cluster score improved from .* to .*/
>>>= 0
# hail no input file
./test/hail
./htest/hail
>>>= 1
# hbal no backend
./test/hbal
./htest/hbal
>>>= 1
# hspace no backend
./test/hspace
./htest/hspace
>>>= 1
# hinfo no backend
./test/hinfo
./htest/hinfo
>>>= 1
# hbal multiple backends
./test/hbal -t /dev/null -m localhost
./htest/hbal -t /dev/null -m localhost
>>>2
Error: Only one of the rapi, luxi, and data files options should be given.
>>>= 1
# test loading data via RAPI
./test/hinfo -v -v -p --print-instances -m $RAPI_URL
./htest/hinfo -v -v -p --print-instances -m $RAPI_URL
>>>= 0
./test/hbal -v -v -p --print-instances -m $RAPI_URL
./htest/hbal -v -v -p --print-instances -m $RAPI_URL
>>>= 0
# this compares generated files from hscan
......
# standard single-group tests
./test/hinfo -v -v -p --print-instances -t$T/simu-onegroup.standard
./htest/hinfo -v -v -p --print-instances -t$T/simu-onegroup.standard
>>>= 0
./test/hbal -v -v -p --print-instances -t$T/simu-onegroup.standard
./htest/hbal -v -v -p --print-instances -t$T/simu-onegroup.standard
>>>= 0
# hbal should not be able to balance
./test/hbal -t$T/simu-onegroup.standard
./htest/hbal -t$T/simu-onegroup.standard
>>> /(Nothing to do, exiting|No solution found)/
>>>= 0
# tiered single-group tests
./test/hinfo -v -v -p --print-instances -t$T/simu-onegroup.tiered
./htest/hinfo -v -v -p --print-instances -t$T/simu-onegroup.tiered
>>>= 0
./test/hbal -v -v -p --print-instances -t$T/simu-onegroup.tiered
./htest/hbal -v -v -p --print-instances -t$T/simu-onegroup.tiered
>>>= 0
# hbal should not be able to balance
./test/hbal -t$T/simu-onegroup.tiered
./htest/hbal -t$T/simu-onegroup.tiered
>>> /(Nothing to do, exiting|No solution found)/
>>>= 0
# hcheck should not find reason to rebalance
./test/hcheck -t$T/simu-onegroup.tiered --machine-readable
./htest/hcheck -t$T/simu-onegroup.tiered --machine-readable
>>> /HCHECK_INIT_CLUSTER_NEED_REBALANCE=0/
>>>= 0
# missing resources test
./test/hbal -t $TESTDATA_DIR/missing-resources.data
./htest/hbal -t $TESTDATA_DIR/missing-resources.data
>>>2 /node node2 is missing .* ram and .* disk/
>>>= 0
./test/hinfo -t $TESTDATA_DIR/missing-resources.data
./htest/hinfo -t $TESTDATA_DIR/missing-resources.data
>>>2 /node node2 is missing .* ram and .* disk/
>>>= 0
# common suffix test
./test/hbal -t $TESTDATA_DIR/common-suffix.data -v -v
./htest/hbal -t $TESTDATA_DIR/common-suffix.data -v -v
>>>/Stripping common suffix of '\.example\.com' from names/
>>>= 0
./test/hinfo -t $TESTDATA_DIR/common-suffix.data -v -v
./htest/hinfo -t $TESTDATA_DIR/common-suffix.data -v -v
>>>/Stripping common suffix of '\.example\.com' from names/
>>>= 0
# invalid node test
./test/hbal -t $TESTDATA_DIR/invalid-node.data
./htest/hbal -t $TESTDATA_DIR/invalid-node.data
>>>2 /Unknown node '.*' for instance new-0/
>>>= !0
./test/hspace -t $TESTDATA_DIR/invalid-node.data
./htest/hspace -t $TESTDATA_DIR/invalid-node.data
>>>2 /Unknown node '.*' for instance new-0/
>>>= !0
./test/hinfo -t $TESTDATA_DIR/invalid-node.data
./htest/hinfo -t $TESTDATA_DIR/invalid-node.data
>>>2 /Unknown node '.*' for instance new-0/
>>>= !0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment