ctdb-tests: Add a test to ensure that CTDB works with no eventscripts
authorMartin Schwenke <martin@meltin.net>
Mon, 29 Aug 2016 06:52:45 +0000 (16:52 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 1 Sep 2016 15:15:05 +0000 (17:15 +0200)
This only tests something on local daemons, since the configuration
can't be easily manipulated on a real cluster.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12180

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Sep  1 17:15:06 CEST 2016 on sn-devel-144

ctdb/tests/simple/28_zero_eventscripts.sh [new file with mode: 0755]

diff --git a/ctdb/tests/simple/28_zero_eventscripts.sh b/ctdb/tests/simple/28_zero_eventscripts.sh
new file mode 100755 (executable)
index 0000000..7c03ae4
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+test_info()
+{
+    cat <<EOF
+Check that CTDB operated correctly if there are 0 event scripts
+
+This test only does anything with local daemons.  On a real cluster it
+has no way of updating configuration.
+EOF
+}
+
+. "${TEST_SCRIPTS_DIR}/integration.bash"
+
+ctdb_test_init "$@"
+
+set -e
+
+cluster_is_healthy
+
+if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+       echo "SKIPPING this test - only runs against local daemons"
+       exit 0
+fi
+
+# Reset configuration
+ctdb_restart_when_done
+
+daemons_stop
+
+echo "Starting CTDB with an empty eventscript directory..."
+empty_dir=$(mktemp -d --tmpdir="$TEST_VAR_DIR")
+ctdb_test_exit_hook_add "rmdir $empty_dir"
+CTDB_EVENT_SCRIPT_DIR="$empty_dir" daemons_start
+
+wait_until_ready
+
+# If this fails to find processes then the tests fails, so look at
+# full command-line so this will work with valgrind.  Note that the
+# output could be generated with pgrep's -a option but it doesn't
+# exist in older versions.
+ps -p $(pgrep -f '\<ctdbd\>' | xargs | sed -e 's| |,|g') -o args ww
+
+echo
+echo "Good, that seems to work!"