ctdb-tests: Handle interactions with monitor events
[Samba.git] / ctdb / tests / simple / 60_recoverd_missing_ip.sh
blob88e450227b4096f38c0dd837d2bf3cdaf7afb0de
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that the reconvery daemon handles unhosted IPs properly.
7 EOF
10 . "${TEST_SCRIPTS_DIR}/integration.bash"
12 ctdb_test_init "$@"
14 set -e
16 cluster_is_healthy
18 # Reset configuration
19 ctdb_restart_when_done
21 select_test_node_and_ips
23 echo "Running test against node $test_node and IP $test_ip"
25 # Find the interface
26 try_command_on_node $test_node "$CTDB ip -v -Y | awk -F: -v ip=$test_ip '\$2 == ip { print \$4 }'"
27 iface="$out"
29 if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
30 # Find the netmask
31 try_command_on_node $test_node ip addr show to $test_ip
32 mask="${out##*/}"
33 mask="${mask%% *}"
34 else
35 mask="24"
38 echo "$test_ip/$mask is on $iface"
40 echo "Deleting IP $test_ip from all nodes"
41 try_command_on_node -v $test_node $CTDB delip -n all $test_ip
43 wait_until_ips_are_on_nodeglob '!' $test_node $test_ip
45 try_command_on_node -v all $CTDB ip
47 my_exit_hook ()
49 if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
50 onnode -q all $CTDB enablescript "10.interface"
54 ctdb_test_exit_hook_add my_exit_hook
56 # This forces us to wait until the ipreallocated associated with the
57 # delips is complete.
58 try_command_on_node $test_node $CTDB sync
60 # Wait for a monitor event. Then the next steps are unlikely to occur
61 # in the middle of a monitor event and will have the expected effect.
62 wait_for_monitor_event $test_node
64 if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
65 # Stop monitor events from bringing up the link status of an interface
66 try_command_on_node $test_node $CTDB disablescript 10.interface
69 echo "Marking interface $iface down on node $test_node"
70 try_command_on_node $test_node $CTDB setifacelink $iface down
72 try_command_on_node $test_node $CTDB clearlog recoverd
74 echo "Adding IP $test_ip to node $test_node"
75 try_command_on_node $test_node $CTDB addip $test_ip/$mask $iface
77 # Give the recovery daemon enough time to start doing IP verification
78 sleep_for 15
80 try_command_on_node $test_node $CTDB getlog recoverd
82 msg="Public IP '$test_ip' is not assigned and we could serve it"
84 if grep "$msg" <<<"$out" ; then
85 echo "BAD: the recovery daemon noticed that the IP was unhosted"
86 exit 1
87 else
88 echo "GOOD: the recovery daemon did not notice that the IP was unhosted"
91 try_command_on_node $test_node $CTDB clearlog recoverd
93 echo "Marking interface $iface up on node $test_node"
94 try_command_on_node $test_node $CTDB setifacelink $iface up
96 wait_until_ips_are_on_nodeglob $test_node $test_ip
98 try_command_on_node -v $test_node $CTDB getlog recoverd
100 if grep "$msg" <<<"$out" ; then
101 echo "GOOD: the recovery daemon noticed that the IP was unhosted"
102 else
103 echo "BAD: the recovery daemon did not notice that the IP was unhosted"
104 exit 1