From ff4935d180e1a290e4ba7ab0f8710d9a022d1b82 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 11 Aug 2022 09:15:38 +1000 Subject: ctdb-tests: Simplify IP address checking Use a new function and wait_until() to simplify. get_test_ip_mask_and_iface() not needed here because select_test_node_and_ips() sets $test_ip, and neither $mask nor $iface is used. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- .../CLUSTER/complex/11_ctdb_delip_removes_ip.sh | 29 ++++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'ctdb') diff --git a/ctdb/tests/CLUSTER/complex/11_ctdb_delip_removes_ip.sh b/ctdb/tests/CLUSTER/complex/11_ctdb_delip_removes_ip.sh index 72a498b2dd8..77e59f8c927 100755 --- a/ctdb/tests/CLUSTER/complex/11_ctdb_delip_removes_ip.sh +++ b/ctdb/tests/CLUSTER/complex/11_ctdb_delip_removes_ip.sh @@ -8,36 +8,27 @@ set -e +test_node_has_test_ip() +{ + # $test_node and $test_ip set by select_test_node_and_ips() + # shellcheck disable=SC2154 + try_command_on_node "$test_node" "ip addr show to ${test_ip}" + [ -n "$out" ] +} + ctdb_test_init select_test_node_and_ips -get_test_ip_mask_and_iface echo "Checking that node ${test_node} hosts ${test_ip}..." -try_command_on_node $test_node "ip addr show to ${test_ip} | grep -q ." +test_node_has_test_ip echo "Attempting to remove ${test_ip} from node ${test_node}." try_command_on_node $test_node $CTDB delip $test_ip try_command_on_node $test_node $CTDB ipreallocate wait_until_ips_are_on_node '!' $test_node $test_ip -timeout=60 -increment=5 -count=0 echo "Waiting for ${test_ip} to disappear from node ${test_node}..." -while :; do - try_command_on_node -v $test_node "ip addr show to ${test_ip}" - if [ -n "$out" ]; then - echo "Still there..." - if [ $(($count * $increment)) -ge $timeout ]; then - echo "BAD: Timed out waiting..." - exit 1 - fi - sleep_for $increment - count=$(($count + 1)) - else - break - fi -done +wait_until 60/5 '!' test_node_has_test_ip echo "GOOD: IP was successfully removed!" -- cgit v1.2.1