Whamcloud - gitweb
LU-11058 tests: cleanup persistent checksum= in 77k
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 1fe5b64..df7f53f 100755 (executable)
@@ -8,8 +8,8 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: LU-9693 LU-6493 LU-9693 LU-11058
-ALWAYS_EXCEPT="$SANITY_EXCEPT  42a     42b     42c     77k"
+# bug number for skipped test: LU-9693 LU-6493 LU-9693
+ALWAYS_EXCEPT="$SANITY_EXCEPT  42a     42b     42c"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 # skipped tests: LU-8411 LU-9096 LU-9054 ..
@@ -7320,6 +7320,9 @@ test_77k() { # LU-10906
                checksum=$(eval $get_checksum)
                [ $checksum -eq $i ] || error "checksum($checksum) != $i"
        done
+       # remove persistent param to avoid races with checksum mountopt below
+       do_facet mgs $LCTL set_param -P -d $cksum_param ||
+               error "failed to delete checksum on MGS"
 
        for opt in "checksum" "nochecksum"; do
                #remount with mount option
@@ -8598,6 +8601,7 @@ test_103a() {
 run_test 103a "acl test"
 
 test_103b() {
+       declare -a pids
        local U
 
        for U in {0..511}; do
@@ -8622,6 +8626,12 @@ test_103b() {
                        error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
                rm -f $DIR/$tfile.[smp]$0
                } &
+               local pid=$!
+
+               # limit the concurrently running threads to 64. LU-11878
+               local idx=$((U % 64))
+               [ -z "${pids[idx]}" ] || wait ${pids[idx]}
+               pids[idx]=$pid
        done
        wait
 }
@@ -19417,31 +19427,45 @@ check_lfs_df() {
        local inodes
        local df_out
        local lfs_df_out
+       local tries=100
+       local count=0
+       local passed=false
 
        # blocks or inodes
        [ "$1" == "blocks" ] && inodes= || inodes="-i"
 
-       # read the lines of interest
-       df_out=($(df $inodes $dir | tail -n +2)) ||
-               error "df $inodes $dir | tail -n +2 failed"
-       lfs_df_out=($($LFS df $inodes $dir | grep filesystem_summary:)) ||
-               error "lfs df $inodes $dir | grep filesystem_summary: failed"
-
-       # skip the first substrings of each command output as they are different
-       # <NID>:/<fsname for df, filesystem_summary: for lfs df
-       df_out=(${df_out[@]:1})
-       lfs_df_out=(${lfs_df_out[@]:1})
-
-       # compare the two outputs
-       for i in {0..4}; do
-               [ "${df_out[i]}" != "${lfs_df_out[i]}" ] &&
-                       error "df and lfs df output mismatch:" \
-                             "df${inodes}: ${df_out[*]}," \
-                             "lfs df${inodes}: ${lfs_df_out[*]}"
+       while (( count < tries )); do
+               cancel_lru_locks
+               sync; sleep 0.2
+
+               # read the lines of interest
+               df_out=($(df $inodes $dir | tail -n +2)) ||
+                       error "df $inodes $dir | tail -n +2 failed"
+               lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
+                       error "lfs df $inodes $dir | grep summary: failed"
+
+               # skip first substrings of each output as they are different
+               # <NID>:/<fsname for df, filesystem_summary: for lfs df
+               df_out=(${df_out[@]:1})
+               lfs_df_out=(${lfs_df_out[@]:1})
+
+               # compare the two outputs
+               passed=true
+
+               for i in {0..4}; do
+                       [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
+               done
+               $passed && break
        done
+
+       $passed || error "df and lfs df $1 output mismatch: "   \
+                        "df ${inodes}: ${df_out[*]}, "         \
+                        "lfs df ${inodes}: ${lfs_df_out[*]}"
 }
 
 test_418() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local dir=$DIR/$tdir
        local numfiles=$((RANDOM % 4096 + 2))
        local numblocks=$((RANDOM % 256 + 1))
@@ -19458,8 +19482,6 @@ test_418() {
        echo "Creating a single file and testing"
        createmany -o $dir/$tfile- 1 &>/dev/null ||
                error "creating 1 file in $dir failed"
-       cancel_lru_locks osc
-       sync; sleep 2
        check_lfs_df blocks $dir
        check_lfs_df inodes $dir
 
@@ -19475,8 +19497,6 @@ test_418() {
                error "dd to $dir/${tfile}-0 failed"
 
        # retest
-       cancel_lru_locks osc
-       sync; sleep 10
        check_lfs_df blocks $dir
        check_lfs_df inodes $dir
 
@@ -19700,7 +19720,7 @@ saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
 
-cleanup_802() {
+cleanup_802a() {
        trap 0
 
        stopall
@@ -19710,7 +19730,7 @@ cleanup_802() {
        setupall
 }
 
-test_802() {
+test_802a() {
 
        [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
        [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
@@ -19723,7 +19743,7 @@ test_802() {
        cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
                error "(2) Fail to copy"
 
-       trap cleanup_802 EXIT
+       trap cleanup_802a EXIT
 
        # sync by force before remount as readonly
        sync; sync_all_data; sleep 3; sync_all_data
@@ -19752,9 +19772,40 @@ test_802() {
        diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
                error "(7) Read should succeed under ro mode"
 
-       cleanup_802
+       cleanup_802a
+}
+run_test 802a "simulate readonly device"
+
+test_802b() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+        remote_mds_nodsh && skip "remote MDS with nodsh"
+
+       do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
+               skip "readonly option not available"
+
+       $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
+
+       cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
+               error "(2) Fail to copy"
+
+       # write back all cached data before setting MDT to readonly
+       cancel_lru_locks
+       sync_all_data
+
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
+       stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
+
+       echo "Modify should be refused"
+       touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
+
+       echo "Read should be allowed"
+       diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
+               error "(7) Read should succeed under ro mode"
+
+       # disable readonly
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
 }
-run_test 802 "simulate readonly device"
+run_test 802b "be able to set MDTs to readonly"
 
 test_803() {
        [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"