diff options
author | Martin Schwenke <martin@meltin.net> | 2015-02-15 14:39:51 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2015-02-18 05:34:06 +0100 |
commit | 2c7c35377e5452e37925b970253b70875a8d7470 (patch) | |
tree | 2d66260d3b9aa6af14dcf9d42b9eea8ad4544c0a /ctdb/tests | |
parent | 39686f45056d942de5ebe3263a533a99ca17c79e (diff) | |
download | samba-2c7c35377e5452e37925b970253b70875a8d7470.tar.gz samba-2c7c35377e5452e37925b970253b70875a8d7470.tar.xz samba-2c7c35377e5452e37925b970253b70875a8d7470.zip |
ctdb-tests: New tests for 00.ctdb "setup" event - set tunables from config
Unit test infrastructure tweaks to support.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests')
-rwxr-xr-x | ctdb/tests/eventscripts/00.ctdb.setup.001.sh | 11 | ||||
-rwxr-xr-x | ctdb/tests/eventscripts/00.ctdb.setup.002.sh | 19 | ||||
-rwxr-xr-x | ctdb/tests/eventscripts/00.ctdb.setup.003.sh | 20 | ||||
-rwxr-xr-x | ctdb/tests/eventscripts/00.ctdb.setup.004.sh | 19 | ||||
-rw-r--r-- | ctdb/tests/eventscripts/etc/sysconfig/ctdb | 4 | ||||
-rw-r--r-- | ctdb/tests/eventscripts/scripts/local.sh | 11 | ||||
-rwxr-xr-x | ctdb/tests/eventscripts/stubs/ctdb | 25 |
7 files changed, 109 insertions, 0 deletions
diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.001.sh b/ctdb/tests/eventscripts/00.ctdb.setup.001.sh new file mode 100755 index 0000000000..1e094f8ba2 --- /dev/null +++ b/ctdb/tests/eventscripts/00.ctdb.setup.001.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "setup, no tunables in config" + +setup_ctdb + +ok_null + +simple_test diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.002.sh b/ctdb/tests/eventscripts/00.ctdb.setup.002.sh new file mode 100755 index 0000000000..c62b83cbce --- /dev/null +++ b/ctdb/tests/eventscripts/00.ctdb.setup.002.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "setup, known tunables in config" + +setup_ctdb + +setup_config <<EOF +CTDB_SET_MonitorInterval=5 +CTDB_SET_TDBMutexEnabled=0 +EOF + +required_result 0 <<EOF +Set MonitorInterval to 5 +Set TDBMutexEnabled to 0 +EOF + +simple_test diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.003.sh b/ctdb/tests/eventscripts/00.ctdb.setup.003.sh new file mode 100755 index 0000000000..46bbc990f9 --- /dev/null +++ b/ctdb/tests/eventscripts/00.ctdb.setup.003.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "setup, known and unknown tunables in config" + +setup_ctdb + +setup_config <<EOF +CTDB_SET_MonitorInterval=5 +CTDB_SET_UnknownMagic=0 +EOF + +required_result 1 <<EOF +Set MonitorInterval to 5 +Unable to set tunable variable 'UnknownMagic' +Failed to set CTDB tunables +EOF + +simple_test diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.004.sh b/ctdb/tests/eventscripts/00.ctdb.setup.004.sh new file mode 100755 index 0000000000..6c3fbd533c --- /dev/null +++ b/ctdb/tests/eventscripts/00.ctdb.setup.004.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "setup, known and obsolete tunables in config" + +setup_ctdb + +setup_config <<EOF +CTDB_SET_MonitorInterval=5 +CTDB_SET_EventScriptUnhealthyOnTimeout=0 +EOF + +required_result 0 <<EOF +Set EventScriptUnhealthyOnTimeout to 0 +Set MonitorInterval to 5 +EOF + +simple_test diff --git a/ctdb/tests/eventscripts/etc/sysconfig/ctdb b/ctdb/tests/eventscripts/etc/sysconfig/ctdb index 4584c112fd..fe0436d6f5 100644 --- a/ctdb/tests/eventscripts/etc/sysconfig/ctdb +++ b/ctdb/tests/eventscripts/etc/sysconfig/ctdb @@ -1,2 +1,6 @@ CTDB_RECOVERY_LOCK="/some/place/on/shared/storage" CTDB_DEBUGLEVEL=ERR + +if [ -n "$FAKE_CTDB_EXTRA_CONFIG" -a -r "$FAKE_CTDB_EXTRA_CONFIG" ] ; then + . "$FAKE_CTDB_EXTRA_CONFIG" +fi diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh index 23a64815c9..f044ef8ffb 100644 --- a/ctdb/tests/eventscripts/scripts/local.sh +++ b/ctdb/tests/eventscripts/scripts/local.sh @@ -296,6 +296,9 @@ setup_ctdb () export FAKE_CTDB_STATE="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-ctdb" + export FAKE_CTDB_EXTRA_CONFIG="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-config.sh" + rm -f "$FAKE_CTDB_EXTRA_CONFIG" + export FAKE_CTDB_IFACES_DOWN="$FAKE_CTDB_STATE/ifaces-down" mkdir -p "$FAKE_CTDB_IFACES_DOWN" rm -f "$FAKE_CTDB_IFACES_DOWN"/* @@ -305,6 +308,14 @@ setup_ctdb () rm -f "$FAKE_CTDB_SCRIPTSTATUS"/* export CTDB_PARTIALLY_ONLINE_INTERFACES + + export FAKE_CTDB_TUNABLES_OK="MonitorInterval TDBMutexEnabled DatabaseHashSize" + export FAKE_CTDB_TUNABLES_OBSOLETE="EventScriptUnhealthyOnTimeout" +} + +setup_config () +{ + cat >"$FAKE_CTDB_EXTRA_CONFIG" } setup_memcheck () diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb index c44419672d..b9524b1968 100755 --- a/ctdb/tests/eventscripts/stubs/ctdb +++ b/ctdb/tests/eventscripts/stubs/ctdb @@ -304,6 +304,30 @@ ctdb_natgwlist () ###################################################################### +ctdb_setvar () +{ + shift + _var="$1" + + for _i in $FAKE_CTDB_TUNABLES_OK ; do + if [ "$_var" = "$_i" ] ; then + return 0 + fi + done + + for _i in $FAKE_CTDB_TUNABLES_OBSOLETE ; do + if [ "$_var" = "$_i" ] ; then + return 0 + fi + done + + echo "Unable to set tunable variable '${_var}'" + return 1 +} + + +###################################################################### + case "$1" in gettickles) setup_tickles @@ -405,5 +429,6 @@ case "$1" in shutdown) ctdb_shutdown "$@";; setnatgwstate) ctdb_setnatgwstate "$@" ;; natgwlist) ctdb_natgwlist "$@" ;; + setvar) ctdb_setvar "$@" ;; *) not_implemented "$1" ;; esac |