a993f53e013506ee69f2c031db0c4647242ac454
[bbaumbach/samba-autobuild/.git] / ctdb / tests / simple / 60_recoverd_missing_ip.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that the recovery daemon handles unhosted IPs properly.
7
8 This test does not do any network level checks to make sure the IP
9 address is actually on an interface.  It just consults "ctdb ip".
10
11 This is a variation of the "addip" test.
12 EOF
13 }
14
15 . "${TEST_SCRIPTS_DIR}/integration.bash"
16
17 ctdb_test_init "$@"
18
19 set -e
20
21 cluster_is_healthy
22
23 # Reset configuration
24 ctdb_restart_when_done
25
26 select_test_node_and_ips
27
28 echo "Running test against node $test_node and IP $test_ip"
29
30 get_test_ip_mask_and_iface
31
32 echo "Deleting IP $test_ip from all nodes"
33 delete_ip_from_all_nodes $test_ip
34 try_command_on_node -v $test_node $CTDB ipreallocate
35 wait_until_ips_are_on_node ! $test_node $test_ip
36
37 try_command_on_node -v all $CTDB ip
38
39 my_exit_hook ()
40 {
41     if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
42         onnode -q all $CTDB event script enable "10.interface"
43     fi
44 }
45
46 ctdb_test_exit_hook_add my_exit_hook
47
48 # This forces us to wait until the ipreallocated associated with the
49 # delips is complete.
50 try_command_on_node $test_node $CTDB sync
51
52 # Wait for a monitor event.  Then the next steps are unlikely to occur
53 # in the middle of a monitor event and will have the expected effect.
54 wait_for_monitor_event $test_node
55
56 if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
57     # Stop monitor events from bringing up the link status of an interface
58     try_command_on_node $test_node $CTDB event script disable 10.interface
59 fi
60
61 echo "Marking interface $iface down on node $test_node"
62 try_command_on_node $test_node $CTDB setifacelink $iface down
63
64 echo "Adding IP $test_ip to node $test_node"
65 try_command_on_node $test_node $CTDB addip $test_ip/$mask $iface
66 try_command_on_node $test_node $CTDB ipreallocate
67
68 echo "Wait long enough for IP verification to have taken place"
69 sleep_for 15
70
71 echo "Ensuring that IP ${test_ip} is not hosted on node ${test_node} when interface is down"
72 if ips_are_on_node '!' $test_node $test_ip; then
73     echo "GOOD: the IP has not been hosted while the interface is down"
74 else
75     echo "BAD: the IP is hosted but the interface is down"
76     exit 1
77 fi
78
79 echo "Marking interface $iface up on node $test_node"
80 try_command_on_node $test_node $CTDB setifacelink $iface up
81 wait_until_ips_are_on_node $test_node $test_ip