| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # Verify that TAKE_IP will work for an IP that is already on an interface |
| 4 | |
| 5 | # This is a variation of simple/60_recoverd_missing_ip.sh |
| 6 | |
| 7 | . "${TEST_SCRIPTS_DIR}/cluster.bash" |
| 8 | |
| 9 | set -e |
| 10 | |
| 11 | ctdb_test_init |
| 12 | |
| 13 | select_test_node_and_ips |
| 14 | |
| 15 | echoscip-shell system . . echo. "Running test against node $test_node and IP $test_ip" |
| 16 | |
| 17 | # This test puts an address on an interface and then needs to quickly |
| 18 | # configure that address and cause an IP takeover. However, an IPv6 |
| 19 | # address will be tentative for a while so "quickly" is not possible". |
| 20 | # When ctdb_control_takeover_ip() calls ctdb_sys_have_ip() it will |
| 21 | # decide that the address is not present. It then attempts a takeip, |
| 22 | # which can fail if the address is suddenly present because it is no |
| 23 | # longer tentative. |
| 24 | case "$test_ip" in |
| 25 | *:*) ctdb_test_skip "This test is not supported for IPv6 addresses" ;; |
| 26 | esac |
| 27 | |
| 28 | get_test_ip_mask_and_iface |
| 29 | |
| 30 | echoscip-shell system . . echo. "Deleting IP $test_ip from all nodes" |
| 31 | delete_ip_from_all_nodes $test_ip |
| 32 | try_command_on_node -v $test_node $CTDB ipreallocate |
| 33 | wait_until_ips_are_on_node ! $test_node $test_ip |
| 34 | |
| 35 | try_command_on_node -v all $CTDB ip |
| 36 | |
| 37 | # The window here needs to small, to try to avoid the address being |
| 38 | # released. The test will still pass either way but if the first IP |
| 39 | # takeover run does a release then this doesn't test the code path we |
| 40 | # expect it to... |
| 41 | echoscip-shell system . . echo. "Adding IP $test_ip to $iface and CTDB on node $test_node" |
| 42 | ip_cmd="ip addr add $test_ip/$mask dev $iface" |
| 43 | ctdb_cmd="$CTDB addip $test_ip/$mask $iface && $CTDB ipreallocate" |
| 44 | try_command_on_node $test_node "$ip_cmd && $ctdb_cmd" |
| 45 | |
| 46 | wait_until_ips_are_on_node $test_node $test_ip |