]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
misc: add duration for recovery loop tests v2023.05.01
authorDarrick J. Wong <djwong@kernel.org>
Wed, 26 Apr 2023 00:14:40 +0000 (17:14 -0700)
committerZorro Lang <zlang@kernel.org>
Sun, 30 Apr 2023 16:05:02 +0000 (00:05 +0800)
Make it so that we can run recovery loop tests for an exact number of
seconds.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc
tests/generic/019
tests/generic/388
tests/generic/475
tests/generic/482
tests/generic/648

index ad9179e260d89d01a5ed7b9b7591e988f0c013b3..37074371d7babb7b79aa3e04a72be953ab5ccd1c 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -5183,6 +5183,40 @@ _require_unix_perm_checking()
        esac
 }
 
+# Decide if a soak test should continue looping.  The sole parameter is the
+# number of soak loops that the test wants to run by default.  The actual
+# loop iteration number is stored in SOAK_LOOPIDX until the loop completes.
+#
+# If the test runner set a SOAK_DURATION value, this predicate will keep
+# looping until it has run for at least that long.
+_soak_loop_running() {
+       local max_soak_loops="$1"
+
+       test -z "$SOAK_LOOPIDX" && SOAK_LOOPIDX=1
+
+       if [ -n "$SOAK_DURATION" ]; then
+               if [ -z "$SOAK_DEADLINE" ]; then
+                       SOAK_DEADLINE="$(( $(date +%s) + SOAK_DURATION))"
+               fi
+
+               local now="$(date +%s)"
+               if [ "$now" -gt "$SOAK_DEADLINE" ]; then
+                       unset SOAK_DEADLINE
+                       unset SOAK_LOOPIDX
+                       return 1
+               fi
+               SOAK_LOOPIDX=$((SOAK_LOOPIDX + 1))
+               return 0
+       fi
+
+       if [ "$SOAK_LOOPIDX" -gt "$max_soak_loops" ]; then
+               unset SOAK_LOOPIDX
+               return 1
+       fi
+       SOAK_LOOPIDX=$((SOAK_LOOPIDX + 1))
+       return 0
+}
+
 init_rc
 
 ################################################################################
index b68dd90c0dd42727ef6e96db8db47205780d1b08..b81c1d17ba6549ea2ecea9c0b0f797eae5a4e25b 100755 (executable)
@@ -30,6 +30,7 @@ _cleanup()
 }
 
 RUN_TIME=$((20+10*$TIME_FACTOR))
+test -n "$SOAK_DURATION" && RUN_TIME="$SOAK_DURATION"
 NUM_JOBS=$((4*LOAD_FACTOR))
 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
 FILE_SIZE=$((BLK_DEV_SIZE * 512))
index 9cd737e8ebfd997d5f0ef6b008c2c5869655621e..4a5be6698cbd9029267a17f809a9634db993a580 100755 (executable)
@@ -42,7 +42,7 @@ _scratch_mkfs >> $seqres.full 2>&1
 _require_metadata_journaling $SCRATCH_DEV
 _scratch_mount
 
-for i in $(seq 1 $((50 * TIME_FACTOR)) ); do
+while _soak_loop_running $((50 * TIME_FACTOR)); do
        ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p 4 >> $seqres.full &) \
                > /dev/null 2>&1
 
index c426402ede44bb12268915b790f7931091523b88..0cbf5131c2f769d6c749c0196f1c92c870ba5355 100755 (executable)
@@ -41,7 +41,7 @@ _require_metadata_journaling $SCRATCH_DEV
 _dmerror_init
 _dmerror_mount
 
-for i in $(seq 1 $((50 * TIME_FACTOR)) ); do
+while _soak_loop_running $((50 * TIME_FACTOR)); do
        ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p $((LOAD_FACTOR * 4)) >> $seqres.full &) \
                > /dev/null 2>&1
 
index 28c83a232e770ed8c16bc96ab4a671c573e8049a..6d8396d98289d5739b4ea7b5ff21135f08d3f895 100755 (executable)
@@ -64,6 +64,7 @@ if [ $nr_cpus -gt 8 ]; then
 fi
 fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \
                $FSSTRESS_AVOID)
+
 devsize=$((1024*1024*200 / 512))       # 200m phys/virt size
 csize=$((1024*64 / 512))               # 64k cluster size
 lowspace=$((1024*1024 / 512))          # 1m low space threshold
index d7bf5697e1fff70361725d191d750a6974685a32..3b3544ff49c3283ac387560094061f84dcc7dacb 100755 (executable)
@@ -74,14 +74,14 @@ snap_loop_fs() {
 
 fsstress=($FSSTRESS_PROG $FSSTRESS_AVOID -d "$loopmnt" -n 999999 -p "$((LOAD_FACTOR * 4))")
 
-for i in $(seq 1 $((25 * TIME_FACTOR)) ); do
+while _soak_loop_running $((25 * TIME_FACTOR)); do
        touch $scratch_aliveflag
        snap_loop_fs >> $seqres.full 2>&1 &
 
        if ! _mount $loopimg $loopmnt -o loop; then
                rm -f $scratch_aliveflag
                _metadump_dev $loopimg $seqres.loop.$i.md
-               _fail "iteration $i loopimg mount failed"
+               _fail "iteration $SOAK_LOOPIDX loopimg mount failed"
                break
        fi
 
@@ -126,12 +126,12 @@ for i in $(seq 1 $((25 * TIME_FACTOR)) ); do
        done
        if [ $is_unmounted -ne 0 ];then
                cat $tmp.unmount.err
-               _fail "iteration $i scratch unmount failed"
+               _fail "iteration $SOAK_LOOPIDX scratch unmount failed"
        fi
        _dmerror_load_working_table
        if ! _dmerror_mount; then
                _metadump_dev $DMERROR_DEV $seqres.scratch.$i.md
-               _fail "iteration $i scratch mount failed"
+               _fail "iteration $SOAK_LOOPIDX scratch mount failed"
        fi
 done