]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Rationalise node stop/start/restart
authorMartin Schwenke <martin@meltin.net>
Wed, 11 Dec 2019 10:44:28 +0000 (21:44 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 18 Feb 2020 02:56:38 +0000 (02:56 +0000)
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>
ctdb/tests/CLUSTER/complex/34_nfs_tickle_restart.sh
ctdb/tests/INTEGRATION/database/basics.002.attach.sh
ctdb/tests/INTEGRATION/simple/cluster.091.version_check.sh
ctdb/tests/scripts/integration.bash
ctdb/tests/scripts/integration_local_daemons.bash
ctdb/tests/scripts/integration_real_cluster.bash

index 04d87af1b2ec1382fece6e14fe81724b555981b5..5ab8a34faecb8121ff0950bf395a0c5e6c6ae59a 100755 (executable)
@@ -59,7 +59,7 @@ rn=$(awk -F'|' -v test_node=$test_node \
     '$2 != test_node { print $2 ; exit }' <<<"$listnodes_output")
 
 echo "Restarting CTDB on node ${rn}"
-restart_ctdb_1 $rn
+ctdb_nodes_restart "$rn"
 
 # In some theoretical world this is racy.  In practice, the node will
 # take quite a while to become healthy, so this will beat any
index b9ae9481d91bcbea1b0ac497504518102ad6267b..ae09741f98028f1150c8c46827868380a4329333 100755 (executable)
@@ -86,7 +86,7 @@ testdb3="test_replicated.tdb"
 test_node="0"
 
 echo "Shutting down node $test_node"
-stop_ctdb_1 "$test_node"
+ctdb_nodes_stop "$test_node"
 sleep 1
 wait_until_node_has_status 1 recovered
 try_command_on_node -v 1 $CTDB status
@@ -110,7 +110,7 @@ done
 
 echo
 echo "Start node $test_node"
-start_ctdb_1 "$test_node"
+ctdb_nodes_start "$test_node"
 sleep 1
 wait_until_ready
 
@@ -124,7 +124,7 @@ check_db $test_node $testdb3 REPLICATED
 
 echo
 echo "Restarting node $test_node"
-restart_ctdb_1 "$test_node"
+ctdb_nodes_restart "$test_node"
 sleep 1
 wait_until_ready
 
index 4076047a8fe285a0da5d3d53fc71de05716cd07c..fa934e8bef1d55db65944af15edbc37be6d7ad47 100755 (executable)
@@ -33,7 +33,7 @@ export CTDB_TEST_SAMBA_VERSION=$(( (major << 16) | minor ))
 printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
        "$test_node" \
        "$CTDB_TEST_SAMBA_VERSION"
-restart_ctdb_1 "$test_node"
+ctdb_nodes_restart "$test_node"
 wait_until_ready
 echo "GOOD: ctdbd restarted successfully on node ${test_node}"
 
@@ -46,7 +46,7 @@ export CTDB_TEST_SAMBA_VERSION=$(( ((major + 1) << 16) | minor ))
 printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
        "$test_node" \
        "$CTDB_TEST_SAMBA_VERSION"
-restart_ctdb_1 "$test_node"
+ctdb_nodes_restart "$test_node"
 echo "Will use PID file ${pidfile} to check for ctdbd exit"
 wait_until 30 ! test -f "$pidfile"
 echo "GOOD: ctdbd exited early on node ${test_node}"
@@ -56,7 +56,7 @@ export CTDB_TEST_SAMBA_VERSION=$(( (major << 16) | (minor + 1) ))
 printf '\nRestarting node %d with CTDB_TEST_SAMBA_VERSION=0x%08x\n' \
        "$test_node" \
        "$CTDB_TEST_SAMBA_VERSION"
-start_ctdb_1 "$test_node"
+ctdb_nodes_start "$test_node"
 echo "Will use PID file ${pidfile} to check for ctdbd exit"
 wait_until 30 ! test -f "$pidfile"
 echo "GOOD: ctdbd exited early on node ${test_node}"
index 51e9c7cb82216775c801e36aa4a7ca1c82c9deaa..adf8d0363cf4edd17f7c8fa511e5d7fefc6c387b 100644 (file)
@@ -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"
 
index 9850ad2208cf1def4b81499a6e3172b2e3a35665..a2b4e2aee67452d9e7baf722a2750d9c7c37818d 100644 (file)
@@ -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 ()
index 455f1431b986224e61624aa87fd58f692c46119d..8d3f68a0b2ca629fa3e56cc0471c699ea4cae660 100644 (file)
@@ -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
 }