Whamcloud - gitweb
LU-17769 tests: run_one() repeats subtests for set duration 69/54869/6
authorCharlie Olmstead <charlie@whamcloud.com>
Mon, 22 Apr 2024 16:37:12 +0000 (10:37 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 May 2024 18:40:39 +0000 (18:40 +0000)
Implement ONLY_MINUTES=M environment variable to allow test runners
to execute a subtest for at least M minutes. Each time the subtest
completes, the duration is checked to see if it has exceeded
ONLY_MINUTES, therfore the parameter represents a minimum number
of minutes to run rather than an exact duration.

If, for some reason, both ONLY_REPEAT and ONLY_MINUTES are set,
the ONLY_REPEAT value takes precedence.

Test-Parameters: trivial testlist=sanity env=ONLY=73
Test-Parameters: testlist=sanity env=ONLY=73,ONLY_REPEAT=10
Test-Parameters: testlist=sanity env=ONLY=73,ONLY_MINUTES=5
Test-Parameters: testlist=sanity env=ONLY=73,ONLY_REPEAT=100,ONLY_MINUTES=10
Test-Parameters: testlist=sanity env=ONLY=73,ONLY_REPEAT=10,ONLY_MINUTES=10
Signed-off-by: Charlie Olmstead <charlie@whamcloud.com>
Change-Id: I4b454fd8582d2b875762ee15451150afb3117d15
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54869
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/test-framework.sh

index aac78ee..fc06109 100755 (executable)
@@ -7418,10 +7418,20 @@ run_one_logged() {
 
        rm -f $LOGDIR/err $LOGDIR/ignore $LOGDIR/skip
        echo
-       # if $ONLY is set, repeat subtest $ONLY_REPEAT times, otherwise once
+
+       # process ONLY options:
+       # - $ONLY_REPEAT will run the subtest $ONLY_REPEAT times
+       # - $ONLY_MINUTES will run the subtest for $ONLY_MINUTES
+       # - $ONLY_REPEAT and $ONLY_MINUTES can be set to run the subtest for
+       #   $ONLY_REPEAT times but not to exceed $ONLY_MINUTES
+       # - if $ONLY_REPEAT and ONLY_MINUTES are unset, subtest will run once
        local repeat=${ONLY:+$ONLY_REPEAT}
+       if [[ -n "$ONLY" && "$ONLY_MINUTES" ]]; then
+               local repeat_end_sec=$((SECONDS + ONLY_MINUTES * 60))
+       fi
 
-       for ((testiter=0; testiter < ${repeat:-1}; testiter++)); do
+       local testiter=1
+       while true; do
                local before_sub=$SECONDS
 
                log_sub_test_begin $TESTNAME
@@ -7429,7 +7439,8 @@ run_one_logged() {
                if [[ -n "$append" ]]; then
                        [[ -n "$tdir" ]] && rm -rvf $DIR/$tdir*
                        [[ -n "$tfile" ]] && rm -vf $DIR/$tfile*
-                       echo "subtest iteration $testiter/$repeat"
+                       echo "subtest iteration $testiter/$repeat " \
+                               "($(((SECONDS-before)/60))/$ONLY_MINUTES min)"
                fi
                # loop around subshell so stack_trap EXIT triggers each time
                (run_one $testnum "$testmsg") 2>&1 | tee -i $append $test_log
@@ -7466,6 +7477,14 @@ run_one_logged() {
                        exit $STOP_NOW_RC
 
                [[ $rc != 0 || "$TEST_STATUS" != "PASS" ]] && break
+
+               # no repeat options were set, break after the first iteration
+               [[ -z "$repeat" && -z "$repeat_end_sec" ]] && break
+               # break if any repeat options were set and have been met
+               [[ -n "$repeat" ]] && (( $testiter >= $repeat )) && break
+               [[ -n "$repeat_end_sec" ]] &&
+                       (( $SECONDS >= $repeat_end_sec )) && break
+               ((testiter++))
        done
 
        local param