# now complete.
set +e
- echo "*** TEST COMPLETE (RC=$status), CLEANING UP..."
+ echo "*** TEST COMPLETED (RC=$status) AT $(date '+%F %T'), CLEANING UP..."
eval "$ctdb_test_exit_hook" || true
unset ctdb_test_exit_hook
# leave the recovery in restart_ctdb so that future tests that
# might do a manual restart mid-test will benefit.
echo "Forcing a recovery..."
- onnode 0 ctdb recover
+ onnode 0 $CTDB recover
fi
exit $status
{
local out x count line
- out=$(ctdb -Y status 2>&1) || return 1
+ out=$($CTDB -Y status 2>/dev/null) || return 1
{
read x
count=0
while read line ; do
- count=$(($count + 1))
+ # We need to see valid lines if we're going to be healthy.
+ [ "${line#:[0-9]}" != "$line" ] && count=$(($count + 1))
+ # A line indicating a node is unhealthy causes failure.
[ "${line##:*:*:*1:}" != "$line" ] && return 1
done
[ $count -gt 0 ] && return $?
else
echo "Cluster is UNHEALTHY"
if ! ${ctdb_test_restart_scheduled:-false} ; then
- echo "DEBUG:"
+ echo "DEBUG AT $(date '+%F %T'):"
local i
- for i in "onnode -q 0 ctdb status" "onnode -q 0 onnode all ctdb scriptstatus" ; do
+ for i in "onnode -q 0 $CTDB status" "onnode -q 0 onnode all $CTDB scriptstatus" ; do
echo "$i"
$i || true
done
if [ -n "$bits" ] ; then
local out x line
- out=$(ctdb -Y status 2>&1) || return 1
+ out=$($CTDB -Y status 2>&1) || return 1
{
read x
return 1
} <<<"$out" # Yay bash!
elif [ -n "$fpat" ] ; then
- ctdb statistics -n "$pnn" | egrep -q "$fpat"
+ $CTDB statistics -n "$pnn" | egrep -q "$fpat"
elif [ -n "$mpat" ] ; then
- ctdb getmonmode -n "$pnn" | egrep -q "$mpat"
+ $CTDB getmonmode -n "$pnn" | egrep -q "$mpat"
else
echo 'node_has_status: unknown mode, neither $bits nor $fpat is set'
return 1
echo "Waiting until node $pnn has status \"$status\"..."
- if ! onnode any $CTDB_TEST_WRAPPER wait_until $timeout node_has_status "$pnn" "$status" ; then
- for i in "onnode -q any ctdb status" "onnode -q any onnode all ctdb scriptstatus" ; do
+ if ! wait_until $timeout onnode any $CTDB_TEST_WRAPPER node_has_status "$pnn" "$status" ; then
+ for i in "onnode -q any $CTDB status" "onnode -q any onnode all $CTDB scriptstatus" ; do
echo "$i"
$i || true
done
echo "Waiting for tcpdump to capture some packets..."
if ! wait_until 30 tcpdump_check ; then
- echo "DEBUG:"
+ echo "DEBUG AT $(date '+%F %T'):"
local i
- for i in "onnode -q 0 ctdb status" "netstat -tanp" "tcpdump -n -e -r $tcpdump_filename" ; do
+ for i in "onnode -q 0 $CTDB status" "netstat -tanp" "tcpdump -n -e -r $tcpdump_filename" ; do
echo "$i"
$i || true
done
daemons_stop ()
{
echo "Attempting to politely shutdown daemons..."
- onnode 1 ctdb shutdown -n all || true
+ onnode 1 $CTDB shutdown -n all || true
echo "Sleeping for a while..."
sleep_for 1
onnode -q 1 $CTDB_TEST_WRAPPER wait_until_healthy || return 1
echo "Setting RerecoveryTimeout to 1"
- onnode -pq all "ctdb setvar RerecoveryTimeout 1"
+ onnode -pq all "$CTDB setvar RerecoveryTimeout 1"
# In recent versions of CTDB, forcing a recovery like this blocks
# until the recovery is complete. Hopefully this will help the
# cluster to stabilise before a subsequent test.
echo "Forcing a recovery..."
- onnode -q 0 ctdb recover
+ onnode -q 0 $CTDB recover
sleep_for 1
echo "Forcing a recovery..."
- onnode -q 0 ctdb recover
+ onnode -q 0 $CTDB recover
echo "ctdb is ready"
}
onnode -q 1 $CTDB_TEST_WRAPPER wait_until_healthy || return 1
echo "Setting RerecoveryTimeout to 1"
- onnode -pq all "ctdb setvar RerecoveryTimeout 1"
+ onnode -pq all "$CTDB setvar RerecoveryTimeout 1"
# In recent versions of CTDB, forcing a recovery like this blocks
# until the recovery is complete. Hopefully this will help the
# cluster to stabilise before a subsequent test.
echo "Forcing a recovery..."
- onnode -q 0 ctdb recover
+ onnode -q 0 $CTDB recover
sleep_for 1
echo "Forcing a recovery..."
- onnode -q 0 ctdb recover
+ onnode -q 0 $CTDB recover
echo "ctdb is ready"
}
{
local script='#!/bin/sh
-out=$(ctdb pnn)
+out=$($CTDB pnn)
pnn="${out#PNN:}"
rm -vf "/tmp/ctdb-test-flag-${1}.${pnn}"
wait_until 120 ! ctdb_test_eventscript_flag exists $pnn "monitor"
}
+
+# Make sure that $CTDB is set.
+: ${CTDB:=ctdb}
1. Verify that the status on all of the ctdb nodes is 'OK'.
2. Use 'ctdb getmodmode -n <node>' to get the current monitoring mode.
-3. Verify that it shows monitoring as 'active'.
+3. Verify that it looks sane.
4. Verify that the command prints the output in colon-separated format
when run with the '-Y' option.
5. Disable monitoring on the node using 'ctdb disablemonitor'.
sanity_check_output \
1 \
- '^Monitoring mode:ACTIVE \(0\)$' \
+ '^Monitoring mode:(ACTIVE \(0\)|DISABLED \(1\))$' \
"$out"
-colons=$(printf ':mode:\n:0:')
-
try_command_on_node -v 0 $CTDB -Y getmonmode -n $test_node
-if [ "$out" = "$colons" ] ; then
- echo "Looks OK"
-else
- echo "BAD: -Y output isn't what was expected"
- testfailures=1
-fi
+sanity_check_output 2 '^(:mode:|:0:|:1:)$' "$out"
try_command_on_node -v 0 $CTDB disablemonitor -n $test_node