1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
samba-mirror/ctdb/tests/simple/06_ctdb_getpid.sh
Martin Schwenke 5d50f5a91c New test 09_ctdb_ping.sh. Add documentation and command-line
processing to all tests.  New script ctdb_test_env sets up environment
for tests, is now sourced by run_tests, and can also take a test on
the command-line, complete with options.  Various cleanups and
improvements.  Document tests that have been properly implemented in
ctdbd.sh.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 826e85fe5291067b8d0b9c22918d63024aa6141c)
2008-11-24 17:47:09 +11:00

94 lines
1.9 KiB
Bash
Executable File

#!/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.
4. Verify that with the '-n all' option the command shows the PIDs on
all the nodes
Expected results:
* 'ctdb getpid' shows valid output.
EOF
}
. ctdb_test_functions.bash
ctdb_test_init "$@"
set -e
onnode 0 $TEST_WRAP cluster_is_healthy
# This is an attempt at being independent of the number of nodes
# reported by "ctdb getpid -n all".
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.
cmd="onnode -q all ctdb getpid"
try_command_on_node 1 "$cmd"
pids_onnode="$out"
echo "Results from \"$cmd\":"
echo "$pids_onnode"
cmd="onnode -q 1 ctdb getpid -n all"
try_command_on_node 1 "$cmd"
pids_getpid_all="$out"
echo "Results from \"$cmd\":"
echo "$pids_getpid_all"
cmd=""
n=0
while [ $n -lt $num_nodes ] ; do
cmd="${cmd}${cmd:+; }ctdb getpid -n $n"
n=$(($n + 1))
done
try_command_on_node 1 "$cmd"
pids_getpid_n="$out"
echo "Results from \"$cmd\":"
echo "$pids_getpid_n"
if [ "$pids_onnode" = "$pids_getpid_all" -a \
"$pids_getpid_all" = "$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 line
pid=${line#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!"
else
echo "BAD!"
testfailures=1
fi
n=$(($n + 1))
done <<<"$pids_onnode"
ctdb_test_exit