Whamcloud - gitweb
LU-797 tests: improve test_23b of ost-pools.sh
[fs/lustre-release.git] / lustre / tests / ost-pools.sh
index a9416a1..ffa1506 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
-# vim:autoindent:shiftwidth=4:tabstop=4:
+# vim:shiftwidth=4:softtabstop=4:tabstop=4:
 #
 # Run select tests by setting ONLY, or as arguments to the script.
 # Skip specific tests by setting EXCEPT.
@@ -36,9 +36,6 @@ assert_DIR
 
 build_test_filter
 
-SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
-GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
-
 MAXFREE=${MAXFREE:-$((2000000 * OSTCOUNT))}
 
 # OST pools tests
@@ -68,8 +65,8 @@ create_dir() {
     local idx=$4
 
     mkdir -p $dir
-    if [[ -n $4 ]]; then
-        $SETSTRIPE -c $count -p $pool $dir -o $idx
+    if [[ -n $idx ]]; then
+        $SETSTRIPE -c $count -p $pool -i $idx $dir
     else
         $SETSTRIPE -c $count -p $pool $dir
     fi
@@ -83,7 +80,7 @@ create_file() {
     local count=${3:-"-1"}
     local index=${4:-"-1"}
     rm -f $file
-    $SETSTRIPE -o $index -c $count -p $pool $file
+    $SETSTRIPE -i $index -c $count -p $pool $file
     [[ $? -eq 0 ]] ||
         error "$SETSTRIPE -p $pool $file failed."
 }
@@ -628,7 +625,7 @@ test_6() {
     # pool is specified.
     create_pool_nofail $POOL2
     add_pool $POOL2 "OST0000" "$FSNAME-OST0000_UUID "
-    $SETSTRIPE -o 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
+    $SETSTRIPE -i 1 -p $POOL2 $ROOT_POOL/$tfile 2>/dev/null
     [[ $? -ne 0 ]] ||
         error "$SETSTRIPE with start index outside the pool did not fail."
 
@@ -1186,13 +1183,21 @@ test_23a() {
     add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
     create_dir $dir $POOL
 
-    $LFS quotaoff -ug $MOUNT
-    $LFS quotacheck -ug $MOUNT
+       # XXX remove the interoperability code once we drop the old server
+       #     ( < 2.3.50) support.
+       if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
+               $LFS quotaoff -ug $MOUNT
+               $LFS quotacheck -ug $MOUNT
+       else
+               do_facet mgs $LCTL conf_param $FSNAME.quota.ost=ug
+               sleep 5
+       fi
+
     $LFS setquota -u $RUNAS_ID -b $LIMIT -B $LIMIT $dir
     sleep 3
     $LFS quota -v -u $RUNAS_ID $dir
 
-    $LFS setstripe $file -c 1 -p $POOL
+    $SETSTRIPE -c 1 -p $POOL $file
     chown $RUNAS_ID.$RUNAS_GID $file
     ls -l $file
 
@@ -1232,8 +1237,6 @@ test_23b() {
 
     local i=0
     local TGT
-    local BUNIT_SZ=1024  # min block quota unit(kB)
-    local LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1)))
     local dir=$POOL_ROOT/dir
     local file="$dir/$tfile-quota"
 
@@ -1244,36 +1247,65 @@ test_23b() {
     add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
     create_dir $dir $POOL
 
-    AVAIL=$($LFS df -p $POOL $dir | awk '/summary/ { print $4 }')
-    [ $AVAIL -gt $MAXFREE ] &&
-        skip_env "Filesystem space $AVAIL is larger than $MAXFREE limit" &&
-            return 0
-    log "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE"
-    log "MAXFREE=$MAXFREE, AVAIL=$AVAIL, SLOW=$SLOW"
-
-    $LFS quotaoff -ug $MOUNT
-    chown $RUNAS_ID.$RUNAS_ID $dir
-    i=0
-    RC=0
-    while [ $RC -eq 0 ]; do
-        i=$((i + 1))
-        stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
-               count=$((LIMIT * 4)) 2>&1)
-        RC=$?
-               echo "$i: $stat"
-        if [ $RC -eq 1 ]; then
-            echo $stat | grep -q "Disk quota exceeded"
-            [[ $? -eq 0 ]] && error "dd failed with EDQUOT with quota off"
-
-            echo $stat | grep -q "No space left on device"
-            [[ $? -ne 0 ]] &&
-                error "dd did not fail with ENOSPC"
-        fi
-    done
-
-    df -h
-
-    rm -rf $POOL_ROOT
+       local maxfree=$((1024 * 1024 * 30)) # 30G
+       local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
+       [ $AVAIL -gt $maxfree ] &&
+               skip_env "Filesystem space $AVAIL is larger than " \
+                       "$maxfree limit" && return 0
+
+       echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
+       echo "MAXFREE=$maxfree, SLOW=$SLOW"
+
+       # XXX remove the interoperability code once we drop the old server
+       #     ( < 2.3.50) support.
+       if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
+               $LFS quotaoff -ug $MOUNT
+       else
+               do_facet mgs $LCTL conf_param $FSNAME.quota.ost=none
+               sleep 5
+       fi
+
+       chown $RUNAS_ID.$RUNAS_ID $dir
+       i=0
+       local RC=0
+       local TOTAL=0 # KB
+       local stime=$(date +%s)
+       local stat
+       local etime
+       local elapsed
+       local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
+       while [ $RC -eq 0 ]; do
+               i=$((i + 1))
+               stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
+                       count=$((5 * 1024)) 2>&1)
+               RC=$?
+               TOTAL=$((TOTAL + 1024 * 1024 * 5))
+               echo "[$i iteration] $stat"
+               echo "total written: $TOTAL"
+
+               etime=$(date +%s)
+               elapsed=$((etime - stime))
+               echo "stime=$stime, etime=$etime, elapsed=$elapsed"
+
+               if [ $RC -eq 1 ]; then
+                       echo $stat | grep -q "Disk quota exceeded"
+                       [[ $? -eq 0 ]] &&
+                               error "dd failed with EDQUOT with quota off"
+
+                       echo $stat | grep -q "No space left on device"
+                       [[ $? -ne 0 ]] &&
+                               error "dd did not fail with ENOSPC"
+               elif [ $TOTAL -gt $AVAIL ]; then
+                       error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
+               elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
+                       log "The first 5G write used $elapsed (> $maxtime) " \
+                               "seconds, terminated"
+                       RC=1
+               fi
+       done
+
+       df -h
+       rm -rf $POOL_ROOT
 }
 run_test 23b "OST pools and OOS"
 
