tests: add a all_ips_on_node() helper function that wraps ctdb ip -Y
authorStefan Metzmacher <metze@samba.org>
Sat, 16 Jan 2010 09:35:41 +0000 (10:35 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 20 Jan 2010 10:11:00 +0000 (11:11 +0100)
metze

tests/scripts/ctdb_test_functions.bash
tests/simple/16_ctdb_config_add_ip.sh
tests/simple/17_ctdb_config_delete_ip.sh
tests/simple/23_ctdb_moveip.sh

index 7c1b46c91dff5295f3b2a1ee32827854097dddba..4f05888d4a7dd7ec1aa1e3d5e34ef320585dd573 100644 (file)
@@ -239,7 +239,7 @@ sanity_check_output ()
 
 sanity_check_ips ()
 {
-    local ips="$1" # Output of "ctdb ip -n all"
+    local ips="$1" # list of "ip node" lines
 
     echo "Sanity checking IPs..."
 
@@ -259,9 +259,16 @@ sanity_check_ips ()
     return 1
 }
 
+# This returns a list of "ip node" lines in $out
+all_ips_on_node()
+{
+    local node=$@
+    try_command_on_node $node "$CTDB ip -Y -n all | cut -d ':' -f1-3 | sed -e '1d' -e 's@^:@@' -e 's@:@ @g'"
+}
+
 select_test_node_and_ips ()
 {
-    try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'"
+    all_ips_on_node 0
 
     # When selecting test_node we just want a node that has public
     # IPs.  This will work and is economically semi-random.  :-)
@@ -450,7 +457,7 @@ ips_are_on_nodeglob ()
 
     local out
 
-    try_command_on_node 1 ctdb ip -n all
+    all_ips_on_node 1
 
     while read ip pnn ; do
        for check in $ips ; do
index aaee472873af96e1a131389197ac0cd522573be5..79849f2c5b6a81890a1ce7b6fb0157897b9fc116 100755 (executable)
@@ -46,7 +46,7 @@ cluster_is_healthy
 ctdb_restart_when_done
 
 echo "Getting list of public IPs..."
-try_command_on_node 0 "$CTDB ip -n all | sed -e '1d'"
+all_ips_on_node 0
 
 # When selecting test_node we just want a node that has public IPs.
 # This will work and is economically semi-randomly.  :-)
index 4ea34bd270c6b971e5d48a91af2d2b34b43a8605..04329469938ea12dc1d248d7aed93ad26483848f 100755 (executable)
@@ -21,7 +21,7 @@ Steps:
 3. Delete one public IP address being be served by the node, using
    'ctdb delip'.
 4. Verify that the delete IP address is no longer listed using the
-   'ctdb ip' command.
+   all_ips_on_node helper function.
 
 Expected results:
 
@@ -42,7 +42,7 @@ cluster_is_healthy
 ctdb_restart_when_done
 
 echo "Getting list of public IPs..."
-try_command_on_node -v 0 "$CTDB ip -n all | sed -e '1d'"
+all_ips_on_node -v 0
 
 # Select an IP/node to remove.
 num_ips=$(echo "$out" | wc -l)
index 68a7f70f91742c4f8400fa5e91ec5ad59d0bb3f2..b025dc7d3da0c235141eca1ebb4027401b1c4015 100755 (executable)
@@ -50,7 +50,7 @@ if [ $num_nodes -lt 2 ] ; then
 fi
 
 echo "Getting list of public IPs..."
-try_command_on_node -v 0 "$CTDB ip -n all | sed -e '1d'"
+all_ips_on_node -v 0
 
 sanity_check_ips "$out"