ctdb-tests: Drop use of "ctdb delip -n all" in simple tests
authorMartin Schwenke <martin@meltin.net>
Mon, 19 Oct 2015 05:51:48 +0000 (16:51 +1100)
committerAmitay Isaacs <amitay@samba.org>
Fri, 23 Oct 2015 01:43:26 +0000 (03:43 +0200)
Add new function delete_ip_from_all_nodes().  Also
ctdb_get_all_pnns().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/scripts/integration.bash
ctdb/tests/simple/16_ctdb_config_add_ip.sh
ctdb/tests/simple/60_recoverd_missing_ip.sh

index 139a9a23cb2e74ae65eeddbab5f4de08ca8dabec..a4d1de6408547f188d55dd5fb84e2ae99ba461e4 100644 (file)
@@ -229,6 +229,34 @@ get_test_ip_mask_and_iface ()
     echo "$test_ip/$mask is on $iface"
 }
 
+ctdb_get_all_pnns ()
+{
+    try_command_on_node -q all "$CTDB pnn | sed -e 's@PNN:@@'"
+    all_pnns="$out"
+}
+
+# The subtlety is that "ctdb delip" will fail if the IP address isn't
+# configured on a node...
+delete_ip_from_all_nodes ()
+{
+    _ip="$1"
+
+    ctdb_get_all_pnns
+
+    _nodes=""
+
+    for _pnn in $all_pnns ; do
+       all_ips_on_node $_pnn
+       while read _i _n ; do
+           if [ "$_ip" = "$_i" ] ; then
+               _nodes="${_nodes}${_nodes:+,}${_pnn}"
+           fi
+       done <<<"$out" # bashism
+    done
+
+    try_command_on_node -pq "$_nodes" "$CTDB delip $_ip"
+}
+
 #######################################
 
 # Wait until either timeout expires or command succeeds.  The command
index b5d76ea7ad69e63e9b15460c8f577f6576934fc5..55527ad4cb1f00c6c448871c63a964fa453455a6 100755 (executable)
@@ -25,7 +25,7 @@ select_test_node_and_ips
 get_test_ip_mask_and_iface
 
 echo "Deleting IP $test_ip from all nodes"
-try_command_on_node $test_node $CTDB delip -n all $test_ip
+delete_ip_from_all_nodes $test_ip
 wait_until_ips_are_on_node '!' $test_node $test_ip
 
 # Debugging...
index 9ad7b69171077b3720f694b1fdbf206a41a91917..36271d19d9eb7bfb812a06d36069e2090838e009 100755 (executable)
@@ -30,7 +30,7 @@ echo "Running test against node $test_node and IP $test_ip"
 get_test_ip_mask_and_iface
 
 echo "Deleting IP $test_ip from all nodes"
-try_command_on_node $test_node $CTDB delip -n all $test_ip
+delete_ip_from_all_nodes $test_ip
 wait_until_ips_are_on_node ! $test_node $test_ip
 
 try_command_on_node -v all $CTDB ip