1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ctdb-tests: Reimplement daemons_stop() using ctdbd_wrapper

The current daemons_stop() implementation uses very loose matching to
decide which processes to kill if "ctdb shutdown" hasn't worked within
1 second.  This can cause ctdbd processes from other test runs to be
killed.

Instead, use ctdbd_wrapper, which uses the PID file as a last resort.
This has the advantage of never killing ctdbd processes from other
test runs.  However, this also has the obvious consequence that an
interrupted test run in one directory can not have its daemons cleaned
up from a new test run in a different directory.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12170

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue Aug 23 21:17:46 CEST 2016 on sn-devel-144

(cherry picked from commit 17dfd8b96bc1750a2f435caa1d208766257346f3)

Autobuild-User(v4-5-test): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(v4-5-test): Wed Aug 24 15:35:51 CEST 2016 on sn-devel-144
This commit is contained in:
Martin Schwenke 2016-08-23 11:49:54 +10:00 committed by Stefan Metzmacher
parent c0dba4948c
commit eb55718e1b

View File

@ -22,28 +22,6 @@ export CTDB_NODES="${TEST_VAR_DIR}/nodes.txt"
#######################################
daemons_stop ()
{
echo "Attempting to politely shutdown daemons..."
onnode -q all $CTDB shutdown || true
echo "Sleeping for a while..."
sleep_for 1
local pat="ctdbd --sloppy-start --nopublicipcheck"
if pgrep -f "$pat" >/dev/null ; then
echo "Killing remaining daemons..."
pkill -f "$pat"
if pgrep -f "$pat" >/dev/null ; then
echo "Once more with feeling.."
pkill -9 -f "$pat"
fi
fi
rm -rf "${TEST_VAR_DIR}/test.db"
}
setup_ctdb ()
{
mkdir -p "${TEST_VAR_DIR}/test.db/persistent"
@ -138,14 +116,28 @@ daemons_start ()
local pidfile="${TEST_VAR_DIR}/ctdbd.${pnn}.pid"
local conf="${TEST_VAR_DIR}/ctdbd.${pnn}.conf"
# We'll use "pkill -f" to kill the daemons with
# "ctdbd --sloppy-start --nopublicipcheck" as context.
CTDBD="${VALGRIND} ctdbd --sloppy-start --nopublicipcheck" \
CTDBD_CONF="$conf" \
ctdbd_wrapper "$pidfile" start
done
}
daemons_stop ()
{
echo "Stopping $TEST_LOCAL_DAEMONS ctdb daemons..."
local pnn
for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
local pidfile="${TEST_VAR_DIR}/ctdbd.${pnn}.pid"
local conf="${TEST_VAR_DIR}/ctdbd.${pnn}.conf"
CTDBD_CONF="$conf" \
ctdbd_wrapper "$pidfile" stop
done
rm -rf "${TEST_VAR_DIR}/test.db"
}
maybe_stop_ctdb ()
{
if $TEST_CLEANUP ; then