Whamcloud - gitweb
LU-12100 tests: Use minimum soft qunit limits 46/36346/2
authorNathaniel Clark <nclark@whamcloud.com>
Thu, 1 Aug 2019 15:36:59 +0000 (11:36 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 21 Nov 2019 07:31:36 +0000 (07:31 +0000)
Ensure that we don't create limits that are too small, which would
cause all writes to fail.
Wait for grace period to timeout.

Lustre-change: https://review.whamcloud.com/35667
Lustre-commit: 37e28b7e05a5b1f77fe663f9407436aea312b3b2

Test-Parameters: trivial
Test-Parameters: testlist=sanity-quota
Test-Parameters: testlist=sanity-quota fstype=zfs
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
Change-Id: I9342272615ca9c252fcc7f77ed8a61030fc9672a
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36346
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-quota.sh

index 0e7820d..a098219 100755 (executable)
@@ -370,6 +370,44 @@ disable_project_quota() {
        setupall
 }
 
+wait_grace_time() {
+       local qtype=$1
+       local flavour=$2
+       local extrasleep=${3:-5}
+       local qarg
+
+       case $qtype in
+               u|g) qarg=$TSTUSR ;;
+               p) qarg=$TSTPRJID ;;
+               *) error "get_grace_time: Invalid quota type: $qtype"
+       esac
+
+       case $flavour in
+               block)
+                       time=$(lfs quota -$qtype $qarg $DIR|
+                                  awk 'NR == 3{ print $5 }'| sed 's/s$//')
+                       ;;
+               file)
+                       time=$(lfs quota -$qtype $qarg $DIR|
+                                  awk 'NR == 3{ print $9 }'| sed 's/s$//')
+                       ;;
+               *)
+                       error "Unknown quota type: $flavour"
+                       ;;
+       esac
+
+       echo "Sleep through grace ..."
+       [ "$time" == "-" ] &&
+           error "Grace timeout was not set or quota not exceeded"
+       if [ "$time" == "none" ]; then
+           echo "...Grace timeout already expired"
+       else
+               let time+=$extrasleep
+               echo "...sleep $time seconds"
+               sleep $time
+       fi
+}
+
 setup_quota_test() {
        wait_delete_completed
        echo "Creating test directory"
@@ -734,7 +772,7 @@ run_test 2 "File hard limit (normal use and out of quota)"
 
 test_block_soft() {
        local TESTFILE=$1
-       local TIMER=$(($2 * 3 / 2))
+       local GRACE=$2
        local LIMIT=$3
        local OFFSET=0
        local qtype=$4
@@ -772,8 +810,7 @@ test_block_soft() {
        OFFSET=$((OFFSET + 1024))
        cancel_lru_locks osc
 
-       echo "Sleep $TIMER seconds ..."
-       sleep $TIMER
+       wait_grace_time $qtype "block"
 
        $SHOW_QUOTA_USER
        $SHOW_QUOTA_GROUP
@@ -822,10 +859,16 @@ test_block_soft() {
 
 # block soft limit
 test_3() {
-       local LIMIT=1  # 1MB
        local GRACE=20 # 20s
+       if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
+           GRACE=60
+       fi
        local TESTFILE=$DIR/$tdir/$tfile-0
 
+       # get minimum soft qunit size
+       local LIMIT=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
+               qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
+
        set_ost_qtype $QTYPE || error "enable ost quota failed"
 
        echo "User quota (soft limit:$LIMIT MB  grace:$GRACE seconds)"
@@ -888,7 +931,7 @@ test_file_soft() {
        local TESTFILE=$1
        local LIMIT=$2
        local grace=$3
-       local TIMER=$(($grace * 3 / 2))
+       local qtype=$4
 
        setup_quota_test
        trap cleanup_quota_test EXIT
@@ -911,8 +954,7 @@ test_file_soft() {
                        "but expect success. $trigger_time, $cur_time"
        sync_all_data || true
 
-       echo "Sleep $TIMER seconds ..."
-       sleep $TIMER
+       wait_grace_time $qtype "file"
 
        $SHOW_QUOTA_USER
        $SHOW_QUOTA_GROUP
@@ -955,7 +997,8 @@ test_file_soft() {
 
 # file soft limit
 test_4a() {
-       local LIMIT=10 # inodes
+       local LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
+               qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
        local TESTFILE=$DIR/$tdir/$tfile-0
        local GRACE=12
 
@@ -971,7 +1014,7 @@ test_4a() {
        $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
                error "set user quota failed"
 
-       test_file_soft $TESTFILE $LIMIT $GRACE
+       test_file_soft $TESTFILE $LIMIT $GRACE "u"
        resetquota -u $TSTUSR
 
        echo "Group quota (soft limit:$LIMIT files  grace:$GRACE seconds)"
@@ -985,7 +1028,7 @@ test_4a() {
                error "set group quota failed"
        TESTFILE=$DIR/$tdir/$tfile-1
 
-       test_file_soft $TESTFILE $LIMIT $GRACE
+       test_file_soft $TESTFILE $LIMIT $GRACE "g"
        resetquota -g $TSTUSR
 
        if is_project_quota_supported; then
@@ -1002,7 +1045,7 @@ test_4a() {
 
                TESTFILE=$DIR/$tdir/$tfile-1
                # one less than limit, because of parent directory included.
-               test_file_soft $TESTFILE $((LIMIT-1)) $GRACE
+               test_file_soft $TESTFILE $((LIMIT-1)) $GRACE "p"
                resetquota -p $TSTPRJID
                $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
                        $MAX_IQ_TIME $DIR ||