From: Charlie Olmstead Date: Mon, 22 Apr 2024 16:37:12 +0000 (-0600) Subject: LU-17769 tests: run_one() repeats subtests for set duration X-Git-Tag: 2.15.64~214 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=51ac82d4c3ecdc88bab873437aa4a41447db9b08;p=fs%2Flustre-release.git LU-17769 tests: run_one() repeats subtests for set duration 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 Change-Id: I4b454fd8582d2b875762ee15451150afb3117d15 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54869 Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index aac78ee..fc06109 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -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