Commit 83846468 authored by Iustin Pop's avatar Iustin Pop

Move htest/ files under the test/ tree

htest/data becomes test/data/htools (basically reverting commit
8feabc89), and htest/* becomes test/hs/*.

Most changes beside the rename are trivial s/…/…, with the exception
of autotools/run-in-tempdir, which needed some more changes now that
test/ is not just Python files:

- test/py is still being copied
- test/hs moves from individual symlinks to entire dir symlink
- test/data is symlinked in its entirety

Checked with make distcheck, pep8 and pylint, so at least VPATH builds
are OK.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 90066780
:set -isrc -ihtest
:set -isrc -itest/hs
......@@ -87,17 +87,17 @@
/man/*.gen
/man/footer.man
# htest
/htest/hail
/htest/hbal
/htest/hcheck
/htest/hinfo
/htest/hroller
/htest/hscan
/htest/hspace
/htest/hpc-htools
/htest/hpc-mon-collector
/htest/test
# test/hs
/test/hs/hail
/test/hs/hbal
/test/hs/hcheck
/test/hs/hinfo
/test/hs/hroller
/test/hs/hscan
/test/hs/hspace
/test/hs/hpc-htools
/test/hs/hpc-mon-collector
/test/hs/test
# tools
/tools/kvm-ifup
......@@ -129,4 +129,4 @@
# automatically-built Haskell files
/src/Ganeti/Constants.hs
/src/Ganeti/Version.hs
/htest/Test/Ganeti/TestImports.hs
/test/hs/Test/Ganeti/TestImports.hs
This diff is collapsed.
......@@ -8,26 +8,25 @@ set -e
tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
trap "rm -rf $tmpdir" EXIT
mkdir $tmpdir/doc
# fully copy items
cp -r autotools daemons scripts lib tools qa $tmpdir
cp -r autotools daemons scripts lib tools test qa $tmpdir
mkdir $tmpdir/doc
ln -s $PWD/doc/examples $tmpdir/doc
mkdir $tmpdir/test/
cp -r test/py $tmpdir/test/py
ln -s $PWD/test/data $tmpdir/test
ln -s $PWD/test/hs $tmpdir/test
mv $tmpdir/lib $tmpdir/ganeti
ln -T -s $tmpdir/ganeti $tmpdir/lib
mkdir -p $tmpdir/src $tmpdir/htest
mkdir -p $tmpdir/src $tmpdir/test/hs
for hfile in htools ganeti-confd mon-collector; do
if [ -e src/$hfile ]; then
ln -s $PWD/src/$hfile $tmpdir/src/
fi
done
for hfile in hpc-htools test offline-test.sh cli-tests-defs.sh \
hbal hscan hspace hinfo hcheck hail hroller hpc-mon-collector; do
if [ -e htest/$hfile ]; then
ln -s $PWD/htest/$hfile $tmpdir/htest/
fi
done
cd $tmpdir && GANETI_TEMP_DIR="$tmpdir" "$@"
......@@ -180,7 +180,7 @@ For Python tests::
For Haskell tests::
$ make htest/test && ./htest/test -t %pattern%
$ make test/hs/test && ./test/hs/test -t %pattern%
Where ``pattern`` can be a simple test pattern (e.g. ``comma``,
matching any test whose name contains ``comma``), a test pattern
......
../src/htools.hs
\ No newline at end of file
../src/mon-collector.hs
\ No newline at end of file
# help/version tests
./htest/hail --version
>>>= 0
./htest/hail --help
>>>= 0
./htest/hail --help-completion
>>>= 0
./htest/hbal --version
>>>= 0
./htest/hbal --help
>>>= 0
./htest/hbal --help-completion
>>>= 0
./htest/hspace --version
>>>= 0
./htest/hspace --help
>>>= 0
./htest/hspace --help-completion
>>>= 0
./htest/hscan --version
>>>= 0
./htest/hscan --help
>>>= 0
./htest/hscan --help-completion
>>>= 0
./htest/hinfo --version
>>>= 0
./htest/hinfo --help
>>>= 0
./htest/hinfo --help-completion
>>>= 0
./htest/hcheck --version
>>>= 0
./htest/hcheck --help
>>>= 0
./htest/hcheck --help-completion
>>>= 0
./htest/hroller --version
>>>= 0
./htest/hroller --help
>>>= 0
./htest/hroller --help-completion
>>>= 0
......@@ -268,7 +268,7 @@ prop_Config_serialisation =
-- | Custom HUnit test to check the correspondence between Haskell-generated
-- networks and their Python decoded, validated and re-encoded version.
-- For the technical background of this unit test, check the documentation
-- of "case_py_compat_types" of htest/Test/Ganeti/Opcodes.hs
-- of "case_py_compat_types" of test/hs/Test/Ganeti/Opcodes.hs
case_py_compat_networks :: HUnit.Assertion
case_py_compat_networks = do
let num_networks = 500::Int
......
......@@ -298,5 +298,5 @@ readPythonTestData filename = do
-- | Returns the content of the specified haskell test data file.
readTestData :: String -> IO String
readTestData filename = do
name <- testDataFilename "/htest/data/" filename
name <- testDataFilename "/test/data/htools/" filename
readFile name
......@@ -19,9 +19,9 @@
# This is an shell testing configuration fragment.
HBINARY=${HBINARY:-./htest/hpc-htools}
HBINARY=${HBINARY:-./test/hs/hpc-htools}
export TESTDATA_DIR=${TOP_SRCDIR:-.}/htest/data
export TESTDATA_DIR=${TOP_SRCDIR:-.}/test/data/htools
export PYTESTDATA_DIR=${TOP_SRCDIR:-.}/test/data
hbal() {
......
../../src/htools.hs
\ No newline at end of file
../../src/mon-collector.hs
\ No newline at end of file
......@@ -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
./htest/hspace --simu p,4,8T,64g,16 -S $T/simu-onegroup \
./test/hs/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...
./htest/hspace --simu p,4,8T,64g,16 --simu p,4,8T,64g,16 \
./test/hs/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"
./htest/hspace --simu u,4,8T,64g,16 --simu p,4,8T,64g,16 \
./test/hs/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,19 +75,19 @@ echo OK
echo -n Checking file-based RAPI...
mkdir -p $T/hscan
export RAPI_URL="file://$TESTDATA_DIR/rapi"
./htest/hscan -d $T/hscan/ -p -v -v $RAPI_URL >/dev/null 2>&1
./test/hs/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)"
./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
./test/hs/hinfo -p --print-instances -m $RAPI_URL > $T/hscan/direct.hinfo 2>&1
./test/hs/hinfo -p --print-instances -t $RAPI_TXT > $T/hscan/fromtext.hinfo 2>&1
echo OK
echo Running shelltest...
shelltest $SHELLTESTARGS \
${TOP_SRCDIR:-.}/htest/shelltests/htools-*.test \
${TOP_SRCDIR:-.}/test/hs/shelltests/htools-*.test \
-- --hide-successes
echo All OK
### std tests
# test basic parsing
./htest/hinfo -v -v -p --print-instances $BACKEND_BAL_STD
./test/hs/hinfo -v -v -p --print-instances $BACKEND_BAL_STD
>>>= 0
./htest/hbal -v -v -v -p --print-instances $BACKEND_BAL_STD -G group-01
./test/hs/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
./htest/hbal $BACKEND_BAL_STD -G group-01 -C -S $T/simu-rebal.standard
./test/hs/hbal $BACKEND_BAL_STD -G group-01 -C -S $T/simu-rebal.standard
>>> /gnt-instance (failover|migrate|replace-disks)/
>>>= 0
# test that hbal won't execute rebalances when using the text backend
./htest/hbal $BACKEND_BAL_STD -G group-01 -X
./test/hs/hbal $BACKEND_BAL_STD -G group-01 -X
>>>2
Error: hbal: Execution of commands possible only on LUXI
>>>= !0
# test that hbal won't execute any moves if we request an absurdly-high
# minimum-improvement
./htest/hbal $BACKEND_BAL_STD -G group-01 -C --min-gain 10000 --min-gain-limit 10000
./test/hs/hbal $BACKEND_BAL_STD -G group-01 -C --min-gain 10000 --min-gain-limit 10000
>>>/No solution found/
>>>= 0
# test saving commands
./htest/hbal $BACKEND_BAL_STD -G group-01 -C$T/rebal-cmds.standard
./test/hs/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
......@@ -40,32 +40,32 @@ diff -u $T/simu-rebal-merged.standard $T/simu-rebal.standard.original
>>>= 0
# no double rebalance; depends on previous test
./htest/hbal -t $T/simu-rebal.standard.balanced -G group-01
./test/hs/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
./htest/hcheck -t$T/simu-rebal.standard.balanced --machine-readable
./test/hs/hcheck -t$T/simu-rebal.standard.balanced --machine-readable
>>> /HCHECK_INIT_CLUSTER_NEED_REBALANCE=0/
>>>= 0
### now tiered tests
# test basic parsing
./htest/hinfo -v -v -p --print-instances $BACKEND_BAL_TIER
./test/hs/hinfo -v -v -p --print-instances $BACKEND_BAL_TIER
>>>= 0
./htest/hbal -v -v -v -p --print-instances $BACKEND_BAL_TIER -G group-01
./test/hs/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
./htest/hbal $BACKEND_BAL_TIER -G group-01 -C -S $T/simu-rebal.tiered
./test/hs/hbal $BACKEND_BAL_TIER -G group-01 -C -S $T/simu-rebal.tiered
>>> /gnt-instance (failover|migrate|replace-disks)/
>>>= 0
# test saving commands
./htest/hbal $BACKEND_BAL_TIER -G group-01 -C$T/rebal-cmds.tiered
./test/hs/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
......@@ -79,45 +79,45 @@ diff -u $T/simu-rebal-merged.tiered $T/simu-rebal.tiered.original
>>>= 0
# no double rebalance; depends on previous test
./htest/hbal -t $T/simu-rebal.tiered.balanced -G group-01
./test/hs/hbal -t $T/simu-rebal.tiered.balanced -G group-01
>>> /(Nothing to do, exiting|No solution found)/
>>>= 0
### now some other custom tests
# n+1 bad instances are reported as such
./htest/hbal -t$TESTDATA_DIR/n1-failure.data -G group-01
./test/hs/hbal -t$TESTDATA_DIR/n1-failure.data -G group-01
>>>/Initial check done: 4 bad nodes, 8 bad instances./
>>>=0
# same test again, different message check (shelltest can't test multiple
# messages via regexp
./htest/hbal -t$TESTDATA_DIR/n1-failure.data -G group-01
./test/hs/hbal -t$TESTDATA_DIR/n1-failure.data -G group-01
>>>/Cluster is not N\+1 happy, continuing but no guarantee that the cluster will end N\+1 happy./
>>>2
>>>=0
# and hcheck should report this as needs rebalancing
./htest/hcheck -t$TESTDATA_DIR/n1-failure.data
./test/hs/hcheck -t$TESTDATA_DIR/n1-failure.data
>>>/Cluster needs rebalancing./
>>>= 1
# ... unless we request no-simulation mode
./htest/hcheck -t$TESTDATA_DIR/n1-failure.data --no-simulation
./test/hs/hcheck -t$TESTDATA_DIR/n1-failure.data --no-simulation
>>>/Running in no-simulation mode./
>>>= 0
# and a clean cluster should be reported as such
./htest/hcheck $BACKEND_BAL_STD
./test/hs/hcheck $BACKEND_BAL_STD
>>>/No need to rebalance cluster, no problems found./
>>>= 0
# ... and even one with non-zero score
./htest/hcheck -t $TESTDATA_DIR/clean-nonzero-score.data
./test/hs/hcheck -t $TESTDATA_DIR/clean-nonzero-score.data
>>>/No need to rebalance cluster, no problems found./
>>>= 0
# hbal should work on empty groups as well
./htest/hbal -t$TESTDATA_DIR/n1-failure.data -G group-02
./test/hs/hbal -t$TESTDATA_DIR/n1-failure.data -G group-02
>>>/Group size 0 nodes, 0 instances/
>>>= 0
# help/version tests
./test/hs/hail --version
>>>= 0
./test/hs/hail --help
>>>= 0
./test/hs/hail --help-completion
>>>= 0
./test/hs/hbal --version
>>>= 0
./test/hs/hbal --help
>>>= 0
./test/hs/hbal --help-completion
>>>= 0
./test/hs/hspace --version
>>>= 0
./test/hs/hspace --help
>>>= 0
./test/hs/hspace --help-completion
>>>= 0
./test/hs/hscan --version
>>>= 0
./test/hs/hscan --help
>>>= 0
./test/hs/hscan --help-completion
>>>= 0
./test/hs/hinfo --version
>>>= 0
./test/hs/hinfo --help
>>>= 0
./test/hs/hinfo --help-completion
>>>= 0
./test/hs/hcheck --version
>>>= 0
./test/hs/hcheck --help
>>>= 0
./test/hs/hcheck --help-completion
>>>= 0
./test/hs/hroller --version
>>>= 0
./test/hs/hroller --help
>>>= 0
./test/hs/hroller --help-completion
>>>= 0
echo a > $T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
echo a > $T/dynu; ./test/hs/hbal -U $T/dynu $BACKEND_DYNU
>>>2 /Cannot parse line/
>>>= !0
echo a b c d e f g h > $T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
echo a b c d e f g h > $T/dynu; ./test/hs/hbal -U $T/dynu $BACKEND_DYNU
>>>2 /Cannot parse line/
>>>= !0
echo inst cpu mem dsk net >$T/dynu; ./htest/hbal -U $T/dynu $BACKEND_DYNU
echo inst cpu mem dsk net >$T/dynu; ./test/hs/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; ./htest/hbal -U $T/dynu $BACKEND_DYNU
echo no-such-inst 2 2 2 2 > $T/dynu; ./test/hs/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; ./htest/hbal -U $T/dynu $BACKEND_DYNU
echo new-0 2 2 2 2 > $T/dynu; ./test/hs/hbal -U $T/dynu $BACKEND_DYNU
>>>= 0
./htest/hbal $BACKEND_EXCL --exclude-instances no-such-instance
./test/hs/hbal $BACKEND_EXCL --exclude-instances no-such-instance
>>>2 /Unknown instance/
>>>= !0
./htest/hbal $BACKEND_EXCL --select-instances no-such-instances
./test/hs/hbal $BACKEND_EXCL --select-instances no-such-instances
>>>2 /Unknown instance/
>>>= !0
./htest/hbal $BACKEND_EXCL --exclude-instances new-0 --select-instances new-1
./test/hs/hbal $BACKEND_EXCL --exclude-instances new-0 --select-instances new-1
>>>= 0
# Test exclusion tags too (both from the command line and cluster tags).
./htest/hbal -t $TESTDATA_DIR/hbal-excl-tags.data --exclusion-tags test
./test/hs/hbal -t $TESTDATA_DIR/hbal-excl-tags.data --exclusion-tags test
>>> /Cluster score improved/
>>>= 0
# test that on invalid files it can't parse the request
./htest/hail /dev/null
./test/hs/hail /dev/null
>>>2 /Invalid JSON/
>>>= !0
# another invalid example
echo '[]' | ./htest/hail -
echo '[]' | ./test/hs/hail -
>>>2 /Unable to read JSObject/
>>>= !0
# empty dict
echo '{}' | ./htest/hail -
echo '{}' | ./test/hs/hail -
>>>2 /key 'request' not found/
>>>= !0
echo '{"request": 0}' | ./htest/hail -
echo '{"request": 0}' | ./test/hs/hail -
>>>2 /key 'request'/
>>>= !0
./htest/hail $TESTDATA_DIR/hail-invalid-reloc.json
./test/hs/hail $TESTDATA_DIR/hail-invalid-reloc.json
>>>2 /key 'name': Unable to read String/
>>>= !0
# and now start the real tests
./htest/hail $TESTDATA_DIR/hail-alloc-drbd.json
./test/hs/hail $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,.*,"result":\["node2","node1"\]/
>>>= 0
./htest/hail $TESTDATA_DIR/hail-reloc-drbd.json
./test/hs/hail $TESTDATA_DIR/hail-reloc-drbd.json
>>> /"success":true,.*,"result":\["node1"\]/
>>>= 0
./htest/hail $TESTDATA_DIR/hail-node-evac.json
./test/hs/hail $TESTDATA_DIR/hail-node-evac.json
>>> /"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"/
>>>= 0
./htest/hail $TESTDATA_DIR/hail-change-group.json
./test/hs/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
./htest/hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json
./test/hs/hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,/
>>>= 0
# check that hail can use the text backend
./htest/hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json
./test/hs/hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,/
>>>= 0
# check that hail can use the simu backend
./htest/hail -t $T/simu-rebal-merged.standard $TESTDATA_DIR/hail-alloc-drbd.json
./test/hs/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
./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
./test/hs/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
./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