trap - 0
[ $(($testfailures+0)) -eq 0 -a $status -ne 0 ] && testfailures=$status
+ status=$(($testfailures+0))
+
+ # Avoid making a test fail from this point onwards. The test is
+ # now complete.
+ set +e
+
+ echo "*** TEST COMPLETE (RC=$status), CLEANING UP..."
eval "$ctdb_test_exit_hook" || true
unset ctdb_test_exit_hook
- if ! onnode 0 $CTDB_TEST_WRAPPER cluster_is_healthy ; then
- echo "Restarting ctdb on all nodes to get back into known state..."
+ if $ctdb_test_restart_scheduled || \
+ ! onnode 0 CTDB_TEST_CLEANING_UP=1 $CTDB_TEST_WRAPPER cluster_is_healthy ; then
+
restart_ctdb
else
# This could be made unconditional but then we might get
onnode 0 ctdb recover
fi
- test_exit
+ exit $status
}
ctdb_test_exit_hook_add ()
{
scriptname=$(basename "$0")
testfailures=0
+ ctdb_test_restart_scheduled=false
ctdb_test_cmd_options $@
exit 0
else
echo "Cluster is UNHEALTHY"
+ if [ -z "$CTDB_TEST_CLEANING_UP" ] ; then
+ echo "DEBUG:"
+ local i
+ for i in "ctdb status" "onnode -q 0 onnode all ctdb scriptstatus" ; do
+ echo "$i"
+ $i || true
+ done
+ fi
exit 1
fi
}
restart_ctdb ()
{
- if [ "$1" = "-v" ] ; then
- echo "Restarting CTDB (scheduled)..."
+ echo -n "Restarting CTDB"
+ if $ctdb_test_restart_scheduled ; then
+ echo -n " (scheduled)"
fi
+ echo "..."
if [ -n "$CTDB_NODES_SOCKETS" ] ; then
daemons_stop
ctdb_restart_when_done ()
{
- ctdb_test_exit_hook_add restart_ctdb -v
+ ctdb_test_restart_scheduled=true
}
-
-
#######################################
install_eventscript ()
set -e
-echo "Restarting ctdb on all nodes..."
setup_ctdb
restart_ctdb
echo "BAD: CTDB version != RPM version"
testfailures=1
fi
-
-ctdb_test_exit
5 \
'^[[:alpha:]]+[[:space:]]*=[[:space:]]*[[:digit:]]+$' \
"$out"
-
-ctdb_test_exit
exit 1
fi
done
-
-testfailures=$?
-
-ctdb_test_exit
echo "Look's good! Putting the old value back..."
cmd="$CTDB setvar $var $val"
try_command_on_node 0 $cmd
-
-echo "All done..."
-
-ctdb_test_exit
fi
n=$(($n + 1))
done
-
-ctdb_test_exit
fi
n=$(($n + 1))
done <<<"$pids_onnode"
-
-ctdb_test_exit
pid="$out"
echo "Checking for PID $pid on node $test_node"
-# set -e is good, but avoid it here
-status=0
-onnode 0 "$CTDB process-exists ${test_node}:${pid}" || status=$?
-echo "$out"
-
-if [ $status -ne 0 ] ; then
- echo "OK"
-else
- echo "BAD"
- testfailures=1
-fi
-
-ctdb_test_exit
+try_command_on_node -v 0 "! $CTDB process-exists ${test_node}:${pid}"
echo "BAD, there are only ${num_not_rm_lines} nodes claiming not to be the recmaster"
testfailures=1
fi
-
-ctdb_test_exit
1 \
"(: ctdb_control error: 'ctdb_control to disconnected node'|Unable to get ping response from node 1|Node 1 is DISCONNECTED)" \
"$out"
-
-echo "Expect a restart..."
-
-ctdb_test_exit
echo "$out"
testfailures=1
fi
-
-ctdb_test_exit
sanity_check_output \
$num_nodes \
- '^Node [[:digit:]]+ is at debug level [[:alpha:]]+ \([[:digit:]]\)$' \
+ '^Node [[:digit:]]+ is at debug level [[:alpha:]]+ \([[:digit:]]+\)$' \
"$out"
try_command_on_node -v 1 "$CTDB getdebug -n all"
nl="
"
while read line ; do
- t=$(echo "$line" | sed -r -e 's@Node [[:digit:]]+ is at debug level ([[:alpha:]]+) \((-?[[:digit:]])\)$@:\1:\2:@')
+ t=$(echo "$line" | sed -r -e 's@Node [[:digit:]]+ is at debug level ([[:alpha:]]+) \((-?[[:digit:]]+)\)$@:\1:\2:@')
colons="${colons}${colons:+${nl}}:Name:Level:${nl}${t}"
done <<<"$getdebug_onnode"
echo "$out"
testfailures=1
fi
-
-ctdb_test_exit
try_command_on_node -v $node "$CTDB getdebug"
check_debug=$(echo "$out" |
- sed -r -e 's@Node [[:digit:]] is at debug level ([[:alpha:]]+) \(-?[[:digit:]]\)$@\1@')
+ sed -r -e 's@Node [[:digit:]]+ is at debug level ([[:alpha:]]+) \(-?[[:digit:]]+\)$@\1@')
}
set_and_check_debug ()
echo "Returning the debug level to its initial value..."
set_and_check_debug 1 "$initial_debug"
fi
-
-ctdb_test_exit
try_command_on_node -v 1 "$CTDB statistics -n all"
sanity_check_output 40 "$pattern" "$out"
-
-ctdb_test_exit
n=$(($n + 1))
done
-
-ctdb_test_exit
echo "BAD: Unable to find IP address to add."
testfailures=1
fi
-
-ctdb_test_exit
echo "BAD: The remove IP address is still there!"
testfailures=1
fi
-
-ctdb_test_exit
try_command_on_node 0 $CTDB freeze -n $test_node
onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node frozen
-
-echo "GOOD: That worked!"
-
-ctdb_test_exit
try_command_on_node 0 $CTDB thaw -n $test_node
onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node unfrozen
-
-ctdb_test_exit
try_command_on_node -v 0 $CTDB disablemonitor -n $test_node
onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node monoff
-
-echo "GOOD: That worked!"
-
-ctdb_test_exit
sleep_for $monitor_interval
onnode 0 $CTDB_TEST_WRAPPER node_has_status $test_node unhealthy
-
-echo "OK, that all worked. Expect a restart..."
-
-ctdb_test_exit
onnode 0 $CTDB_TEST_WRAPPER wait_until_node_has_status $test_node unhealthy $monitor_interval
try_command_on_node -v $test_node ls -l "$detected"
-
-echo "GOOD: That all worked..."
-
-ctdb_test_exit
echo "BAD: IP didn't move to ${to_node}."
exit 1
fi
-
-echo "GOOD: That worked..."
-
-ctdb_test_exit
exit 1
fi
done
-
-echo "GOOD: That worked..."
-
-ctdb_test_exit
echo "BAD: there not look to be output for all $num_nodes nodes"
exit 1
fi
-
-ctdb_test_exit
exit 1
fi
done
-
-echo "OK, that all worked. Expect a restart..."
-
-ctdb_test_exit
echo "Some IPs didn't move."
testfailures=1
fi
-
-echo "Expect a restart..."
-
-ctdb_test_exit
echo "Some IPs didn't move."
testfailures=1
fi
-
-echo "All done!"
-
-ctdb_test_exit
echo "Some IPs didn't move."
testfailures=1
fi
-
-ctdb_test_exit
echo "Some IPs didn't move."
testfailures=1
fi
-
-ctdb_test_exit
echo "BAD: percentage difference between +ive and -ive ($perc_diff%) > $check_percent%"
exit 1
fi
-
-
-ctdb_test_exit
echo "BAD: percentage difference between +ive and -ive ($perc_diff%) > 1%"
exit 1
fi
-
-ctdb_test_exit
echo "Running ctdb_transaction on all $num_nodes nodes."
try_command_on_node -v -pq all "$t & $t"
-
-ctdb_test_exit
echo "Running ctdb_persistent on all $num_nodes nodes."
try_command_on_node -v -pq all "$t & $t"
-
-ctdb_test_exit
echo "Running ctdb_persistent --unsafe-writes on all $num_nodes nodes."
try_command_on_node -v -pq all "$t & $t"
-
-ctdb_test_exit