]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Drop uses of "onnode any ..." in testcases
authorMartin Schwenke <martin@meltin.net>
Tue, 10 Dec 2019 00:33:02 +0000 (11:33 +1100)
committerMartin Schwenke <martins@samba.org>
Wed, 22 Jul 2020 07:53:36 +0000 (07:53 +0000)
It would be nice to get rid of "onnode any".  There's no use making
tests nondeterministic.  If covering different cases matters then they
should be explicitly handled.

In most places "any" is replaced by "$test_node".  In some cases,
where $test_node is not set, a fixed node that is already used
elsewhere can be reused.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/CLUSTER/complex/18_ctdb_reloadips.sh
ctdb/tests/CLUSTER/complex/31_nfs_tickle.sh
ctdb/tests/CLUSTER/complex/34_nfs_tickle_restart.sh
ctdb/tests/INTEGRATION/database/readonly.001.basic.sh
ctdb/tests/INTEGRATION/database/recovery.001.volatile.sh
ctdb/tests/INTEGRATION/failover/pubips.012.reloadips.sh
ctdb/tests/INTEGRATION/failover/pubips.013.failover_noop.sh
ctdb/tests/INTEGRATION/failover/pubips.020.moveip.sh

index f4df2b1b08b2140fb48adb50ccc7f578f93ed9d2..150aeea5f14df7f6f07737ecce59697cce44be7d 100755 (executable)
@@ -38,7 +38,7 @@ select_test_node_and_ips
 # the provided prefix.  Note that this is an IPv4-specific test.
 
 echo "Getting public IP information from CTDB..."
-try_command_on_node any "$CTDB ip -X -v all"
+ctdb_onnode "$test_node" "ip -X -v all"
 ctdb_ip_info=$(awk -F'|' 'NR > 1 { print $2, $3, $5 }' "$outfile")
 
 echo "Getting IP information from interfaces..."
@@ -215,7 +215,7 @@ do_ctdb_reloadips
 
 check_ips $test_node "$iface" "$prefix" 1 $new_ip_max
 
-try_command_on_node any $CTDB sync
+ctdb_onnode "$test_node" sync
 
 ####################
 
@@ -229,7 +229,7 @@ do_ctdb_reloadips
 
 check_ips $test_node "$iface" "$prefix" 2 $new_ip_max
 
-try_command_on_node any $CTDB sync
+ctdb_onnode "$test_node" sync
 
 ####################
 
@@ -244,7 +244,7 @@ do_ctdb_reloadips
 
 check_ips $test_node "$iface" "$prefix" $start $new_ip_max
 
-try_command_on_node any $CTDB sync
+ctdb_onnode "$test_node" sync
 
 ####################
 
index e3c362c347ae00a6d4e491b150ca43d62aa77a81..e3f1540aedbfcf831c321c30c403a50327508ccd 100755 (executable)
@@ -29,15 +29,14 @@ set -e
 
 ctdb_test_init
 
-# We need this for later, so we know how long to run nc for.
-try_command_on_node any $CTDB getvar MonitorInterval
-monitor_interval="${out#*= }"
-#echo "Monitor interval on node $test_node is $monitor_interval seconds."
-
 select_test_node_and_ips
 try_command_on_node $test_node "$CTDB listnodes | wc -l"
 numnodes="$out"
 
+# We need this for later, so we know how long to run nc for.
+ctdb_onnode "$test_node" "getvar MonitorInterval"
+monitor_interval="${out#*= }"
+
 test_port=2049
 
 echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with netcat..."
index 5ab8a34faecb8121ff0950bf395a0c5e6c6ae59a..b81510d372298000980b9116264ead1aee5b3073 100755 (executable)
@@ -27,11 +27,6 @@ set -e
 
 ctdb_test_init
 
-# We need this for later, so we know how long to run nc for.
-try_command_on_node any $CTDB getvar MonitorInterval
-monitor_interval="${out#*= }"
-#echo "Monitor interval on node $test_node is $monitor_interval seconds."
-
 select_test_node_and_ips
 try_command_on_node $test_node "$CTDB listnodes -X"
 listnodes_output="$out"
