Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 199a1a6..09bb53d 100644 (file)
@@ -19,7 +19,6 @@ export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
 ONLY=${ONLY:-"$*"}
 ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-[ "$SLOW" = "no" ] && EXCEPT="$EXCEPT  9 10 11"
 
 case `uname -r` in
 2.6*) FSTYPE=${FSTYPE:-ldiskfs};;
@@ -50,6 +49,8 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="9 10 11"
+
 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
 
 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
@@ -66,6 +67,10 @@ SHOW_QUOTA_USER="$LFS quota -u $TSTUSR $DIR"
 SHOW_QUOTA_GROUP="$LFS quota -g $TSTUSR $DIR"
 SHOW_QUOTA_INFO="$LFS quota -t $DIR"
 
+# control the time of tests
+cycle=30
+[ "$SLOW" = "no" ] && cycle=10
+
 build_test_filter
 
 eval ONLY_0=true
@@ -162,6 +167,7 @@ run_test 0 "Set quota ============================="
 
 # block hard limit (normal use and out of quota)
 test_1() {
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
 
        LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 5)) # 5 bunits each sever
@@ -212,6 +218,7 @@ run_test 1 "Block hard limit (normal use and out of quota) ==="
 
 # file hard limit (normal use and out of quota)
 test_2() {
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
 
        LIMIT=$(($IUNIT_SZ * 10)) # 10 iunits on mds
@@ -223,7 +230,7 @@ test_2() {
 
        echo "    Create $LIMIT files ..."
        $RUNAS createmany -m ${TESTFILE} $LIMIT || \
-           error "(usr) create failure, but except success"
+           error "(usr) create failure, but expect success"
        echo "    Done"
        echo "    Create out of file quota ..."
        $RUNAS touch ${TESTFILE}_xxx && \
@@ -318,6 +325,7 @@ test_block_soft() {
 
 # block soft limit (start timer, timer goes off, stop timer)
 test_3() {
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
 
        LIMIT=$(( $BUNIT_SZ * 2 )) # 1 bunit on mds and 1 bunit on the ost
@@ -400,7 +408,8 @@ test_file_soft() {
 }
 
 # file soft limit (start timer, timer goes off, stop timer)
-test_4() {
+test_4a() {    # was test_4
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
        LIMIT=$(($IUNIT_SZ * 10))       # 10 iunits on mds
        TESTFILE=$DIR/$tdir/$tfile-0
@@ -428,9 +437,9 @@ test_4() {
        $LFS setquota -t -u $MAX_DQ_TIME $MAX_IQ_TIME $DIR
        $LFS setquota -t -g $MAX_DQ_TIME $MAX_IQ_TIME $DIR
 }
-run_test 4 "File soft limit (start timer, timer goes off, stop timer) ==="
+run_test 4a "File soft limit (start timer, timer goes off, stop timer) ==="
 
-test_4a() {
+test_4b() {    # was test_4a
         GR_STR1="1w3d"
         GR_STR2="1000s"
         GR_STR3="5s"
@@ -454,10 +463,11 @@ test_4a() {
         $LFS setquota -t -u $MAX_DQ_TIME $MAX_IQ_TIME $DIR
         $LFS setquota -t -g $MAX_DQ_TIME $MAX_IQ_TIME $DIR
 }
-run_test 4a "Grace time strings handling ==="
+run_test 4b "Grace time strings handling ==="
 
 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
 test_5() {
+       mkdir -p $DIR/$tdir
        BLIMIT=$(( $BUNIT_SZ * $((OSTCOUNT + 1)) * 10)) # 10 bunits on each server
        ILIMIT=$(( $IUNIT_SZ * 10 )) # 10 iunits on mds
        
@@ -493,6 +503,7 @@ test_6() {
                return 0;
        fi
 
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
 
        LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1) * 5)) # 5 bunits per server
@@ -552,6 +563,7 @@ run_test 6 "Block quota acquire & release ========="
 # quota recovery (block quota only by now)
 test_7()
 {
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
        remote_mds && skip "remote mds" && return 0
 
@@ -601,17 +613,19 @@ run_test 7 "Quota recovery (only block limit) ======"
 
 # run dbench with quota enabled
 test_8() {
+       mkdir -p $DIR/$tdir
        BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
        FILE_LIMIT=1000000
        DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
        
        [ ! -d $DBENCH_LIB ] && skip "dbench not installed" && return 0
+
+       wait_delete_completed
        
        echo "  Set enough high limit for user: $TSTUSR"
        $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
        echo "  Set enough high limit for group: $TSTUSR"
        $LFS setquota -g $USER 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
-       
 
        TGT=$DIR/$tdir/client.txt
        SRC=${SRC:-$DBENCH_LIB/client.txt}
@@ -619,13 +633,19 @@ test_8() {
        SRC=$DBENCH_LIB/client_plain.txt
        [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
 
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
        SAVE_PWD=$PWD
        cd $DIR/$tdir
-       $RUNAS dbench -c client.txt 3
+       local duration=""
+       [ "$SLOW" = "no" ] && duration=" -t 120"
+       $RUNAS dbench -c client.txt 3 $duration
        RC=$?
+       [ $RC -ne 0 ] && killall -9 dbench
        
        rm -f client.txt
+       sync; sleep 3; sync;
+
        cd $SAVE_PWD
        return $RC
 }
@@ -707,6 +727,7 @@ run_test 9 "run for fixing bug10707(64bit) ==========="
 
 # run for fixing bug10707, it need a big room. test for 32bit
 test_10() {
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
        lustrefs_size=`(echo 0; df -t lustre -P | awk '{print $4}') | tail -n 1`
        size_file=$((FSIZE * GB))
@@ -784,6 +805,8 @@ test_10() {
 run_test 10 "run for fixing bug10707(32bit) ==========="
 
 test_11() {
+       wait_delete_completed
+
        #prepare the test
        block_limit=`(echo 0; df -t lustre -P | awk '{print $(NF - 4)}') | tail -n 1`
        echo $block_limit
@@ -799,30 +822,32 @@ test_11() {
        local RV=0
 
        #do the test
-       MINS=0
-       REPS=3
-       i=1
+       local SECS=0
+       local REPS=3
+       [ "$SLOW" = no ] && REPS=1
+       local sleep=20
+       local i=1
        while [ $i -le $REPS ]; do
           echo "test: cycle($i of $REPS) start at $(date)"
-          mkdir -p $DIR/$tdir && chmod 777 $DIR/$tdir
+          mkdir -p $TESTDIR && chmod 777 $TESTDIR
           echo -n "    create a file for uid "
           for j in `seq 1 30`; do
               echo -n "$j "
                # 30MB per dd for a total of 900MB (if space even permits)
-              runas -u $j dd if=/dev/zero of=$DIR/$tdir/$tfile  bs=$blksize count=15 > /dev/null 2>&1 &
+              runas -u $j dd if=/dev/zero of=$TESTDIR/$tfile  bs=$blksize count=15 > /dev/null 2>&1 &
           done
           echo ""
           PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
           LAST_USED=0
           while [ $PROCS -gt 0 ]; do 
-            sleep 60
-            MINS=$(($MINS+1))
+            sleep 20
+            SECS=$((SECS + sleep))
             PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
-            USED=$(du -s $DIR/$tdir | awk '{print $1}')
+            USED=$(du -s $TESTDIR | awk '{print $1}')
             PCT=$(($USED * 100 / $block_limit))
-            echo "${i}/${REPS} ${PCT}% p${PROCS} t${MINS}  "
+            echo "${i}/${REPS} ${PCT}% p${PROCS} t${SECS}  "
             if [ $USED -le $LAST_USED ]; then
-                kill -9 $(ps -ef | grep "dd if /dev/zero of $DIR/$tdir" | grep -v grep | awk '{ print $2 }')
+                kill -9 $(ps -ef | grep "dd if /dev/zero of $TESTDIR" | grep -v grep | awk '{ print $2 }')
                 i=$REPS
                 RV=2
                 break
@@ -830,11 +855,11 @@ test_11() {
              LAST_USED=$USED
           done
           echo "    removing the test files..."
-          rm -rf $DIR/$tdir/$tfile-0
+          rm -f $TESTDIR/$tfile
           echo "cycle $i done at $(date)"
           i=$[$i+1]
        done
-       echo "Test took $MINS minutes"
+       echo "Test took $SECS sec"
 
        #clean
        echo $orig_dbr > /proc/sys/vm/dirty_background_ratio
@@ -842,7 +867,7 @@ test_11() {
        echo $orig_dr  > /proc/sys/vm/dirty_ratio
        echo $orig_dwc > /proc/sys/vm/dirty_writeback_centisecs
        if [ $RV -ne 0 ]; then
-           error "Nothing was written for over a minute... aborting"
+           error "Nothing was written for $SECS sec ... aborting"
        fi
        return $RV
 }
@@ -851,6 +876,7 @@ run_test 11 "run for fixing bug10912 ==========="
 
 # test a deadlock between quota and journal b=11693
 test_12() {
+       mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
 
        [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \
@@ -917,7 +943,8 @@ test_13() {
        # one OST * 10 + (mds + other OSTs)
        LIMIT=$((BUNIT_SZ * 10 + (BUNIT_SZ * OSTCOUNT)))
        TESTFILE="$DIR/$tdir/$tfile"
-       
+       mkdir -p $DIR/$tdir
+
        echo "   User quota (limit: $LIMIT kbytes)"
        $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
        $SHOW_QUOTA_USER
@@ -1000,8 +1027,9 @@ pre_test_14 () {
 
 pre_test_14 
 
-test_14(){ # b=12223 -- setting quota on root
+test_14a() {   # was test_14 b=12223 -- setting quota on root
        TESTFILE="$DIR/$tdir/$tfile"
+       mkdir -p $DIR/$tdir
 
        # out of root's file and block quota
         $LFS setquota -u root 10 10 10 10 $DIR
@@ -1027,7 +1055,7 @@ test_14(){ # b=12223 -- setting quota on root
        unlinkmany ${TESTFILE} 15
        rm -f $TESTFILE
 }
-run_test 14 "test setting quota on root ==="
+run_test 14a "test setting quota on root ==="
 
 # turn off quota
 test_99()