ctdb-tests: Make fake ssh script set CTDB_BASE
authorMartin Schwenke <martin@meltin.net>
Fri, 2 Mar 2018 09:36:39 +0000 (20:36 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 9 Mar 2018 06:08:25 +0000 (07:08 +0100)
The local daemons code puts the socket in the CTDB_BASE directory.
This means CTDB_NODES_SOCKETS can be replaced by CTDB_BASES, a list of
base directories.  The fake ssh script can first determine the correct
CTDB_BASE directory and then use it to set CTDB_SOCKET and
CTDB_PIDFILE.

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

index 2a4704b21dc75f4f6bfc5c75bf8ec508ba4a6bb2..a0fae2a32d4b5bda95c21652e66ac720a11951df 100644 (file)
@@ -301,14 +301,14 @@ ps_ctdbd ()
        echo
 }
 
-# onnode will use CTDB_NODES_SOCKETS to help the ctdb tool connection
-# to each daemon
-export CTDB_NODES_SOCKETS=""
+# onnode will use CTDB_BASES to help the ctdb tool connection to each
+# daemon
+export CTDB_BASES=""
 for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
-    socket=$(node_socket "$i")
-    CTDB_NODES_SOCKETS="${CTDB_NODES_SOCKETS}${CTDB_NODES_SOCKETS:+ }${socket}"
+       node_dir=$(node_dir "$i")
+       CTDB_BASES="${CTDB_BASES}${CTDB_BASES:+ }${node_dir}"
 done
 
 # Need a default CTDB_BASE for onnode (to find the functions file).
 # Any node will do, so pick the 1st...
-export CTDB_BASE=$(node_dir 0)
+export CTDB_BASE="${CTDB_BASES%% *}"
index ecf5ee952f22ea83db9cae833018bcea66ee2cd6..f0c364c36dbcd662c33226d0279b7a209ca8e3c6 100755 (executable)
@@ -23,20 +23,24 @@ command="$2"
 num=$(awk -v ip="$ip" '$1 == ip { print NR }' "$nodes")
 pnn=$((num - 1))
 
-# Determine the correct Unix domain socket
-export CTDB_SOCKET=""
+# Determine the correct CTDB base directory
+export CTDB_BASE=""
 n=0
-for s in $CTDB_NODES_SOCKETS ; do
+for b in $CTDB_BASES ; do
        if [ $n -eq $pnn ] ; then
-               CTDB_SOCKET="$s"
+               CTDB_BASE="$b"
                break
        fi
        n=$((n + 1))
 done
-if [ -z "$CTDB_SOCKET" ] ; then
-       echo "$0: Unable to find socket for node ${ip}" >&2
+
+if [ -z "$CTDB_BASE" ] ; then
+       echo "$0: Unable to find base for node ${ip}" >&2
        exit 1
 fi
 
+export CTDB_SOCKET="${CTDB_BASE}/ctdbd.socket"
+export CTDB_PIDFILE="${CTDB_BASE}/ctdbd.pid"
+
 # Now
 exec sh -c "$command"