1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-06 13:18:07 +03:00
samba-mirror/ctdb/tests/INTEGRATION/simple/basics.004.getpid.sh
Martin Schwenke 8b24cae630 ctdb-tests: Update preamble for INTEGRATION tests
* Use "#!/usr/bin/env bash" for improved portability

* Drop test_info() definition and replace it with a comment

  The use of test_info() is pointless.

* Drop call to cluster_is_healthy()

  This is a holdover from when the previous test would restart daemons
  to get things ready for a test.  There was also a bug where going
  into recovery during the restart would sometimes cause the cluster
  to become unhealthy.  If we really need something like this then we
  can add it to ctdb_test_init().

* Make order of preamble consistent

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2020-07-22 07:53:35 +00:00

56 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Verify that 'ctdb getpid' works as expected
. "${TEST_SCRIPTS_DIR}/integration.bash"
set -e
ctdb_test_init
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
die "Error: they differ."
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\" - "
case "$out" in
ctdbd) : ;;
memcheck*)
if [ -z "$VALGRIND" ] ; then
die "BAD"
fi
;;
*) die "BAD"
esac
echo "GOOD!"
n=$(($n + 1))
done <<<"$pids_onnode"