summaryrefslogtreecommitdiff
path: root/ctdb/tests/simple/06_ctdb_getpid.sh
blob: 21a6e552e55c204e04bd4573df5c605a0b901cde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash

test_info()
{
    cat <<EOF
Verify that 'ctdb getpid' works as expected.

Prerequisites:

* An active CTDB cluster with at least 2 active nodes.

Steps:

1. Verify that the status on all of the ctdb nodes is 'OK'.
2. Run 'ctdb getpid -n <number>' on the nodes to check the PID of the
   ctdbd process.
3. Verify that the output is valid.

Expected results:

* 'ctdb getpid' shows valid output.
EOF
}

. "${TEST_SCRIPTS_DIR}/integration.bash"

ctdb_test_init "$@"

set -e

cluster_is_healthy

try_command_on_node 0 "$CTDB listnodes | wc -l"
num_nodes="$out"
echo "There are $num_nodes nodes..."

# Call getpid a few different ways and make sure the answer is always the same.

try_command_on_node -v 0 "onnode -q all $CTDB getpid"
pids_onnode="$out"

cmd=""
n=0
while [ $n -lt $num_nodes ] ; do
    cmd="${cmd}${cmd:+; }$CTDB getpid -n $n"
    n=$(($n + 1))
done
try_command_on_node -v 0 "( $cmd )"
pids_getpid_n="$out"

if [ "$pids_onnode" = "$pids_getpid_n" ] ; then
    echo "They're the same... cool!"
else
    echo "Error: they differ."
    testfailures=1
fi

echo "Checking each PID for validity"

n=0
while [ $n -lt $num_nodes ] ; do
    read pid
    try_command_on_node $n "ls -l /proc/${pid}/exe | sed -e 's@.*/@@'"
    echo -n "Node ${n}, PID ${pid} looks to be running \"$out\" - "
    if [ "$out" = "ctdbd" ] ; then
	echo "GOOD!"
    elif [ -n "$VALGRIND" -a "$out" = "memcheck" ] ; then
	# We could check cmdline too if this isn't good enough.
	echo "GOOD enough!"
    else
	echo "BAD!"
	testfailures=1
    fi
    n=$(($n + 1))
done <<<"$pids_onnode"