ctdb-tests: Add function ctdb_test_on_cluster()
authorMartin Schwenke <martin@meltin.net>
Wed, 2 Oct 2019 05:08:18 +0000 (15:08 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 4 Oct 2019 09:41:28 +0000 (09:41 +0000)
This centralises this logic.  Use it in a subset of tests - there are
other cases but these will be cleaned up soon.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/INTEGRATION/failover/pubips.001.list.sh
ctdb/tests/INTEGRATION/failover/pubips.050.missing_ip.sh
ctdb/tests/scripts/integration.bash

index d9fdd28f77543e26078fbf9d6df7b6f3660b1bf3..d8e0097362fbd6256da43d3e15e50ff32f6058e1 100755 (executable)
@@ -43,7 +43,7 @@ machineout=$(sed -r \
        -e 's@\]@@g' \
        "$outfile")
 
-if [ -z "$TEST_LOCAL_DAEMONS" ]; then
+if ctdb_test_on_cluster ; then
        while read ip pnn ; do
                try_command_on_node $pnn "ip addr show to ${ip}"
                if [ -n "$out" ] ; then
index 5b11f9f38851f79f844abe5f69097142cff5241e..c455784c8862a8ea02406c5967590daaca333fb8 100755 (executable)
@@ -35,7 +35,7 @@ try_command_on_node -v all $CTDB ip
 
 my_exit_hook ()
 {
-    if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+    if ctdb_test_on_cluster ; then
        onnode -q all $CTDB event script enable legacy "10.interface"
     fi
 }
@@ -50,7 +50,7 @@ try_command_on_node $test_node $CTDB sync
 # in the middle of a monitor event and will have the expected effect.
 wait_for_monitor_event $test_node
 
-if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+if ctdb_test_on_cluster ; then
     # Stop monitor events from bringing up the link status of an interface
     try_command_on_node $test_node $CTDB event script disable legacy 10.interface
 fi
index 9142cf5701c9a8843fc6ea23fb071cc6f8ff4bb8..c8a1b760835d0403d321d8a791b8eb1df56014dd 100644 (file)
@@ -23,6 +23,11 @@ PATH="${TEST_SCRIPTS_DIR}:${PATH}"
 
 ######################################################################
 
+ctdb_test_on_cluster ()
+{
+       [ -z "$TEST_LOCAL_DAEMONS" ]
+}
+
 ctdb_test_exit ()
 {
     local status=$?
@@ -217,7 +222,7 @@ get_test_ip_mask_and_iface ()
     try_command_on_node $test_node "$CTDB ip -v -X | awk -F'|' -v ip=$test_ip '\$2 == ip { print \$4 }'"
     iface="$out"
 
-    if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+    if ctdb_test_on_cluster ; then
        # Find the netmask
        try_command_on_node $test_node ip addr show to $test_ip
        mask="${out##*/}"
@@ -662,7 +667,7 @@ db_ctdb_tstore_dbseqnum ()
 # Make sure that $CTDB is set.
 : ${CTDB:=ctdb}
 
-if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+if ctdb_test_on_cluster ; then
        . "${TEST_SCRIPTS_DIR}/integration_real_cluster.bash"
 else
        . "${TEST_SCRIPTS_DIR}/integration_local_daemons.bash"