]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Simplify IP address checking
authorMartin Schwenke <martin@meltin.net>
Wed, 10 Aug 2022 23:15:38 +0000 (09:15 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 25 Aug 2022 15:22:36 +0000 (15:22 +0000)
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/CLUSTER/complex/11_ctdb_delip_removes_ip.sh

index 72a498b2dd8eb42eb48fa47e2b5987cce3fa9657..77e59f8c927dd96dcc6f096b6bdc1bb95feb427c 100755 (executable)
@@ -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!"