ctdb-tests: Use setup_ctdb_base() for simple tests
authorMartin Schwenke <martin@meltin.net>
Wed, 7 Feb 2018 07:38:04 +0000 (18:38 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 9 Mar 2018 06:08:25 +0000 (07:08 +0100)
The comment in local.bash is incorrect.  CTDB_BASE will never be set
here because this script is not run under onnode.  Instead, this where
CTDB_BASE needs to be set when running against a real cluster.

For local daemons, the check for CTDB_BASE being inconsistent with
node_dir is temporary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/functions [deleted symlink]
ctdb/tests/simple/scripts/local.bash
ctdb/tests/simple/scripts/local_daemons.bash
ctdb/wscript

diff --git a/ctdb/tests/simple/functions b/ctdb/tests/simple/functions
deleted file mode 120000 (symlink)
index ff10411..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../config/functions
\ No newline at end of file
index 2cbf30de257afee71c95674c0a9fdee2acbff6af..7b4a4f030dff29f1e6cfe89d73f8bd6272beabd2 100644 (file)
@@ -6,11 +6,11 @@ export SIMPLE_TESTS_VAR_DIR="${TEST_VAR_DIR}/simple"
 # Don't remove old directory since state is retained between tests
 mkdir -p "$SIMPLE_TESTS_VAR_DIR"
 
-# onnode needs CTDB_BASE to be set when run in-tree
-if [ -z "$CTDB_BASE" ] ; then
-    export CTDB_BASE="$TEST_SUBDIR"
-fi
-
-if [ -n "$TEST_LOCAL_DAEMONS" ] ; then
-    . "${TEST_SUBDIR}/scripts/local_daemons.bash"
+if [ -z "$TEST_LOCAL_DAEMONS" ] ; then
+       # Running against a real cluster
+       setup_ctdb_base "$SIMPLE_TESTS_VAR_DIR" "ctdb-etc" \
+                       functions \
+                       nodes
+else
+       . "${TEST_SUBDIR}/scripts/local_daemons.bash"
 fi
index 1c8b012dfdc5e6741ba0f32e2b75b43bad28f9ef..2a4704b21dc75f4f6bfc5c75bf8ec508ba4a6bb2 100644 (file)
@@ -159,7 +159,13 @@ setup_ctdb ()
        local pnn
        for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
                local node_dir=$(node_dir "$pnn")
-               mkdir -p "$node_dir"
+
+               setup_ctdb_base "$SIMPLE_TESTS_VAR_DIR" "node.${pnn}" \
+                               functions
+
+               if [ "$node_dir" != "$CTDB_BASE" ] ; then
+                       die "Inconsistent CTDB_BASE"
+               fi
 
                local public_addresses="${node_dir}/public_addresses"
 
@@ -202,6 +208,7 @@ EOF
 start_ctdb_1 ()
 {
        local pnn="$1"
+       local node_dir=$(node_dir "$pnn")
        local pidfile=$(node_pidfile "$pnn")
        local conf=$(node_conf "$pnn")
 
@@ -218,6 +225,7 @@ start_ctdb_1 ()
        fi
 
        CTDBD="${VALGRIND} ctdbd --sloppy-start --nopublicipcheck" \
+            CTDB_BASE="$node_dir" \
             CTDBD_CONF="$conf" \
             CTDB_PIDFILE="$pidfile" \
             ctdbd_wrapper start
@@ -240,12 +248,14 @@ daemons_start ()
 stop_ctdb_1 ()
 {
        local pnn="$1"
+       local node_dir=$(node_dir "$pnn")
        local pidfile=$(node_pidfile "$pnn")
        local conf=$(node_conf "$pnn")
 
-       CTDBD_CONF="$conf" \
-                 CTDB_PIDFILE="$pidfile" \
-                 ctdbd_wrapper stop
+       CTDB_BASE="$node_dir" \
+                CTDBD_CONF="$conf" \
+                CTDB_PIDFILE="$pidfile" \
+                ctdbd_wrapper stop
 }
 
 daemons_stop ()
@@ -298,3 +308,7 @@ for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
     socket=$(node_socket "$i")
     CTDB_NODES_SOCKETS="${CTDB_NODES_SOCKETS}${CTDB_NODES_SOCKETS:+ }${socket}"
 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)
index d49f08257c59e31787f0fcac235306617b988e19..065f610b8d9bfb78f77a5bcd2fd33e62a58e8bc0 100644 (file)
@@ -944,15 +944,6 @@ def build(bld):
     bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
                    'ctdb_run_tests')
 
-    # Tests that use onnode need to overwrite link to in-tree
-    # functions file when installed
-    bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple/functions'),
-                   os.path.join(bld.env.CTDB_ETCDIR, 'functions'))
-
-    # Need a link to nodes file because $CTDB_BASE is overridden
-    bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple/nodes'),
-                   os.path.join(bld.env.CTDB_ETCDIR, 'nodes'))
-
 
 def testonly(ctx):
     cmd = 'tests/run_tests.sh -V tests/var'