]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: Fix ctdb process-exist tests
authorAmitay Isaacs <amitay@gmail.com>
Fri, 25 Aug 2017 06:55:34 +0000 (16:55 +1000)
committerKarolin Seeger <kseeger@samba.org>
Wed, 13 Sep 2017 13:41:13 +0000 (15:41 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13012

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Sat Sep  9 14:44:57 CEST 2017 on sn-devel-144

(cherry picked from commit 87f7d32a906799e83cb9b023978e689a630de017)

ctdb/tests/simple/07_ctdb_process_exists.sh
ctdb/tests/tool/ctdb.process-exists.001.sh

index b7492a84f19b15c2e992b6a876acd0599f1fd4cf..c44924b0fe6e62663f18d62a1977d460dba2204b 100755 (executable)
@@ -15,11 +15,10 @@ Prerequisites:
 Steps:
 
 1. Verify that the status on all of the ctdb nodes is 'OK'.
-2. On one of the cluster nodes, get the PID of an existing process
-   (using ps wax).
+2. On one of the cluster nodes, get the PID of a ctdb client.
 3. Run 'ctdb process-exists <pid>' on the node and verify that the
    correct output is shown.
-4. Run 'ctdb process-exists <pid>' with a pid of a non-existent
+4. Run 'ctdb process-exists <pid>' with a pid of ctdb daemon
    process and verify that the correct output is shown.
 
 Expected results:
@@ -38,15 +37,25 @@ cluster_is_healthy
 
 test_node=1
 
-# Create a background process on $test_node that will last for 60 seconds.
+# 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 $test_node 'sleep 60 >/dev/null 2>&1 & echo $!'
-pid="$out"
+try_command_on_node -v $test_node \
+       "$CTDB_TEST_WRAPPER exec dummy_client >/dev/null 2>&1 & echo \$!"
+client_pid="$out"
 
-echo "Checking for PID $pid on node $test_node"
-# set -e is good, but avoid it here
+cleanup ()
+{
+    if [ -n "$client_pid" ] ; then
+       onnode $test_node kill -9 "$client_pid"
+    fi
+}
+
+ctdb_test_exit_hook_add cleanup
+
+echo "Checking for PID $client_pid on node $test_node"
 status=0
-try_command_on_node $test_node "$CTDB process-exists ${pid}" || status=$?
+try_command_on_node $test_node \
+       "$CTDB process-exists ${client_pid}" || status=$?
 echo "$out"
 
 if [ $status -eq 0 ] ; then
@@ -56,10 +65,9 @@ else
     testfailures=1
 fi
 
-# Now just echo the PID of the shell from the onnode process on node
-# 2.  This PID will disappear and PIDs shouldn't roll around fast
-# enough to trick the test...  but there is a chance that will happen!
-try_command_on_node $test_node 'echo $$'
+# 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"
 pid="$out"
 
 echo "Checking for PID $pid on node $test_node"
index b153da1e1fe51373ca17079b3f9f317e9ef88b8a..2339344fec52e143a524e4aff6c99232b775fc66 100755 (executable)
@@ -11,12 +11,14 @@ NODEMAP
 2       192.168.20.43   0x0
 EOF
 
-pid=$(ctdbd_getpid)
+dummy_client -s $ctdbd_socket &
+pid=$!
 
 ok "PID $pid exists"
 simple_test "$pid"
 
-# Use a PID that is probably impossible.  It must fit into 32 bits but
-# should be larger than most settings for pid_max.
-required_result 1 "PID 99999999 does not exist"
-simple_test "99999999"
+kill -9 $pid
+
+pid=$(ctdbd_getpid)
+required_result 1 "PID $pid does not exist"
+simple_test "$pid"