ctdb-tests: Add tests for PID with srvid
authorAmitay Isaacs <amitay@gmail.com>
Wed, 30 Aug 2017 06:35:49 +0000 (16:35 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 21 Sep 2017 10:56:30 +0000 (12:56 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Sep 21 12:56:30 CEST 2017 on sn-devel-144

ctdb/tests/simple/07_ctdb_process_exists.sh
ctdb/tests/tool/ctdb.process-exists.002.sh [new file with mode: 0755]

index f24e93a47ad4c0e0d6438c1225e49e8559919b90..b3b8e513741f6eb9384b2a42f03b22ad6b7efd4c 100755 (executable)
@@ -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 (executable)
index 0000000..fe3dfd4
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "ctdbd process on node 0"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+srvid="0xaebbccdd12345678"
+
+dummy_client -d INFO -s "$ctdbd_socket" -S "$srvid" &
+pid=$!
+
+srvid2="0x1234567812345678"
+required_result 1 "PID $pid with SRVID $srvid2 does not exist"
+simple_test "$pid" "$srvid2"
+
+ok "PID $pid with SRVID $srvid exists"
+simple_test "$pid" "$srvid"
+
+kill -9 $pid