From d89e16214d4a33c8803c64416ed494c7798d767d Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 12 Jan 2026 12:35:46 -0800 Subject: [PATCH] Simplify fence-and-reclaim fence execution check The fence-and-reclaim test runs a bunch of scenarios and makes sure that the fence agent was run on the appropriate mount's rids. Unfortunately the checks were racey. The check itself only looked at the log once to see if the rid had been fenced. Each check had steps before that would wait until the rid should have been fenced and could be checked. Those steps were racey. They'd do things like make sure a fence request wasn't pending, but never waited for it to be created in the first place. They'd falsely indicate that the log should be checked and when the rid wasn't found in the log the test would fail. In logs of failures we'd see that the rids were fenced after this test failed and moved on to the next. This simplifies the checks. It gets rid of all the intermediate steps and just waits around for the rid to be fenced, with a timeout. This avoids the flakey tests. Signed-off-by: Zach Brown --- tests/tests/fence-and-reclaim.sh | 39 ++++++++------------------------ 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/tests/tests/fence-and-reclaim.sh b/tests/tests/fence-and-reclaim.sh index 7648bb2c..1a4269a0 100644 --- a/tests/tests/fence-and-reclaim.sh +++ b/tests/tests/fence-and-reclaim.sh @@ -5,6 +5,9 @@ t_require_commands sleep touch grep sync scoutfs t_require_mounts 2 +# regularly see ~20/~30s +VERIFY_TIMEOUT_SECS=90 + # # Make sure that all mounts can read the results of a write from each # mount. @@ -40,8 +43,10 @@ verify_fenced_run() for rid in $rids; do grep -q ".* running rid '$rid'.* args 'ignored run args'" "$T_FENCED_LOG" || \ - t_fail "fenced didn't execute RUN script for rid $rid" + return 1 done + + return 0 } echo "== make sure all mounts can see each other" @@ -54,14 +59,7 @@ rid=$(t_mount_rid $cl) echo "cl $cl sv $sv rid $rid" >> "$T_TMP.log" sync t_force_umount $cl -# wait for client reconnection to timeout -while grep -q $rid $(t_debugfs_path $sv)/connections; do - sleep .5 -done -while t_rid_is_fencing $rid; do - sleep .5 -done -verify_fenced_run $rid +t_wait_until_timeout $VERIFY_TIMEOUT_SECS verify_fenced_run $rid t_mount $cl check_read_write @@ -83,15 +81,7 @@ for cl in $(t_fs_nrs); do t_force_umount $cl done -# wait for all client reconnections to timeout -while egrep -q "($pattern)" $(t_debugfs_path $sv)/connections; do - sleep .5 -done -# wait for all fence requests to complete -while test -d $(echo /sys/fs/scoutfs/*/fence/* | cut -d " " -f 1); do - sleep .5 -done -verify_fenced_run $rids +t_wait_until_timeout $VERIFY_TIMEOUT_SECS verify_fenced_run $rids # remount all the clients for cl in $(t_fs_nrs); do if [ $cl == $sv ]; then @@ -107,12 +97,7 @@ rid=$(t_mount_rid $sv) echo "sv $sv rid $rid" >> "$T_TMP.log" sync t_force_umount $sv -t_wait_for_leader -# wait until new server is done fencing unmounted leader rid -while t_rid_is_fencing $rid; do - sleep .5 -done -verify_fenced_run $rid +t_wait_until_timeout $VERIFY_TIMEOUT_SECS verify_fenced_run $rid t_mount $sv check_read_write @@ -127,11 +112,7 @@ for nr in $(t_fs_nrs); do t_force_umount $nr done t_mount_all -# wait for all fence requests to complete -while test -d $(echo /sys/fs/scoutfs/*/fence/* | cut -d " " -f 1); do - sleep .5 -done -verify_fenced_run $rids +t_wait_until_timeout $VERIFY_TIMEOUT_SECS verify_fenced_run $rids check_read_write t_pass