Whamcloud - gitweb
LU-15358 tests: fix check in sanityn test_80b 06/46706/5
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 4 Mar 2022 19:04:10 +0000 (12:04 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 May 2022 18:45:00 +0000 (18:45 +0000)
Shellcheck found checks in sanityn test_80b using bad logic:

        [ $rc -ne 0 -o $rc -ne 16 ] || {
                echo "touch file failed with $rc1"
                break;
        }

This can never be false, so the subtest will never detect errors.
Fix these checks, along with some related style issues.

Test-Parameters: trivial testlist=sanityn mdscount=2 mdtcount=4 env=ONLY=80,ONLY_REPEAT=50
Fixes: 220e6cbfa65c5 ("LU-6475 mdt: race between open and migrate")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I541fe6f3ae253ea1c4d7fa2bcfad9052e374e60c
Reviewed-on: https://review.whamcloud.com/46706
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: James Nunez <jnunez@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanityn.sh

index 3436dba..c506da5 100755 (executable)
@@ -4594,7 +4594,6 @@ test_80b() {
        local migrate_dir2=$DIR2/$tdir/migrate_dir
        local migrate_run=$LUSTRE/tests/migrate.sh
        local start_time
-       local end_time
        local show_time=1
        local mdt_idx
        local rc=0
@@ -4614,14 +4613,14 @@ test_80b() {
                        mdt_idx=$((RANDOM % MDSCOUNT))
                        $LFS migrate -m $mdt_idx $migrate_dir1 &>/dev/null ||
                                rc=$?
-                       [ $rc -ne 0 -o $rc -ne 16 ] || break
+                       (( $rc != 0 && $rc != 16 )) || break
                done
        ) &
        migrate_pid=$!
 
        echo "start migration thread $migrate_pid"
        #Access the files at the same time
-       start_time=$(date +%s)
+       start_time=$SECONDS
        echo "accessing the migrating directory for 5 minutes..."
        while true; do
                ls $migrate_dir2 > /dev/null || {
@@ -4649,7 +4648,7 @@ test_80b() {
                }
 
                touch $migrate_dir2/source_file > /dev/null || rc1=$?
-               [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
+               (( $rc != 0 && $rc != 1 )) || {
                        echo "touch file failed with $rc1"
                        break;
                }
@@ -4663,7 +4662,7 @@ test_80b() {
 
                        mrename $migrate_dir2/source_file \
                                $migrate_dir2/target_file &>/dev/null || rc1=$?
-                       [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
+                       (( $rc != 0 && $rc != 1 )) || {
                                echo "rename failed with $rc1"
                                break
                        }
@@ -4675,16 +4674,15 @@ test_80b() {
                                rm -rf $migrate_dir2/source_file &>/dev/null ||
                                                                rc1=$?
                        fi
-                       [ $rc1 -ne 0 -o $rc1 -ne 1 ] || {
+                       (( $rc != 0 && $rc != 1 )) || {
                                echo "unlink failed with $rc1"
                                break
                        }
                fi
 
-               end_time=$(date +%s)
-               duration=$((end_time - start_time))
-               if [ $((duration % 10)) -eq 0 ]; then
-                       if [ $show_time -eq 1 ]; then
+               local duration=$((SECONDS - start_time))
+               if (( duration % 10 == 0 )); then
+                       if (( $show_time == 1 )); then
                                echo "...$duration seconds"
                                show_time=0
                        fi
@@ -4697,7 +4695,7 @@ test_80b() {
                        break
                }
 
-               [ $duration -ge 300 ] && break
+               (( $duration < 300 )) || break
        done
 
        #check migration are still there