ctdb-tests: Start daemons in ctdb_test_init(), stop them in ctdb_test_exit()
authorMartin Schwenke <martin@meltin.net>
Mon, 8 Oct 2018 02:30:55 +0000 (13:30 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 6 Nov 2018 06:16:16 +0000 (07:16 +0100)
This makes tests self-contained.  They can also now be individually
looped, if necessary.

Most tests (all but 1 complex, more than 50% of simple) restart the
daemons anyway, so this simplification is worth it.

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

index 25363d3c1940890e163fbba2bbb95ca8de7a9d61..fdfa714fe87e499d6a30f76a960fb04fc219dce0 100644 (file)
@@ -44,22 +44,8 @@ ctdb_test_exit ()
     eval "$ctdb_test_exit_hook" || true
     unset ctdb_test_exit_hook
 
-    if $ctdb_test_restart_scheduled || ! cluster_is_healthy ; then
-       echo "Restarting CTDB (scheduled)..."
-       ctdb_stop_all || true  # Might be restarting some daemons were shutdown
-
-       echo "Reconfiguring cluster..."
-       setup_ctdb
-
-       ctdb_init
-    else
-       # This could be made unconditional but then we might get
-       # duplication from the recovery in ctdb_init().  We want to
-       # leave the recovery in ctdb_init() so that future tests that
-       # might do a manual restart mid-test will benefit.
-       echo "Forcing a recovery..."
-       onnode 0 $CTDB recover
-    fi
+    echo "Stopping cluster..."
+    ctdb_stop_all
 
     exit $status
 }
@@ -71,9 +57,19 @@ ctdb_test_exit_hook_add ()
 
 ctdb_test_init ()
 {
-    ctdb_test_restart_scheduled=false
+       ctdb_test_restart_scheduled=false
+
+       trap "ctdb_test_exit" 0
+
+       ctdb_stop_all >/dev/null 2>&1 || true
+
+       echo "Configuring cluster..."
+       setup_ctdb || exit 1
+
+       echo "Starting cluster..."
+       ctdb_init || exit 1
 
-    trap "ctdb_test_exit" 0
+       echo  "*** SETUP COMPLETE AT $(date '+%F %T'), RUNNING TEST..."
 }
 
 ########################################