Whamcloud - gitweb
LU-4028 quota: fix output of 'lfs quota'
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 3a61d12..634d7f9 100644 (file)
@@ -89,21 +89,18 @@ SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
 build_test_filter
 
 lustre_fail() {
-        local fail_node=$1
+       local fail_node=$1
        local fail_loc=$2
        local fail_val=${3:-0}
+       local NODES=
 
-       if [ $fail_node == "mds" ] || [ $fail_node == "mds_ost" ]; then
-               do_facet $SINGLEMDS "lctl set_param fail_val=$fail_val"
-               do_facet $SINGLEMDS "lctl set_param fail_loc=$fail_loc"
-       fi
+       case $fail_node in
+       mds_ost|mdt_ost) NODES="$(comma_list $(mdts_nodes) $(osts_nodes))";;
+       mds|mdt) NODES="$(comma_list $(mdts_nodes))";;
+       ost) NODES="$(comma_list $(osts_nodes))";;
+       esac
 
-       if [ $fail_node == "ost" ] || [ $fail_node == "mds_ost" ]; then
-               for num in `seq $OSTCOUNT`; do
-                       do_facet ost$num "lctl set_param fail_val=$fail_val"
-                       do_facet ost$num "lctl set_param fail_loc=$fail_loc"
-               done
-       fi
+       do_nodes $NODES "lctl set_param fail_val=$fail_val fail_loc=$fail_loc"
 }
 
 RUNAS="runas -u $TSTID -g $TSTID"
@@ -933,9 +930,8 @@ test_6() {
 
        rm -f $TMP/lustre-log-${TESTNAME}.log
 
-       # write should continue & succeed
+       # write should continue then fail with EDQUOT
        local count=0
-       local o_size=$(stat -c %s $TESTFILE)
        local c_size
        while [ true ]; do
                if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
@@ -945,13 +941,8 @@ test_6() {
                count=$((count + 1))
                if [ $((count % 30)) -eq 0 ]; then
                        c_size=$(stat -c %s $TESTFILE)
-                       if [ $c_size -eq $o_size ]; then
-                               quota_error u $TSTUSR "file not growed" \
-                               "in 30 seconds $o_size/$c_size"
-                       else
-                               echo "Waiting $count secs. $o_size/$c_size"
-                               o_size=$c_size
-                       fi
+                       echo "Waiting $count secs. $c_size"
+                       $SHOW_QUOTA_USER
                fi
                sleep 1
        done
@@ -2026,9 +2017,17 @@ test_27c() {
                error "lfs setquota failed"
 
        limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
-       [ $limit != "30M" ] && error "softlimit isn't human-readable"
+       [ $limit != "30M" ] && error "softlimit $limit isn't human-readable"
+       limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
+       [ $limit != "3T" ] && error "hardlimit $limit isn't human-readable"
+
+       $LFS setquota -u $TSTID -b 1500M -B 18500G $DIR ||
+               error "lfs setquota for $TSTID failed"
+
+       limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
+       [ $limit != "1.465G" ] && error "wrong softlimit $limit"
        limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
-       [ $limit != "3T" ] && error "hardlimit isn't human-readable"
+       [ $limit != "18.07T" ] && error "wrong hardlimit $limit"
 
        $LFS quota -u $TSTID -v -h $DIR | grep -q "Total allocated" ||
                error "total allocated inode/block limit not printed"
@@ -2062,11 +2061,11 @@ test_30() {
        # over-quota flag has not yet settled since we do not trigger async
        # events based on grace time period expiration
        $SHOW_QUOTA_USER
-       $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 || true
+       $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 || true
        cancel_lru_locks osc
        # now over-quota flag should be settled and further writes should fail
        $SHOW_QUOTA_USER
-       $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 &&
+       $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 &&
                error "grace times were reset"
        # cleanup
        cleanup_quota_test