Whamcloud - gitweb
LU-1900 test: check for lustre version in sanity-scrub
[fs/lustre-release.git] / lustre / tests / sanity-scrub.sh
index 660c0bc..a5647d3 100644 (file)
@@ -19,6 +19,8 @@ init_logging
 
 [ "${MDSFSTYPE:-$FSTYPE}" != "ldiskfs" ] &&
        skip "test OI scrub only for ldiskfs" && exit 0
+[[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
+       skip "Need MDS version at least 2.3.0" && exit 0
 require_dsh_mds || exit 0
 
 SAVED_MDSSIZE=${MDSSIZE}
@@ -482,6 +484,11 @@ test_8() {
 run_test 8 "Control OI scrub manually"
 
 test_9() {
+       if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
+               skip "Testing on UP system, the speed may be inaccurate."
+               return 0
+       fi
+
        scrub_prep 8000
        mds_backup_restore || error "(1) Fail to backup/restore!"
 
@@ -532,9 +539,8 @@ test_9() {
        [ $SPEED -lt 220 ] &&
                error "(11) Unexpected speed $SPEED, should not less than 220"
 
-       # (1024 + 100 * 10 + 300 * 10) / 20
-       [ $SPEED -gt 270 ] &&
-               error "(12) Unexpected speed $SPEED, should not more than 270"
+       [ $SPEED -gt 300 ] &&
+               error "(12) Unexpected speed $SPEED, should not more than 300"
 
        do_facet $SINGLEMDS \
                $LCTL set_param -n mdd.${MDT_DEV}.lfsck_speed_limit 0
@@ -671,6 +677,46 @@ test_10b() {
 }
 run_test 10b "non-stopped OI scrub should auto restarts after MDS remount (2)"
 
+test_11() {
+       echo "stopall"
+       stopall > /dev/null
+       echo "setupall"
+       setupall > /dev/null
+
+       local tname=`date +%s`
+       rm -rf $MOUNT/$tname > /dev/null
+       mkdir $MOUNT/$tname || error "(1) Fail to mkdir $MOUNT/$tname"
+
+       createmany -o $MOUNT/$tname/f 100 || error "(2) Fail to create!"
+
+       # reset OI scrub start point by force
+       $START_SCRUB -r || error "(3) Fail to start OI scrub!"
+       sleep 3
+       local STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }')
+       [ "$STATUS" == "completed" ] ||
+               error "(4) Expect 'completed', but got '$STATUS'"
+
+       # OI scrub should skip the new created objects for the first accessing
+       local SKIPPED=$($SHOW_SCRUB | awk '/^noscrub/ { print $2 }')
+       [ $SKIPPED -eq 101 ] ||
+               error "(5) Expect 101 objects skipped, but got $SKIPPED"
+
+       # reset OI scrub start point by force
+       $START_SCRUB -r || error "(6) Fail to start OI scrub!"
+       sleep 3
+       STATUS=$($SHOW_SCRUB | awk '/^status/ { print $2 }')
+       [ "$STATUS" == "completed" ] ||
+               error "(7) Expect 'completed', but got '$STATUS'"
+
+       # OI scrub should skip the new created object only once
+       SKIPPED=$($SHOW_SCRUB | awk '/^noscrub/ { print $2 }')
+       [ $SKIPPED -eq 0 ] ||
+               error "(8) Expect 0 objects skipped, but got $SKIPPED"
+
+       rm -rf $MOUNT/$tname > /dev/null
+}
+run_test 11 "OI scrub skips the new created objects only once"
+
 # restore the ${facet}_MKFS_OPTS variables
 for facet in MGS MDS OST; do
        opts=SAVED_${facet}_MKFS_OPTS