Tweak eventscript unit test infrastructure to support.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
--- /dev/null
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "unset, check no-op"
+
+CTDB_RECOVERY_LOCK=""
+
+ok_null
+simple_test
--- /dev/null
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "set to helper, check no-op"
+
+CTDB_RECOVERY_LOCK="!/some/recover/lock/helper foo"
+
+ok_null
+simple_test
--- /dev/null
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "set, exists"
+
+setup_reclock
+
+ok_null
+simple_test
--- /dev/null
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "set, doesn't exist, 4 times"
+
+setup_reclock
+rm -f "$CTDB_RECOVERY_LOCK"
+
+ok_null
+simple_test
+simple_test
+simple_test
+
+required_result 1 <<EOF
+ERROR: 4 consecutive failures for 01.reclock, marking node unhealthy
+EOF
+simple_test
--- /dev/null
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "set, doesn't exist, 4 times"
+
+setup_reclock
+rm -f "$CTDB_RECOVERY_LOCK"
+
+ok_null
+for i in $(seq 1 3) ; do
+ simple_test
+done
+
+for i in $(seq 4 199) ; do
+ required_result 1 <<EOF
+ERROR: ${i} consecutive failures for 01.reclock, marking node unhealthy
+EOF
+ simple_test
+done
+
+required_result 1 <<EOF
+Reclock file "${CTDB_RECOVERY_LOCK}" can not be accessed. Shutting down.
+Filesystem 1024-blocks Used Available Capacity Mounted on
+/dev/sda1 1000000 100000 900000 10% /
+CTDB says BYE!
+ERROR: 200 consecutive failures for 01.reclock, marking node unhealthy
+EOF
+simple_test
-CTDB_RECOVERY_LOCK="/some/place/on/shared/storage"
CTDB_DEBUGLEVEL=ERR
if [ -n "$FAKE_CTDB_EXTRA_CONFIG" -a -r "$FAKE_CTDB_EXTRA_CONFIG" ] ; then
######################################################################
+# Recovery lock fakery
+
+setup_reclock ()
+{
+ CTDB_RECOVERY_LOCK=$(mktemp --tmpdir="$EVENTSCRIPTS_TESTS_VAR_DIR")
+ export CTDB_RECOVERY_LOCK
+}
+
+######################################################################
+
# VSFTPD fakery
setup_vsftpd ()
usage ()
{
- echo "usage: df -kP <mount-point>"
+ echo "usage: df [-kP] [<mount-point>]"
exit 1
}
-if [ "$1" != "-kP" ] ; then
- usage
+if [ "$1" = "-kP" ] ; then
+ shift
fi
-shift
-if [ -z "$1" ] ; then
- usage
-fi
+case "$1" in
+ -*) usage ;;
+esac
-fs="$1"
+fs="${1:-/}"
# Anything starting with CTDB_DBDIR gets canonicalised to CTDB_DBDIR.
# This helps with the setting of defaults for the filesystem checks.