6 Verify that 'ctdb disablemonitor' works correctly.
10 * An active CTDB cluster with at least 2 active nodes.
11 * 00_ctdb_install_eventscript.sh successfully installed its event
16 1. Verify that the status on all of the ctdb nodes is 'OK'.
17 2. Create a file called /tmp/ctdb-test-unhealthy-trigger.<node> on a
18 node and verify that the status of the node changes to unhealthy
19 within the interval indicated by the MonitorInterval variable.
20 3. Check that the file /tmp/ctdb-test-unhealthy-detected.<node> is
21 created, indicating that the event script is the reason the node
22 has been marked as unhealthy.
23 4. Now disable monitoring on the node using 'ctdb disablemonitor -n <node>.
24 5. Verify that the message 'Monitoring mode:DISABLED' is printed.
25 6. Remove /tmp/ctdb-test-unhealthy-detected.<node> and ensure that it
26 is not recreated within the interval indicated by the
27 MonitorInterval variable.
28 7. Remove /tmp/ctdb-test-unhealthy-trigger.<node>.
29 8. Verify that the status of the node continues to be 'UNHEALTHY',
30 since monitoring has been disabled.
34 * When monitoring is disabled, event scripts are not executed and the
35 state of nodes is not monitored.
39 . ctdb_test_functions.bash
48 ctdb_restart_when_done
52 # We need this for later, so we know how long to sleep.
53 try_command_on_node -v 0 $CTDB getvar MonitorInterval -n $test_node
54 monitor_interval="${out#*= }"
55 echo "Monitor interval on node $test_node is $monitor_interval seconds."
57 trigger="/tmp/ctdb-test-unhealthy-trigger.${test_node}"
58 detected="/tmp/ctdb-test-unhealthy-detected.${test_node}"
60 recovered_flag="/tmp/ctdb-test-flag.recovered.${test_node}"
61 try_command_on_node $test_node touch "$recovered_flag"
63 ctdb_test_exit_hook_add "onnode $test_node rm -vf $trigger"
65 echo "Creating trigger file on node $test_node to make it unhealthy..."
66 try_command_on_node $test_node touch "$trigger"
68 onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node unhealthy $monitor_interval
70 try_command_on_node -v $test_node ls -l "$detected"
72 # Wait until recovery is complete before disabling monitoring,
73 # otherwise completion of the recover can turn monitoring back on!
74 echo "Waiting until recovery is complete..."
75 wait_until 30 onnode $test_node ! test -e "$recovered_flag"
77 try_command_on_node -v 0 $CTDB disablemonitor -n $test_node
81 '^Monitoring mode:DISABLED$' \
84 onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node monoff
86 try_command_on_node -v $test_node rm -v "$detected"
88 sleep_for $monitor_interval
90 try_command_on_node $test_node test ! -e "$detected"
92 echo "OK: flag file was not recreated so monitoring must be disabled."
94 echo "Removing trigger file. Monitoring is disabled so node will stay unhealthy."
96 try_command_on_node -v $test_node rm -v "$trigger"
98 sleep_for $monitor_interval
100 onnode 0 $CTDB_TEST_WRAPPER node_has_status $test_node unhealthy