ctdb-tests: Rework simple tests daemon start/stop
authorMartin Schwenke <martin@meltin.net>
Sat, 3 Mar 2018 09:04:17 +0000 (20:04 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 9 Mar 2018 06:08:24 +0000 (07:08 +0100)
Separate stopping and starting of daemons during restart

This allows actions to be taken after stopping and allows the init
testcase to be clearer about what it is doing.

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

index b627c3e11628ee69f4f0b5b7f8c01e137e722594..7a1938ed50cdbe81e5319616974742e70b791d59 100644 (file)
@@ -42,12 +42,13 @@ ctdb_test_exit ()
     unset ctdb_test_exit_hook
 
     if $ctdb_test_restart_scheduled || ! cluster_is_healthy ; then
-
-       restart_ctdb
+       echo "Restarting CTDB (scheduled)..."
+       ctdb_stop_all || true  # Might be restarting some daemons were shutdown
+       ctdb_start_all
     else
        # This could be made unconditional but then we might get
-       # duplication from the recovery in restart_ctdb.  We want to
-       # leave the recovery in restart_ctdb so that future tests that
+       # duplication from the recovery in ctdb_start_all().  We want to
+       # leave the recovery in ctdb_start_all() so that future tests that
        # might do a manual restart mid-test will benefit.
        echo "Forcing a recovery..."
        onnode 0 $CTDB recover
@@ -487,10 +488,14 @@ _service_ctdb ()
     fi
 }
 
-# Restart CTDB on all nodes.  Override for local daemons.
-_restart_ctdb_all ()
+# Stop/start CTDB on all nodes.  Override for local daemons.
+ctdb_stop_all ()
+{
+       onnode -p all $CTDB_TEST_WRAPPER _service_ctdb stop
+}
+_ctdb_start_all ()
 {
-    onnode -p all $CTDB_TEST_WRAPPER _service_ctdb restart
+       onnode -p all $CTDB_TEST_WRAPPER _service_ctdb start
 }
 
 # Nothing needed for a cluster.  Override for local daemons.
@@ -514,18 +519,12 @@ restart_ctdb_1 ()
     onnode "$1" $CTDB_TEST_WRAPPER _service_ctdb restart
 }
 
-restart_ctdb ()
+ctdb_start_all ()
 {
-    echo -n "Restarting CTDB"
-    if $ctdb_test_restart_scheduled ; then
-       echo -n " (scheduled)"
-    fi
-    echo "..."
-
     local i
     for i in $(seq 1 5) ; do
-       _restart_ctdb_all || {
-           echo "Restart failed.  Trying again in a few seconds..."
+       _ctdb_start_all || {
+           echo "Start failed.  Trying again in a few seconds..."
            sleep_for 5
            continue
        }
index bd15fd7ed6e1f81b1e28fa1fb71098453c3f864a..66b42ddc561ff33e12d723b3995e03bbcb606e66 100755 (executable)
@@ -28,5 +28,8 @@ ctdb_test_init "$@"
 
 set -e
 
+ctdb_stop_all >/dev/null 2>&1 || true
+
 setup_ctdb
-restart_ctdb
+
+ctdb_start_all
index e89f1ffe7cc3cf7ff93cc36a88880fcb388983c9..d081ab66215b7ef50001ae837a7774db78aa4279 100644 (file)
@@ -252,10 +252,14 @@ maybe_stop_ctdb ()
     daemons_stop
 }
 
-_restart_ctdb_all ()
+ctdb_stop_all ()
 {
-    daemons_stop
-    daemons_start
+       daemons_stop
+}
+
+_ctdb_start_all ()
+{
+       daemons_start
 }
 
 ps_ctdbd ()