Add trivial tests for gnt-* cli
authorIustin Pop <iustin@google.com>
Fri, 23 Mar 2012 16:32:57 +0000 (17:32 +0100)
committerIustin Pop <iustin@google.com>
Mon, 26 Mar 2012 08:30:04 +0000 (10:30 +0200)
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
htools/offline-test.sh
test/cli-test.bash [new file with mode: 0755]
test/ganeti-cli.test [new file with mode: 0644]
test/gnt-cli.test [new file with mode: 0644]

index 1ff35d0..c0d8129 100644 (file)
@@ -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) \
index 51ff12c..cd62c0c 100755 (executable)
@@ -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 (executable)
index 0000000..9c1f1fa
--- /dev/null
@@ -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 (file)
index 0000000..054a618
--- /dev/null
@@ -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 (file)
index 0000000..1c1f936
--- /dev/null
@@ -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