From 503bc3997800cfb2fd9f7f092ef896c355b844cd Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Wed, 30 Aug 2017 16:35:49 +1000 Subject: [PATCH] ctdb-tests: Add tests for PID with srvid BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Thu Sep 21 12:56:30 CEST 2017 on sn-devel-144 --- ctdb/tests/simple/07_ctdb_process_exists.sh | 20 +++++++++++++++++++- ctdb/tests/tool/ctdb.process-exists.002.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 ctdb/tests/tool/ctdb.process-exists.002.sh diff --git a/ctdb/tests/simple/07_ctdb_process_exists.sh b/ctdb/tests/simple/07_ctdb_process_exists.sh index f24e93a47ad..b3b8e513741 100755 --- a/ctdb/tests/simple/07_ctdb_process_exists.sh +++ b/ctdb/tests/simple/07_ctdb_process_exists.sh @@ -36,11 +36,12 @@ set -e cluster_is_healthy test_node=1 +srvid=0xAE00000012345678 # Execute a ctdb client on $test_node that will last for 60 seconds. # It should still be there when we check. try_command_on_node -v $test_node \ - "$CTDB_TEST_WRAPPER exec dummy_client >/dev/null 2>&1 & echo \$!" + "$CTDB_TEST_WRAPPER exec dummy_client -S ${srvid} >/dev/null 2>&1 & echo \$!" client_pid="$out" cleanup () @@ -65,6 +66,23 @@ else testfailures=1 fi +echo "Checking for PID $client_pid with SRVID $srvid on node $test_node" +status=0 +try_command_on_node $test_node \ + "$CTDB process-exists ${client_pid} ${srvid}" || status=$? +echo "$out" + +if [ $status -eq 0 ] ; then + echo "OK" +else + echo "BAD" + testfailures=1 +fi + +echo "Checking for PID $client_pid with SRVID $client_pid on node $test_node" +try_command_on_node -v $test_node \ + "! $CTDB process-exists ${client_pid} ${client_pid}" + # Now just echo the PID of the ctdb daemon on test node. # This is not a ctdb client and process-exists should return error. try_command_on_node $test_node "ctdb getpid" diff --git a/ctdb/tests/tool/ctdb.process-exists.002.sh b/ctdb/tests/tool/ctdb.process-exists.002.sh new file mode 100755 index 00000000000..fe3dfd4d59f --- /dev/null +++ b/ctdb/tests/tool/ctdb.process-exists.002.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "ctdbd process on node 0" + +setup_ctdbd <