Add test for NoIPTakeover
[kai/samba-autobuild/.git] / ctdb / tests / simple / 73_tunable_NoIPTakeover.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that  'ctdb setvar NoIPTakeover 1' stops ip addresses from being failed 
7 over onto the node.
8
9 Prerequisites:
10
11 * An active CTDB cluster with at least 2 active nodes.
12
13 Steps:
14
15 1. Verify that the status on all of the ctdb nodes is 'OK'.
16 2. Use 'ctdb ip' on one of the nodes to list the IP addresses being
17    served.
18 3. Use 'ctdb moveip' to move an address from one node to another.
19 4. Verify that the IP is no longer being hosted by the first node and is now being hosted by the second node.
20
21 Expected results:
22
23 * 'ctdb moveip' allows an IP address to be moved between cluster nodes.
24 EOF
25 }
26
27 . ctdb_test_functions.bash
28
29 ctdb_test_init "$@"
30
31 cluster_is_healthy
32
33 # Reset configuration
34 ctdb_restart_when_done
35
36 try_command_on_node 0 "$CTDB listnodes | wc -l"
37 num_nodes="$out"
38 echo "There are $num_nodes nodes..."
39
40 if [ $num_nodes -lt 2 ] ; then
41     echo "Less than 2 nodes!"
42     exit 1
43 fi
44
45
46 echo "Wait until the ips are reallocated"
47 sleep 30
48 try_command_on_node -q 0 "$CTDB ipreallocate"
49
50 num=`try_command_on_node -v 1 "$CTDB ip" | grep -v Public | egrep " 1$" | wc -l`
51 echo "Number of addresses on node 1 : $num"
52
53
54 echo "Turning on NoIPTakeover on node 1"
55 try_command_on_node -q 1 "$CTDB setvar NoIPTakeover 1"
56 try_command_on_node -q 1 "$CTDB ipreallocate"
57
58 echo Disable node 1
59 try_command_on_node -q 1 "$CTDB disable"
60 try_command_on_node -q 1 "$CTDB ipreallocate"
61 num=`try_command_on_node -v 1 "$CTDB ip" | grep -v Public | egrep " 1$" | wc -l`
62 echo "Number of addresses on node 1 : $num"
63 [ "$num" != "0" ] && {
64     echo "BAD: node 1 still hosts ip addresses"
65     exit 1
66 }
67
68
69 echo "Enable node 1 again"
70 try_command_on_node -q 1 "$CTDB enable"
71 sleep 30
72 try_command_on_node -q 1 "$CTDB ipreallocate"
73 try_command_on_node -q 1 "$CTDB ipreallocate"
74 num=`try_command_on_node -v 1 "$CTDB ip" | grep -v Public | egrep " 1$" | wc -l`
75 echo "Number of addresses on node 1 : $num"
76 [ "$num" != "0" ] && {
77     echo "BAD: node took over ip addresses"
78     exit 1
79 }
80
81
82 echo "OK. ip addresses were not taken over"
83 exit 0