From: Andreas Dilger Date: Fri, 4 Mar 2022 19:04:10 +0000 (-0700) Subject: LU-15358 tests: fix check in sanityn test_80b X-Git-Tag: 2.15.0-RC4~8 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F46706%2F5;p=fs%2Flustre-release.git LU-15358 tests: fix check in sanityn test_80b 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 Change-Id: I541fe6f3ae253ea1c4d7fa2bcfad9052e374e60c Reviewed-on: https://review.whamcloud.com/46706 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: James Nunez Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 3436dba..c506da5 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -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