ctdb-tests: Factor out new function get_test_ip_mask_and_iface()
authorMartin Schwenke <martin@meltin.net>
Fri, 12 Sep 2014 03:40:01 +0000 (13:40 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 23 Sep 2014 06:06:12 +0000 (08:06 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/scripts/integration.bash
ctdb/tests/simple/60_recoverd_missing_ip.sh

index 548b1e19c049bf690810bc728b4822bbf7f5d8cc..d40582955b87c172415f5584fdaa80f7b87a9e72 100644 (file)
@@ -202,6 +202,25 @@ select_test_node_and_ips ()
     return 0
 }
 
+# Sets: mask, iface
+get_test_ip_mask_and_iface ()
+{
+    # Find the interface
+    try_command_on_node $test_node "$CTDB ip -v -Y | awk -F: -v ip=$test_ip '\$2 == ip { print \$4 }'"
+    iface="$out"
+
+    if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+       # Find the netmask
+       try_command_on_node $test_node ip addr show to $test_ip
+       mask="${out##*/}"
+       mask="${mask%% *}"
+    else
+       mask="24"
+    fi
+
+    echo "$test_ip/$mask is on $iface"
+}
+
 #######################################
 
 # Wait until either timeout expires or command succeeds.  The command
index 8ba05702a978af0b2bb1eccf046d3178f894c103..d6d5310662ca4b1ebfe0abed5dcfad2bc6046db7 100755 (executable)
@@ -22,19 +22,7 @@ select_test_node_and_ips
 
 echo "Running test against node $test_node and IP $test_ip"
 
-# Find the interface
-try_command_on_node $test_node "$CTDB ip -v -Y | awk -F: -v ip=$test_ip '\$2 == ip { print \$4 }'"
-iface="$out"
-
-if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
-    # Find the netmask
-    try_command_on_node $test_node ip addr show to $test_ip
-    mask="${out##*/}"
-    mask="${mask%% *}"
-else
-    mask="24"
-fi
-
+get_test_ip_mask_and_iface
 echo "$test_ip/$mask is on $iface"
 
 echo "Deleting IP $test_ip from all nodes"