From: Martin Schwenke Date: Sat, 3 Mar 2018 09:04:17 +0000 (+1100) Subject: ctdb-tests: Rework simple tests daemon start/stop X-Git-Tag: talloc-2.1.12~222 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=914c877860ecc19f4375eab031fdd2a33bd6ded6;p=thirdparty%2Fsamba.git ctdb-tests: Rework simple tests daemon start/stop 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index b627c3e1162..7a1938ed50c 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -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 } diff --git a/ctdb/tests/simple/00_ctdb_init.sh b/ctdb/tests/simple/00_ctdb_init.sh index bd15fd7ed6e..66b42ddc561 100755 --- a/ctdb/tests/simple/00_ctdb_init.sh +++ b/ctdb/tests/simple/00_ctdb_init.sh @@ -28,5 +28,8 @@ ctdb_test_init "$@" set -e +ctdb_stop_all >/dev/null 2>&1 || true + setup_ctdb -restart_ctdb + +ctdb_start_all diff --git a/ctdb/tests/simple/scripts/local_daemons.bash b/ctdb/tests/simple/scripts/local_daemons.bash index e89f1ffe7cc..d081ab66215 100644 --- a/ctdb/tests/simple/scripts/local_daemons.bash +++ b/ctdb/tests/simple/scripts/local_daemons.bash @@ -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 ()