Whamcloud - gitweb
LU-16516 tests: ONLY and ONLY_REPEAT improvements 95/50395/3
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 23 Mar 2023 21:38:54 +0000 (15:38 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 4 Apr 2023 14:38:06 +0000 (14:38 +0000)
ONLY_REPEAT=N did not work if multiple subtests were selected via
a "base" test number (e.g. "ONLY=118") and that resulted in more
than one subtest being run (e.g. ONLY_118a=true, ONLY_118b=true, ...)
Since the run_one() caller of run_one_logged() is already checking
whether the test should be run or not, don't repeat that check
for ONLY_REPEAT.

Allow ONLY_REPEAT to be used when multiple subtests are specified
via ONLY, even if the subtests are not explicitly listed.

Allow tests in ONLY, EXCEPT, ALWAYS_EXCEPT, and SLOW to be separated
by '+', or ',' in addition to space-separated test numbers.  That
avoids issues with handling space-separated test lists in the shell
or when specified via Test-Parameters (need to use '+' in that case).

Test-Parameters: trivial testlist=sanity env=ONLY=118,ONLY_REPEAT=5
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ieac578c098ae76994a211c7db094dd99923bcc8c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50395
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Alex Deiter <alex.deiter@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/test-framework.sh

index f09884d..89a440d 100755 (executable)
@@ -6692,9 +6692,11 @@ function always_except() {
 build_test_filter() {
        EXCEPT="$EXCEPT $(testslist_filter)"
 
-       for O in $ONLY; do
-               if [[ $O = [0-9]*-[0-9]* ]]; then
-                       for num in $(seq $(echo $O | tr '-' ' ')); do
+       # allow test numbers separated by '+', or ',', in addition to ' '
+       # to avoid issues with multiple arguments handling by shell/autotest
+       for O in ${ONLY//[+,]/ }; do
+               if [[ $O =~ [0-9]*-[0-9]* ]]; then
+                       for ((num=${O%-[0-9]*}; num <= ${O#[0-9]*-}; num++)); do
                                eval ONLY_$num=true
                        done
                else
@@ -6702,20 +6704,20 @@ build_test_filter() {
                fi
        done
 
-       [ "$EXCEPT$ALWAYS_EXCEPT" ] &&
-               log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
-       [ "$EXCEPT_SLOW" ] &&
-               log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
-       for E in $EXCEPT; do
+       [[ -z "$EXCEPT$ALWAYS_EXCEPT" ]] ||
+               log "excepting tests: $(echo $EXCEPT $ALWAYS_EXCEPT)"
+       [[ -z "$EXCEPT_SLOW" ]] ||
+               log "skipping tests SLOW=no: $(echo $EXCEPT_SLOW)"
+       for E in ${EXCEPT//[+,]/ }; do
                eval EXCEPT_${E}=true
        done
-       for E in $ALWAYS_EXCEPT; do
+       for E in ${ALWAYS_EXCEPT//[+,]/ }; do
                eval EXCEPT_ALWAYS_${E}=true
        done
-       for E in $EXCEPT_SLOW; do
+       for E in ${EXCEPT_SLOW//[+,]/ }; do
                eval EXCEPT_SLOW_${E}=true
        done
-       for G in $GRANT_CHECK_LIST; do
+       for G in ${GRANT_CHECK_LIST//[+,]/ }; do
                eval GCHECK_ONLY_${G}=true
        done
 }
@@ -6963,18 +6965,17 @@ run_one_logged() {
 
        rm -f $LOGDIR/err $LOGDIR/ignore $LOGDIR/skip
        echo
-       # if ${ONLY_$testnum} set, repeat $ONLY_REPEAT times, otherwise once
-       local isonly=ONLY_$testnum
-       local repeat=${!isonly:+$ONLY_REPEAT}
+       # if $ONLY is set, repeat subtest $ONLY_REPEAT times, otherwise once
+       local repeat=${ONLY:+$ONLY_REPEAT}
 
        for ((testiter=0; testiter < ${repeat:-1}; testiter++)); do
                local before_sub=$SECONDS
-               log_sub_test_begin $TESTNAME
 
+               log_sub_test_begin $TESTNAME
                # remove temp files between repetitions to avoid test failures
                if [[ -n "$append" ]]; then
-                       [[ -n "$DIR/$tdir" ]] && rm -rvf $DIR/$tdir*
-                       [[ -n "$DIR/$tfile" ]] && rm -vf $DIR/$tfile*
+                       [[ -n "$tdir" ]] && rm -rvf $DIR/$tdir*
+                       [[ -n "$tfile" ]] && rm -vf $DIR/$tfile*
                        echo "subtest iteration $testiter/$repeat"
                fi
                # loop around subshell so stack_trap EXIT triggers each time
@@ -7005,7 +7006,7 @@ run_one_logged() {
                fi
 
                log_sub_test_end $TEST_STATUS $duration_sub "$rc" "$test_error"
-               [[ $rc != 0 ]] && break
+               [[ $rc != 0 || "$TEST_STATUS" != "PASS" ]] && break
        done
 
        if [[ "$TEST_STATUS" != "SKIP" && -f $TF_SKIP ]]; then