From 30f2802f21df7989e00aa82a37daecb3c7c3ecff Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 23 Mar 2012 17:32:57 +0100 Subject: [PATCH] Add trivial tests for gnt-* cli While testing some other stuff, I realised that the gnt-* commands could be broken (as in, the script fails with syntax errors), but make check doesn't detect it. Since we have shelltest, we can now add trivial tests for this case. One downside is that starting the scripts seems to be much slower than the htools binaries, so we can't add as many tests. The other downside is that shelltest is now required for all development work, but I think this is a small disadvantage compared to the increased testing possibilities. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- Makefile.am | 10 ++++-- htools/offline-test.sh | 4 ++- test/cli-test.bash | 8 +++++ test/ganeti-cli.test | 36 +++++++++++++++++++++ test/gnt-cli.test | 72 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 3 deletions(-) create mode 100755 test/cli-test.bash create mode 100644 test/ganeti-cli.test create mode 100644 test/gnt-cli.test diff --git a/Makefile.am b/Makefile.am index 1ff35d0b7..c0d812971 100644 --- a/Makefile.am +++ b/Makefile.am @@ -768,6 +768,8 @@ TEST_FILES = \ test/data/vgs-missing-pvs-2.02.02.txt \ test/data/vgs-missing-pvs-2.02.66.txt \ test/import-export_unittest-helper \ + test/gnt-cli.test \ + test/ganeti-cli.test \ test/htools-balancing.test \ test/htools-basic.test \ test/htools-dynutil.test \ @@ -857,6 +859,7 @@ dist_TESTS = \ test/daemon-util_unittest.bash \ test/ganeti-cleaner_unittest.bash \ test/import-export_unittest.bash \ + test/cli-test.bash \ $(python_tests) nodist_TESTS = @@ -872,8 +875,10 @@ TESTS = $(dist_TESTS) $(nodist_TESTS) # Environment for all tests PLAIN_TESTS_ENVIRONMENT = \ - PYTHONPATH=. TOP_SRCDIR=$(abs_top_srcdir) PYTHON=$(PYTHON) \ - FAKEROOT=$(FAKEROOT_PATH) $(RUN_IN_TEMPDIR) + PYTHONPATH=. \ + TOP_SRCDIR=$(abs_top_srcdir) TOP_BUILDDIR=$(abs_top_builddir) \ + PYTHON=$(PYTHON) FAKEROOT=$(FAKEROOT_PATH) \ + $(RUN_IN_TEMPDIR) # Environment for tests run by automake TESTS_ENVIRONMENT = \ @@ -906,6 +911,7 @@ srclink_files = \ test/daemon-util_unittest.bash \ test/ganeti-cleaner_unittest.bash \ test/import-export_unittest.bash \ + test/cli-test.bash \ htools/offline-test.sh \ htools/cli-tests-defs.sh \ $(all_python_code) \ diff --git a/htools/offline-test.sh b/htools/offline-test.sh index 51ff12c9e..cd62c0c83 100755 --- a/htools/offline-test.sh +++ b/htools/offline-test.sh @@ -86,6 +86,8 @@ echo OK echo Running shelltest... -shelltest $SHELLTESTARGS ${TOP_SRCDIR:-.}/test/ -- --hide-successes +shelltest $SHELLTESTARGS \ + ${TOP_SRCDIR:-.}/test/htools-*.test \ + -- --hide-successes echo All OK diff --git a/test/cli-test.bash b/test/cli-test.bash new file mode 100755 index 000000000..9c1f1fab0 --- /dev/null +++ b/test/cli-test.bash @@ -0,0 +1,8 @@ +#!/bin/bash + +export SCRIPTS=${TOP_BUILDDIR:-.}/scripts +export DAEMONS=${TOP_BUILDDIR:-.}/daemons + +shelltest $SHELLTESTARGS \ + ${TOP_SRCDIR:-.}/test/gnt-*.test \ + -- --hide-successes diff --git a/test/ganeti-cli.test b/test/ganeti-cli.test new file mode 100644 index 000000000..054a6189b --- /dev/null +++ b/test/ganeti-cli.test @@ -0,0 +1,36 @@ +# test the various gnt-commands for common options +$SCRIPTS/ganeti-masterd --help +>>>/Usage:/ +>>>2 +>>>= 0 +$SCRIPTS/ganeti-masterd --version +>>>/^ganeti-/ +>>>2 +>>>= 0 + +$SCRIPTS/ganeti-noded --help +>>>/Usage:/ +>>>2 +>>>= 0 +$SCRIPTS/ganeti-noded --version +>>>/^ganeti-/ +>>>2 +>>>= 0 + +$SCRIPTS/ganeti-rapi --help +>>>/Usage:/ +>>>2 +>>>= 0 +$SCRIPTS/ganeti-rapi --version +>>>/^ganeti-/ +>>>2 +>>>= 0 + +$SCRIPTS/ganeti-watcher --help +>>>/Usage:/ +>>>2 +>>>= 0 +$SCRIPTS/ganeti-watcher --version +>>>/^ganeti-/ +>>>2 +>>>= 0 diff --git a/test/gnt-cli.test b/test/gnt-cli.test new file mode 100644 index 000000000..1c1f936e3 --- /dev/null +++ b/test/gnt-cli.test @@ -0,0 +1,72 @@ +# test the various gnt-commands for common options +$SCRIPTS/gnt-node --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-node --version +>>>/^gnt-/ +>>>2 +>>>= 0 + +$SCRIPTS/gnt-instance --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-instance --version +>>>/^gnt-instance/ +>>>2 +>>>= 0 + +$SCRIPTS/gnt-os --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-os --version +>>>/^gnt-/ +>>>2 +>>>= 0 + +$SCRIPTS/gnt-group --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-group --version +>>>/^gnt-/ +>>>2 +>>>= 0 + +$SCRIPTS/gnt-job --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-job --version +>>>/^gnt-/ +>>>2 +>>>= 0 + +$SCRIPTS/gnt-cluster --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-cluster --version +>>>/^gnt-/ +>>>2 +>>>= 0 + +$SCRIPTS/gnt-backup --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-backup --version +>>>/^gnt-/ +>>>2 +>>>= 0 + +$SCRIPTS/gnt-debug --help +>>>/Usage:/ +>>>2 +>>>= 1 +$SCRIPTS/gnt-debug --version +>>>/^gnt-/ +>>>2 +>>>= 0 -- GitLab