ctdb-tests: Factor out new function get_test_ip_mask_and_iface()
[Samba.git] / ctdb / tests / simple / 60_recoverd_missing_ip.sh
blobd6d5310662ca4b1ebfe0abed5dcfad2bc6046db7
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 get_test_ip_mask_and_iface
26 echo "$test_ip/$mask is on $iface"
28 echo "Deleting IP $test_ip from all nodes"
29 try_command_on_node -v $test_node $CTDB delip -n all $test_ip
31 wait_until_ips_are_on_node '!' $test_node $test_ip
33 try_command_on_node -v all $CTDB ip
35 my_exit_hook ()
37 if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
38 onnode -q all $CTDB enablescript "10.interface"
42 ctdb_test_exit_hook_add my_exit_hook
44 # This forces us to wait until the ipreallocated associated with the
45 # delips is complete.
46 try_command_on_node $test_node $CTDB sync
48 # Wait for a monitor event. Then the next steps are unlikely to occur
49 # in the middle of a monitor event and will have the expected effect.
50 wait_for_monitor_event $test_node
52 if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
53 # Stop monitor events from bringing up the link status of an interface
54 try_command_on_node $test_node $CTDB disablescript 10.interface
57 echo "Marking interface $iface down on node $test_node"
58 try_command_on_node $test_node $CTDB setifacelink $iface down
60 try_command_on_node $test_node $CTDB clearlog recoverd
62 echo "Adding IP $test_ip to node $test_node"
63 try_command_on_node $test_node $CTDB addip $test_ip/$mask $iface
65 # Give the recovery daemon enough time to start doing IP verification
66 sleep_for 15
68 try_command_on_node $test_node $CTDB getlog recoverd
70 msg="Public IP '$test_ip' is not assigned and we could serve it"
72 if grep "$msg" <<<"$out" ; then
73 echo "BAD: the recovery daemon noticed that the IP was unhosted"
74 exit 1
75 else
76 echo "GOOD: the recovery daemon did not notice that the IP was unhosted"
79 try_command_on_node $test_node $CTDB clearlog recoverd
81 echo "Marking interface $iface up on node $test_node"
82 try_command_on_node $test_node $CTDB setifacelink $iface up
84 wait_until_ips_are_on_node $test_node $test_ip
86 try_command_on_node -v $test_node $CTDB getlog recoverd
88 if grep "$msg" <<<"$out" ; then
89 echo "GOOD: the recovery daemon noticed that the IP was unhosted"
90 else
91 echo "BAD: the recovery daemon did not notice that the IP was unhosted"
92 exit 1