ldb: Release ldb 1.3.0
[Samba.git] / ctdb / tests / simple / 07_ctdb_process_exists.sh
blob8ccfc69baa99d99bb0eef437e3a9c2288554ede3
1 #!/bin/bash
3 test_info()
5 cat <<EOF
6 Verify that 'ctdb process-exists' shows correct information.
8 The implementation is creative about how it gets PIDs for existing and
9 non-existing processes.
11 Prerequisites:
13 * An active CTDB cluster with at least 2 active nodes.
15 Steps:
17 1. Verify that the status on all of the ctdb nodes is 'OK'.
18 2. On one of the cluster nodes, get the PID of a ctdb client.
19 3. Run 'ctdb process-exists <pid>' on the node and verify that the
20 correct output is shown.
21 4. Run 'ctdb process-exists <pid>' with a pid of ctdb daemon
22 process and verify that the correct output is shown.
24 Expected results:
26 * 'ctdb process-exists' shows the correct output.
27 EOF
30 . "${TEST_SCRIPTS_DIR}/integration.bash"
32 ctdb_test_init "$@"
34 set -e
36 cluster_is_healthy
38 test_node=1
39 srvid=0xAE00000012345678
41 # Execute a ctdb client on $test_node that will last for 60 seconds.
42 # It should still be there when we check.
43 try_command_on_node -v $test_node \
44 "$CTDB_TEST_WRAPPER exec dummy_client -n 10 -S ${srvid} >/dev/null 2>&1 & echo \$!"
45 client_pid="$out"
47 cleanup ()
49 if [ -n "$client_pid" ] ; then
50 onnode $test_node kill -9 "$client_pid"
54 ctdb_test_exit_hook_add cleanup
56 echo "Waiting until PID $client_pid is registered on node $test_node"
57 status=0
58 wait_until 30 try_command_on_node $test_node \
59 "$CTDB process-exists ${client_pid}" || status=$?
60 echo "$out"
62 if [ $status -eq 0 ] ; then
63 echo "OK"
64 else
65 echo "BAD"
66 testfailures=1
69 echo "Checking for PID $client_pid with SRVID $srvid on node $test_node"
70 status=0
71 try_command_on_node $test_node \
72 "$CTDB process-exists ${client_pid} ${srvid}" || status=$?
73 echo "$out"
75 if [ $status -eq 0 ] ; then
76 echo "OK"
77 else
78 echo "BAD"
79 testfailures=1
82 echo "Checking for PID $client_pid with SRVID $client_pid on node $test_node"
83 try_command_on_node -v $test_node \
84 "! $CTDB process-exists ${client_pid} ${client_pid}"
86 # Now just echo the PID of the ctdb daemon on test node.
87 # This is not a ctdb client and process-exists should return error.
88 try_command_on_node $test_node "ctdb getpid"
89 pid="$out"
91 echo "Checking for PID $pid on node $test_node"
92 try_command_on_node -v $test_node "! $CTDB process-exists ${pid}"