Merge branch 'master' of ctdb into 'master' of samba
[sfrench/samba-autobuild/.git] / ctdb / tests / simple / 26_ctdb_config_check_error_on_unreachable_ctdb.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify an error occurs if a ctdb command is run against a node without a ctdbd.
7
8 That is, check that an error message is printed if an attempt is made
9 to execute a ctdb command against a node that is not running ctdbd.
10
11 Prerequisites:
12
13 * An active CTDB cluster with at least 2 active nodes.
14
15 Steps:
16
17 1. Verify that the status on all of the ctdb nodes is 'OK'.
18 2. Shutdown ctdb on a node using 'ctdb shutdown -n <node>'.
19 3. Verify that the status of the node changes to 'DISCONNECTED'.
20 4. Now run 'ctdb ip -n <node>' from another node.
21 5. Verify that an error message is printed stating that the node is
22    disconnected.
23 6. Execute some other commands against the shutdown node.  For example,
24    disable, enable, ban, unban, listvars.
25 7. For each command, verify that an error message is printed stating
26    that the node is disconnected. 
27
28 Expected results:
29
30 * For a node on which ctdb is not running, all commands display an
31   error message stating that the node is disconnected.
32 EOF
33 }
34
35 . "${TEST_SCRIPTS_DIR}/integration.bash"
36
37 ctdb_test_init "$@"
38
39 set -e
40
41 cluster_is_healthy
42
43 # Reset configuration
44 ctdb_restart_when_done
45
46 test_node=1
47
48 try_command_on_node 0 "$CTDB listnodes"
49 num_nodes=$(echo "$out" | wc -l)
50 echo "There are $num_nodes nodes."
51
52 echo "Shutting down node ${test_node}..."
53 try_command_on_node $test_node $CTDB shutdown
54
55 wait_until_node_has_status $test_node disconnected 30 0
56
57 wait_until_node_has_status 0 recovered 30 0
58
59 pat="ctdb_control error: 'ctdb_control to disconnected node'|ctdb_control error: 'node is disconnected'|Node $test_node is DISCONNECTED|Node $test_node has status DISCONNECTED\|UNHEALTHY\|INACTIVE"
60
61 for i in ip disable enable "ban 0" unban listvars ; do
62     try_command_on_node -v 0 ! $CTDB $i -n $test_node
63
64     if egrep -q "$pat" <<<"$out" ; then
65         echo "OK: \"ctdb ${i}\" fails with expected \"disconnected node\" message"
66     else
67         echo "BAD: \"ctdb ${i}\" does not fail with expected \"disconnected node\" message"
68         exit 1
69     fi
70 done