c513c51257ef13111d39002ffeed4ae842f73231
[metze/ctdb/wip.git] / tests / simple / 31_ctdb_disable.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify the operation of 'ctdb disable'.
7
8 This is a superficial test of the 'ctdb disable' command.  It trusts
9 information from CTDB that indicates that the IP failover has happened
10 correctly.  Another test should check that the failover has actually
11 happened at the networking level.
12
13 Prerequisites:
14
15 * An active CTDB cluster with at least 2 active nodes.
16
17 Steps:
18
19 1. Verify that the status on all of the ctdb nodes is 'OK'.
20 2. Disable one of the nodes using 'ctdb disable -n <node>'.
21 3. Verify that the status of the node changes to 'disabled'.
22 4. Verify that the IP addreses served by the disabled node are failed
23    over to other nodes.
24
25 Expected results:
26
27 * The status of the disabled node changes as expected and IP addresses
28   failover as expected.
29 EOF
30 }
31
32 . ctdb_test_functions.bash
33
34 ctdb_test_init "$@"
35
36 set -e
37
38 cluster_is_healthy
39
40 # Reset configuration
41 ctdb_restart_when_done
42
43 echo "Getting list of public IPs..."
44 try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'"
45
46 # When selecting test_node we just want a node that has public IPs.
47 # This will work and is economically semi-randomly.  :-)
48 read x test_node <<<"$out"
49
50 ips=""
51 while read ip pnn ; do
52     if [ "$pnn" = "$test_node" ] ; then
53         ips="${ips}${ips:+ }${ip}"
54     fi
55 done <<<"$out" # bashism to avoid problem setting variable in pipeline.
56
57 echo "Selected node ${test_node} with IPs: $ips"
58
59 echo "Disabling node $test_node"
60
61 try_command_on_node 1 $CTDB disable -n $test_node
62
63 # Avoid a potential race condition...
64 onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node disabled
65
66 if wait_until_ips_are_on_nodeglob "[!${test_node}]" $ips ; then
67     echo "All IPs moved."
68 else
69     echo "Some IPs didn't move."
70     testfailures=1
71 fi