@@ -1295,11 +1327,11 @@ test_24() {
     create_dir $POOL_ROOT/dir1 $POOL $OSTCOUNT
 
     mkdir $POOL_ROOT/dir2
-    $SETSTRIPE $POOL_ROOT/dir2 -p $POOL -s 65536 -i 0 -c 1 ||
+    $SETSTRIPE -p $POOL -S 65536 -i 0 -c 1 $POOL_ROOT/dir2 ||
         error "$SETSTRIPE $POOL_ROOT/dir2 failed"
 
     mkdir $POOL_ROOT/dir3
-    $SETSTRIPE $POOL_ROOT/dir3 -s 65536 -i 0 -c 1 ||
+    $SETSTRIPE -S 65536 -i 0 -c 1 $POOL_ROOT/dir3 ||
         error "$SETSTRIPE $POOL_ROOT/dir3 failed"
 
     mkdir $POOL_ROOT/dir4
@@ -1379,7 +1411,7 @@ test_25() {
         df $POOL_ROOT > /dev/null
         sleep 5
         # Make sure OST0 can be striped on
-        $SETSTRIPE -o 0 -c 1 $POOL_ROOT/$tfile
+        $SETSTRIPE -i 0 -c 1 $POOL_ROOT/$tfile
         STR=$($GETSTRIPE $POOL_ROOT/$tfile | grep 0x | cut -f2 | tr -d " ")
         rm $POOL_ROOT/$tfile
         if [[ "$STR" == "0" ]]; then
@@ -1434,7 +1466,7 @@ run_test 26 "Choose other OSTs in the pool first in the creation remedy"
 
 cd $ORIG_PWD
 
-complete $(basename $0) $SECONDS
+complete $SECONDS
 cleanup_pools $FSNAME
 check_and_cleanup_lustre
 exit_status