6 Verify the operation of the 'ctdb ban' command.
8 This is a superficial test of the 'ctdb ban' command. It trusts
9 information from CTDB that indicates that the IP failover has
10 happened correctly. Another test should check that the failover
11 has actually happened at the networking level.
15 * An active CTDB cluster with at least 2 active nodes.
19 1. Verify that the status on all of the ctdb nodes is 'OK'.
20 2. Ban one of the nodes using the 'ctdb ban <timeout>' command.
21 3. Before the ban timeout expires, verify that the status of the
22 node changes to 'banned'.
23 4. Verify that the public IP addresses that were being served by
24 the node are failed over to one of the other nodes.
25 5. When the ban expires ensure that the status of the node changes
26 back to 'OK' and that the public IP addresses move back to the
31 * The status of the banned nodes changes as expected and IP addresses
36 . ctdb_test_functions.bash
42 onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy
44 echo "Finding out which node is the recovery master..."
45 try_command_on_node -v 0 "$CTDB recmaster"
48 echo "Getting list of public IPs..."
49 try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'"
51 # When selecting test_node we want a node that has public IPs and that
52 # is not the recmaster. We pick the first one that satisfies both
53 # conditions. We avoid the recmaster because banning the recmaster
54 # (obviously) causes the recmaster to change... and changing the
55 # recmaster causes all nodes to become unbanned!
59 while read ip pnn ; do
60 [ -z "$test_node" -a $recmaster -ne $pnn ] && test_node=$pnn
61 [ "$pnn" = "$test_node" ] && ips="${ips}${ips:+ }${ip}"
62 done <<<"$out" # bashism to avoid problem setting variable in pipeline.
64 if [ -z "$test_node" ] ; then
65 echo "BAD: unable to select a suitable node for banning."
69 echo "Selected node ${test_node} with IPs: $ips"
73 echo "Banning node $test_node for $ban_time seconds"
74 try_command_on_node 1 $CTDB ban $ban_time -n $test_node
76 # Avoid a potential race condition...
77 onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node banned
79 if wait_until_ips_are_on_nodeglob "[!${test_node}]" $ips ; then
82 echo "Some IPs didn't move."
86 echo "Sleeping until ban expires..."
89 onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node unbanned
91 # BUG: this is only guaranteed if DeterministicIPs is 1 and
93 if wait_until_ips_are_on_nodeglob "$test_node" $ips ; then
96 echo "Some IPs didn't move."