tests: select_test_node_and_ips() should try to avoid failing
authorMartin Schwenke <martin@meltin.net>
Mon, 2 Jul 2012 04:06:35 +0000 (14:06 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 26 Jul 2012 12:03:00 +0000 (22:03 +1000)
Sometimes "ctdb sync" doesn't do its job, so we end up with unassigned
IPs.

If $test_node isn't set then this is bad.  However, try a few times to
ensure it is set.

Signed-off-by: Martin Schwenke <martin@meltin.net>
tests/scripts/integration.bash

index 52291840667ad04f7878ab8f34457dfe3701a34b..8b268b1aa00662ea094db695b1dc7f55a74dc885 100644 (file)
@@ -234,7 +234,7 @@ all_ips_on_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 ()
+_select_test_node_and_ips ()
 {
     all_ips_on_node 0
 
@@ -252,6 +252,24 @@ select_test_node_and_ips ()
 
     echo "Selected node ${test_node} with IPs: ${test_node_ips}."
     test_ip="${test_node_ips%% *}"
+
+    [ -n "$test_node" ] || return 1
+}
+
+select_test_node_and_ips ()
+{
+    local timeout=10
+    while ! _select_test_node_and_ips ; do
+       echo "Unable to find a test node with IPs assigned"
+       if [ $timeout -le 0 ] ; then
+           echo "BAD: Too many attempts"
+           return 1
+       fi
+       sleep_for 1
+       timeout=$(($timeout - 1))
+    done
+
+    return 0
 }
 
 #######################################