ctdb-tests: Add functions to start/stop/restart a single local daemon
authorAmitay Isaacs <amitay@gmail.com>
Fri, 18 Aug 2017 04:45:30 +0000 (14:45 +1000)
committerKarolin Seeger <kseeger@samba.org>
Mon, 28 Aug 2017 09:04:16 +0000 (11:04 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12978

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 9691b72a8785c2bc2561bd6c897fea3c0cc2cbeb)

ctdb/tests/simple/scripts/local_daemons.bash

index d7f33b6804e4b1b8cbc6bff65f79b464f0f601d3..b702a3e659f0959f97dff359eeb790f229b75798 100644 (file)
@@ -172,12 +172,9 @@ EOF
     done
 }
 
-daemons_start ()
+start_ctdb_1 ()
 {
-    echo "Starting $TEST_LOCAL_DAEMONS ctdb daemons..."
-
-    local pnn
-    for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
+       local pnn="$1"
        local pidfile=$(node_pidfile "$pnn")
        local conf=$(node_conf "$pnn")
 
@@ -200,25 +197,47 @@ daemons_start ()
        if [ -n "$tmp_conf" ] ; then
                rm -f "$tmp_conf"
        fi
-    done
+
 }
 
-daemons_stop ()
+daemons_start ()
 {
-    echo "Stopping $TEST_LOCAL_DAEMONS ctdb daemons..."
+    echo "Starting $TEST_LOCAL_DAEMONS ctdb daemons..."
 
     local pnn
     for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
+       start_ctdb_1 "$pnn"
+    done
+}
+
+stop_ctdb_1 ()
+{
+       local pnn="$1"
        local pidfile=$(node_pidfile "$pnn")
        local conf=$(node_conf "$pnn")
 
        CTDBD_CONF="$conf" \
             ctdbd_wrapper "$pidfile" stop
+}
+
+daemons_stop ()
+{
+    echo "Stopping $TEST_LOCAL_DAEMONS ctdb daemons..."
+
+    local pnn
+    for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
+       stop_ctdb_1 "$pnn"
     done
 
     rm -rf "${TEST_VAR_DIR}/test.db"
 }
 
+restart_ctdb_1 ()
+{
+       stop_ctdb_1 "$1"
+       start_ctdb_1 "$1"
+}
+
 maybe_stop_ctdb ()
 {
     if $TEST_CLEANUP ; then