Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: sleep more verbosely #153

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sbd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ BuildRequires: libuuid-devel
BuildRequires: libxml2-devel
BuildRequires: pkgconfig
BuildRequires: make
BuildRequires: time
Conflicts: fence-agents-sbd < 4.5.0

%if 0%{?rhel} > 0
Expand All @@ -97,6 +98,7 @@ Available rpmbuild rebuild options:
Summary: Storage-based death environment for regression tests
License: GPL-2.0-or-later
Group: System Environment/Daemons
Requires: time

%description tests
This package provides an environment + testscripts for
Expand Down
42 changes: 24 additions & 18 deletions tests/regressions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
: ${SBD_TRANSLATE_AIO:= "no"}

sbd() {
LD_PRELOAD=${SBD_PRELOAD} SBD_DEVICE="${SBD_DEVICE}" SBD_PRELOAD_LOG=${SBD_PRELOAD_LOG} SBD_WATCHDOG_DEV=/dev/watchdog setsid ${SBD_BINARY} -p ${SBD_PIDFILE} "$@"
LD_BIND_NOW=yes LD_PRELOAD=${SBD_PRELOAD} SBD_DEVICE="${SBD_DEVICE}" SBD_PRELOAD_LOG=${SBD_PRELOAD_LOG} SBD_WATCHDOG_DEV=/dev/watchdog setsid ${SBD_BINARY} -p ${SBD_PIDFILE} "$@"
}

sbd_sleep() {
TIME="delay %es" time sleep $1
}

