summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-08-29 16:49:07 +1000
committerStefan Metzmacher <metze@samba.org>2016-09-06 08:22:18 +0200
commitaf2386bdc2f0b69acb65701f15352ea14c0f0051 (patch)
tree92a287244cbe692f7b98a5e314b6e5d27702275d
parent7e0846a3b9dddc1adec11f04912cc2d3249d394c (diff)
downloadsamba-af2386bdc2f0b69acb65701f15352ea14c0f0051.tar.gz
ctdb-tests: Conditionally use temporary config file for local daemons
If there's configuration in the environment then daemons_start() should use a temporary configuration file with that appended. This means that global overrides don't (harmlessly) build up in the configuration file during each test and individual tests can override configuration when calling daemons_start() directly. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12180 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit 7885b9652fcb3b30361a8b2e0b4688c261b55065)
-rw-r--r--ctdb/tests/simple/scripts/local_daemons.bash16
1 files changed, 16 insertions, 0 deletions
diff --git a/ctdb/tests/simple/scripts/local_daemons.bash b/ctdb/tests/simple/scripts/local_daemons.bash
index 022bbf8880a..fb1e7e1cd5f 100644
--- a/ctdb/tests/simple/scripts/local_daemons.bash
+++ b/ctdb/tests/simple/scripts/local_daemons.bash
@@ -123,9 +123,25 @@ daemons_start ()
local pidfile="${TEST_VAR_DIR}/ctdbd.${pnn}.pid"
local conf="${TEST_VAR_DIR}/ctdbd.${pnn}.conf"
+ # If there is any CTDB configuration in the environment then
+ # append it to the regular configuration in a temporary
+ # configuration file and use it just this once.
+ local tmp_conf=""
+ local env_conf=$(config_from_environment)
+ if [ -n "$env_conf" ] ; then
+ tmp_conf=$(mktemp --tmpdir="$TEST_VAR_DIR")
+ cat "$conf" >"$tmp_conf"
+ echo "$env_conf" >>"$tmp_conf"
+ conf="$tmp_conf"
+ fi
+
CTDBD="${VALGRIND} ctdbd --sloppy-start --nopublicipcheck" \
CTDBD_CONF="$conf" \
ctdbd_wrapper "$pidfile" start
+
+ if [ -n "$tmp_conf" ] ; then
+ rm -f "$tmp_conf"
+ fi
done
}