summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2008-12-04 17:19:51 +1100
committerMartin Schwenke <martin@meltin.net>2008-12-04 17:19:51 +1100
commit805c5bf1f33d250fa1f9f6fac0e46ff9358c8dee (patch)
treed3d9277642eaf94eef13c75c969e211b9539893e
parent733fe4594c551168bc70241f361a18eb2acd45ee (diff)
New test for getmonmode. Overload node_has_status some more to
support checking the monitoring mode. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 4e1c079deb0aafb99d4114bb6504ff5ba1cbdeb4)
-rw-r--r--ctdb/tests/scripts/ctdb_test_functions.bash8
-rwxr-xr-xctdb/tests/simple/20_ctdb_getmonmode.sh69
2 files changed, 75 insertions, 2 deletions
diff --git a/ctdb/tests/scripts/ctdb_test_functions.bash b/ctdb/tests/scripts/ctdb_test_functions.bash
index bcf401c1de..96a0f9f56e 100644
--- a/ctdb/tests/scripts/ctdb_test_functions.bash
+++ b/ctdb/tests/scripts/ctdb_test_functions.bash
@@ -272,13 +272,13 @@ wait_until_healthy ()
wait_until 120 _cluster_is_healthy
}
-# Incomplete! Do not use!
+# This function is becoming nicely overloaded. Soon it will collapse! :-)
node_has_status ()
{
local pnn="$1"
local status="$2"
- local bits fpat
+ local bits fpat mpat
case "$status" in
(disconnected) bits="1:?:?:?" ;;
(connected) bits="0:?:?:?" ;;
@@ -288,6 +288,8 @@ node_has_status ()
(enabled) bits="?:?:0:?" ;;
(frozen) fpat='^[[:space:]]+frozen[[:space:]]+1$' ;;
(unfrozen) fpat='^[[:space:]]+frozen[[:space:]]+0$' ;;
+ (monon) mpat='^Monitoring mode:ACTIVE \(0\)$' ;;
+ (monoff) mpat='^Monitoring mode:DISABLED \(1\)$' ;;
*)
echo "node_has_status: unknown status \"$status\""
return 1
@@ -307,6 +309,8 @@ node_has_status ()
} <<<"$out" # Yay bash!
elif [ -n "$fpat" ] ; then
ctdb statistics -n "$pnn" | egrep -q "$fpat"
+ elif [ -n "$mpat" ] ; then
+ ctdb getmonmode -n "$pnn" | egrep -q "$mpat"
else
echo 'node_has_status: unknown mode, neither $bits nor $fpat is set'
return 1
diff --git a/ctdb/tests/simple/20_ctdb_getmonmode.sh b/ctdb/tests/simple/20_ctdb_getmonmode.sh
new file mode 100755
index 0000000000..97bcf21bc7
--- /dev/null
+++ b/ctdb/tests/simple/20_ctdb_getmonmode.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+test_info()
+{
+ cat <<EOF
+Verify 'ctdb getmonmode' works correctly.
+
+This test doesn't actually verify that enabling and disabling
+monitoring mode actually does that. It trusts ctdb that the
+monitoring mode is modified as requested. 21_ctdb_disablemonitor.sh
+does some more useful checking.
+
+Prerequisites:
+
+* An active CTDB cluster with at least 2 active nodes.
+
+Steps:
+
+1. Verify that the status on all of the ctdb nodes is 'OK'.
+2. Use 'ctdb getmodmode -n <node>' to get the current monitoring mode.
+3. Verify that it shows monitoring as 'active'.
+4. Verify that the command prints the output in colon-separated format
+ when run with the '-Y' option.
+5. Disable monitoring on the node using 'ctdb disablemonitor'.
+6. Verify that it shows monitoring as 'disabled'.
+
+Expected results:
+
+* 'ctdb getmonmode' works as expected.
+EOF
+}
+
+. ctdb_test_functions.bash
+
+ctdb_test_init "$@"
+
+set -e
+
+onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
+
+test_node=1
+
+try_command_on_node -v 0 ctdb getmonmode -n $test_node
+
+sanity_check_output \
+ 1 \
+ '^Monitoring mode:ACTIVE \(0\)$' \
+ "$out"
+
+colons=$(printf ':mode:\n:0:')
+
+try_command_on_node -v 0 ctdb -Y getmonmode -n $test_node
+
+if [ "$out" = "$colons" ] ; then
+ echo "Looks OK"
+else
+ echo "BAD: -Y output isn't what was expected"
+ testfailures=1
+fi
+
+try_command_on_node -v 0 ctdb disablemonitor -n $test_node
+
+onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node monoff
+
+echo "That worked! Disabling node $test_node to force a restart..."
+
+try_command_on_node $test_node ctdb disable
+
+ctdb_test_exit