sbd_wipe_disk() {
Expand Down Expand Up @@ -134,7 +138,7 @@ sbd_daemon_cleanup() {
fi
if [[ "${SBD_PIDFILE}" != "" ]]; then
pkill -TERM --pidfile ${SBD_PIDFILE} 2>/dev/null
sleep 5
sbd_sleep 5
pkill -KILL --pidfile ${SBD_PIDFILE} 2>/dev/null
pkill -KILL --parent "$(cat ${SBD_PIDFILE} 2>/dev/null)" 2>/dev/null
echo > ${SBD_PIDFILE}
Expand Down Expand Up @@ -265,10 +269,10 @@ test_stall_inquisitor() {
echo "Stall inquisitor test"
sbd_daemon_cleanup
sbd -d ${D[1]} -d ${D[2]} -d ${D[3]} -n test-1 watch
sleep 10
sbd_sleep 10
_ok kill -0 "$(cat ${SBD_PIDFILE})"
kill -STOP "$(cat ${SBD_PIDFILE})"
sleep $((${WATCHDOG_TIMEOUT} * 2))
sbd_sleep $((${WATCHDOG_TIMEOUT} * 2))
kill -CONT "$(cat ${SBD_PIDFILE})" 2>/dev/null
_in_log "watchdog fired"
}
Expand All @@ -277,9 +281,9 @@ test_wipe_slots1() {
echo "Wipe slots test (with watchdog)"
sbd_daemon_cleanup
sbd -d ${D[1]} -n test-1 watch
sleep 2
sbd_sleep 2
sbd_wipe_disk ${D[1]}
sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "watchdog fired"
}

Expand All @@ -288,9 +292,9 @@ test_wipe_slots2() {
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
sleep 2
sbd_sleep 2
sbd_wipe_disk ${D[1]}
sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "sysrq-trigger ('b')"
_in_log "reboot (reboot)"
}
Expand All @@ -300,9 +304,9 @@ test_message1() {
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
sleep 2
sbd_sleep 2
sbd -d ${D[1]} message test-1 reset
sleep 2
sbd_sleep 2
_in_log "sysrq-trigger ('b')"
_in_log "reboot (reboot)"
}
Expand All @@ -312,9 +316,9 @@ test_message2() {
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
sleep 2
sbd_sleep 2
sbd -d ${D[1]} message test-1 off
sleep 2
sbd_sleep 2
_in_log "sysrq-trigger ('o')"
_in_log "reboot (poweroff)"
}
Expand All @@ -324,9 +328,9 @@ test_message3() {
sbd_daemon_cleanup
sbd -d ${D[1]} create
sbd -d ${D[1]} -w /dev/null -n test-1 watch
sleep 2
sbd_sleep 2
sbd -d ${D[1]} message test-1 crashdump
sleep 2
sbd_sleep 2
_in_log "sysrq-trigger ('c')"
}

Expand All @@ -335,9 +339,9 @@ test_timeout_action1() {
sbd_daemon_cleanup
sbd -d ${D[1]} create
SBD_TIMEOUT_ACTION=off sbd -d ${D[1]} -w /dev/null -n test-1 watch
sleep 2
sbd_sleep 2
sbd_wipe_disk ${D[1]}
sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "sysrq-trigger ('o')"
_in_log "reboot (poweroff)"
}
Expand All @@ -347,9 +351,9 @@ test_timeout_action2() {
sbd_daemon_cleanup
sbd -d ${D[1]} create
SBD_TIMEOUT_ACTION=crashdump sbd -d ${D[1]} -w /dev/null -n test-1 watch
sleep 2
sbd_sleep 2
sbd_wipe_disk ${D[1]}
sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
sbd_sleep $((${MSGWAIT_TIMEOUT} + ${WATCHDOG_TIMEOUT} * 2))
_in_log "sysrq-trigger ('c')"
}

Expand All @@ -360,9 +364,11 @@ echo "SBD_TRANSLATE_AIO = \"${SBD_TRANSLATE_AIO}"\"

sbd_setup

MOUNTPOINT=$((mount|grep ${SBD_IMGPATH} || echo unknown)|cut -f1 -d" ")
_ok test "${WATCHDOG_TIMEOUT}" -eq "${WATCHDOG_TIMEOUT}"
_ok test "${MSGWAIT_TIMEOUT}" -eq "${MSGWAIT_TIMEOUT}"
echo "running sbd-tests with WATCHDOG_TIMEOUT=${WATCHDOG_TIMEOUT}s MSGWAIT_TIMEOUT=${MSGWAIT_TIMEOUT}s"
echo "on randomly named images in SBD_IMGPATH=\"${SBD_IMGPATH}\" on ${MOUNTPOINT} filesystem"

if [[ "${SBD_PRELOAD}" != "" ]]; then
SBD_DAEMON_TESTS="watchdog stall_inquisitor wipe_slots1 wipe_slots2 message1 message2 message3 timeout_action1 timeout_action2"
Expand Down
24 changes: 12 additions & 12 deletions tests/sbd-testbed.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ typedef int (*orig_io_getevents_f_type)(io_context_t ctx_id, long min_nr, long n
struct io_event *events, struct timespec *timeout);
typedef int (*orig_io_cancel_f_type)(io_context_t ctx_id, struct iocb *iocb,
struct io_event *result);
typedef int (*orig_io_pgetevents_f_type)(io_context_t ctx_id, long min_nr, long nr,
struct io_event *events, struct timespec *timeout,
sigset_t *sigmask);


static int is_init = 0;
static FILE *log_fp = NULL;
Expand Down Expand Up @@ -98,6 +102,7 @@ static orig_io_destroy_f_type orig_io_destroy = NULL;
static orig_io_submit_f_type orig_io_submit = NULL;
static orig_io_getevents_f_type orig_io_getevents = NULL;
static orig_io_cancel_f_type orig_io_cancel = NULL;
static orig_io_pgetevents_f_type orig_io_pgetevents = NULL;

/* fprintf is inlined as __fprintf_chk or
* we have vfprintf.
Expand Down Expand Up @@ -154,17 +159,12 @@ init (void)
orig_fopen = (orig_fopen_f_type)dlsym_fatal(RTLD_NEXT,"fopen");
orig_fclose = (orig_fclose_f_type)dlsym_fatal(RTLD_NEXT,"fclose");

handle = dlopen("libaio.so.1", RTLD_NOW);
if (!handle) {
fprintf(stderr, "Failed opening libaio.so.1\n");
exit(1);
}
orig_io_setup = (orig_io_setup_f_type)dlsym_fatal(handle,"io_setup");
orig_io_destroy = (orig_io_destroy_f_type)dlsym_fatal(handle,"io_destroy");
orig_io_submit = (orig_io_submit_f_type)dlsym_fatal(handle,"io_submit");
orig_io_getevents = (orig_io_getevents_f_type)dlsym_fatal(handle,"io_getevents");
orig_io_cancel = (orig_io_cancel_f_type)dlsym_fatal(handle,"io_cancel");
dlclose(handle);
orig_io_setup = (orig_io_setup_f_type)dlsym_fatal(RTLD_NEXT,"io_setup");
orig_io_destroy = (orig_io_destroy_f_type)dlsym_fatal(RTLD_NEXT,"io_destroy");
orig_io_submit = (orig_io_submit_f_type)dlsym_fatal(RTLD_NEXT,"io_submit");
orig_io_getevents = (orig_io_getevents_f_type)dlsym_fatal(RTLD_NEXT,"io_getevents");
orig_io_cancel = (orig_io_cancel_f_type)dlsym_fatal(RTLD_NEXT,"io_cancel");
orig_io_pgetevents= io_pgetevents; /* reference something we don't wrap */

value = getenv("SBD_PRELOAD_LOG");
if (value) {
Expand Down Expand Up @@ -203,7 +203,7 @@ init (void)
}
}

// ***** end - handling of watchdog & block-devices ****
// ***** handling of watchdog & block-devices ****

static gboolean
watchdog_timeout_notify(gpointer data)
Expand Down