diff options
author | Martin Schwenke <martin@meltin.net> | 2019-12-11 21:44:28 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2020-02-18 02:56:38 +0000 |
commit | dc076b835f30b1067155e2f440a3386331d15b5a (patch) | |
tree | c239ed8bb5f000ed28990d6d5f1d8f76ee3eb673 /ctdb/tests/scripts | |
parent | a20403adf871d2c1a646be0737935f85b55f8779 (diff) | |
download | samba-dc076b835f30b1067155e2f440a3386331d15b5a.tar.gz |
ctdb-tests: Rationalise node stop/start/restart
Separate functions are not needed for stopping/starting/restarting
individual nodes. The stop and start functions essentially just use
onnode, though for local daemons this is embedded in local_daemons.sh.
So, just provide one stop and one start function that takes an
optional nodespec, defaulting to all nodes.
Restarting becomes common.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests/scripts')
-rw-r--r-- | ctdb/tests/scripts/integration.bash | 15 | ||||
-rw-r--r-- | ctdb/tests/scripts/integration_local_daemons.bash | 28 | ||||
-rw-r--r-- | ctdb/tests/scripts/integration_real_cluster.bash | 23 |
3 files changed, 23 insertions, 43 deletions
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index 51e9c7cb822..adf8d0363cf 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -50,7 +50,7 @@ ctdb_test_exit () unset ctdb_test_exit_hook echo "Stopping cluster..." - ctdb_stop_all + ctdb_nodes_stop exit $status } @@ -92,7 +92,7 @@ ctdb_test_init () { trap "ctdb_test_exit" 0 - ctdb_stop_all >/dev/null 2>&1 || true + ctdb_nodes_stop >/dev/null 2>&1 || true echo "Configuring cluster..." setup_ctdb "$@" || exit 1 @@ -111,6 +111,13 @@ ctdb_test_skip_on_cluster () fi } + +ctdb_nodes_restart () +{ + ctdb_nodes_stop "$@" + ctdb_nodes_start "$@" +} + ######################################## # Sets: $out, $outfile @@ -568,9 +575,9 @@ wait_until_node_has_no_ips () ctdb_init () { - ctdb_stop_all >/dev/null 2>&1 || : + ctdb_nodes_stop >/dev/null 2>&1 || : - ctdb_start_all || ctdb_test_error "Cluster start failed" + ctdb_nodes_start || ctdb_test_error "Cluster start failed" wait_until_ready || ctdb_test_error "Cluster didn't become ready" diff --git a/ctdb/tests/scripts/integration_local_daemons.bash b/ctdb/tests/scripts/integration_local_daemons.bash index 9850ad2208c..a2b4e2aee67 100644 --- a/ctdb/tests/scripts/integration_local_daemons.bash +++ b/ctdb/tests/scripts/integration_local_daemons.bash @@ -45,34 +45,18 @@ setup_ctdb () fi } -start_ctdb_1 () +ctdb_nodes_start () { - local pnn="$1" + local nodespec="${1:-all}" - $ctdb_local_daemons start "$pnn" + $ctdb_local_daemons start "$nodespec" } -ctdb_start_all () +ctdb_nodes_stop () { - $ctdb_local_daemons start "all" -} - -stop_ctdb_1 () -{ - local pnn="$1" - - $ctdb_local_daemons stop "$pnn" -} + local nodespec="${1:-all}" -ctdb_stop_all () -{ - $ctdb_local_daemons stop "all" -} - -restart_ctdb_1 () -{ - stop_ctdb_1 "$1" - start_ctdb_1 "$1" + $ctdb_local_daemons stop "$nodespec" } onnode () diff --git a/ctdb/tests/scripts/integration_real_cluster.bash b/ctdb/tests/scripts/integration_real_cluster.bash index 455f1431b98..8d3f68a0b2c 100644 --- a/ctdb/tests/scripts/integration_real_cluster.bash +++ b/ctdb/tests/scripts/integration_real_cluster.bash @@ -39,26 +39,15 @@ _service_ctdb () } # Stop/start CTDB on all nodes. Override for local daemons. -ctdb_stop_all () +ctdb_nodes_stop () { - onnode -p all "$CTDB_TEST_WRAPPER" _service_ctdb stop -} -ctdb_start_all () -{ - onnode -p all "$CTDB_TEST_WRAPPER" _service_ctdb start -} + local nodespec="${1:-all}" -start_ctdb_1 () -{ - onnode "$1" "$CTDB_TEST_WRAPPER" _service_ctdb start + onnode -p "$nodespec" "$CTDB_TEST_WRAPPER" _service_ctdb stop } - -stop_ctdb_1 () +ctdb_nodes_start () { - onnode "$1" "$CTDB_TEST_WRAPPER" _service_ctdb stop -} + local nodespec="${1:-all}" -restart_ctdb_1 () -{ - onnode "$1" "$CTDB_TEST_WRAPPER" _service_ctdb restart + onnode -p "$nodespec" "$CTDB_TEST_WRAPPER" _service_ctdb start } |