From 49262a6bc4d5f8b81aa341294bfe04a22a6b32b6 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Sun, 29 Sep 2019 08:27:33 +1000 Subject: ctdb-tests: Add handling of process clean-up on a cluster node Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/tests/scripts/integration.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'ctdb') diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index bbb3a64ea5a..d5bd542ab00 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -60,6 +60,34 @@ ctdb_test_exit_hook_add () ctdb_test_exit_hook="${ctdb_test_exit_hook}${ctdb_test_exit_hook:+ ; }$*" } +# Setting cleanup_pid to @ will cause to be killed on +# when the test completes. To cancel, just unset cleanup_pid. +ctdb_test_cleanup_pid="" +ctdb_test_cleanup_pid_exit_hook () +{ + if [ -n "$ctdb_test_cleanup_pid" ] ; then + local pid="${ctdb_test_cleanup_pid%@*}" + local node="${ctdb_test_cleanup_pid#*@}" + + try_command_on_node "$node" "kill ${pid}" + fi +} + +ctdb_test_exit_hook_add ctdb_test_cleanup_pid_exit_hook + +ctdb_test_cleanup_pid_set () +{ + local node="$1" + local pid="$2" + + ctdb_test_cleanup_pid="${pid}@${node}" +} + +ctdb_test_cleanup_pid_clear () +{ + ctdb_test_cleanup_pid="" +} + ctdb_test_init () { trap "ctdb_test_exit" 0 -- cgit v1.2.1