index 20faa3aa03b86ada6d02a1fdcddacdd907d7aabf..aeb974028e65b997ce413effe94800169f566bda 100755 (executable)
@@ -92,7 +92,7 @@ check_readonly ()
 ######################################################################
 
 echo "Get list of nodes..."
-try_command_on_node any $CTDB -X listnodes
+ctdb_onnode 0 "-X listnodes"
 all_nodes=$(awk -F'|' '{print $2}' "$outfile")
 
 ######################################################################
index e523e835de70b19a9d518b407fa829ef705e3f72..ffe322037f57b104e659527f41b8b5ddd23e0d23 100755 (executable)
@@ -38,7 +38,7 @@ status=0
 
 # Make sure node 0 is not the recovery master
 echo "find out which node is recmaster"
-try_command_on_node any $CTDB recmaster
+ctdb_onnode 0 recmaster
 recmaster="$out"
 if [ "$recmaster" = "0" ]; then
     echo "node 0 is recmaster, disable recmasterrole on node 0"
@@ -56,7 +56,7 @@ if [ "$recmaster" = "0" ]; then
     try_command_on_node 0 $CTDB continue
     wait_until_node_has_status 0 notstopped
 
-    try_command_on_node any $CTDB recmaster
+    ctdb_onnode 0 recmaster
     recmaster="$out"
     if [ "$recmaster" = "0" ]; then
        echo "failed to move recmaster to different node"
index 829b83930dacd008da12f65237c50055d294f7fd..a3bb3af648041f9d2ca46c33902cc51a699c356e 100755 (executable)
@@ -33,7 +33,7 @@ do_ctdb_reloadips ()
        local retry_max=10
        local retry_count=0
        while : ; do
-               if try_command_on_node any "$CTDB reloadips all" ; then
+               if ctdb_onnode "$test_node" "reloadips all" ; then
                        return 0
                fi
 
@@ -73,7 +73,7 @@ GOOD: node $test_node is no longer hosting IP $test_ip:
 $out
 EOF
 
-try_command_on_node any $CTDB sync
+ctdb_onnode "$test_node" sync
 
 
 echo "Restoring addresses"
@@ -94,7 +94,7 @@ GOOD: node $test_node has these addresses:
 $out
 EOF
 
-try_command_on_node any $CTDB sync
+ctdb_onnode "$test_node" sync
 
 
 echo "Emptying public addresses file on $test_node"
index 488243d62601053b131f4b70ca11d7cee7472bd3..77f9a63e589c4c9986f28fe1564156fcadddec3b 100755 (executable)
@@ -16,8 +16,13 @@ ctdb_test_init -n
 echo "Starting CTDB with failover disabled..."
 ctdb_nodes_start_custom -F
 
+select_test_node
+
 echo "Getting IP allocation..."
-try_command_on_node -v any "$CTDB ip all | tail -n +2"
+
+# $test_node set above by select_test_node()
+# shellcheck disable=SC2154
+try_command_on_node -v "$test_node" "$CTDB ip all | tail -n +2"
 
 while read ip pnn ; do
        if [ "$pnn" != "-1" ] ; then
@@ -33,7 +38,7 @@ echo "Starting CTDB with an empty public addresses configuration..."
 ctdb_nodes_start_custom -P /dev/null
 
 echo "Trying explicit ipreallocate..."
-try_command_on_node any $CTDB ipreallocate
+ctdb_onnode "$test_node" ipreallocate
 
 echo "Good, that seems to work!"
 echo
index 68b5e079d66f31afd89de8b7e1044ee0e30e771d..8daf3f516741d68e2405444af357bdb6fbc67310 100755 (executable)
@@ -40,7 +40,10 @@ sanity_check_ips ()
 sanity_check_ips
 
 # Find a target node - it must be willing to host $test_ip
-try_command_on_node any "$CTDB listnodes | wc -l"
+
+# $test_node set above by select_test_node_and_ips()
+# shellcheck disable=SC2154
+try_command_on_node "$test_node" "$CTDB listnodes | wc -l"
 num_nodes="$out"
 to_node=""
 for i in $(seq 0 $(($num_nodes - 1)) ) ; do