From b53438df70eb4462cdbfd0b4e58ea5acf2d404b9 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Fri, 15 Oct 2021 15:23:53 +0300 Subject: [PATCH] LU-15109 tests: different quota and usage relations Add sanity-quota_1i that following cases: - User is above PQ limit and the quota limit is cleared. User should now be able to write. - User is below PQ limit and the quota limit is lowered below current usage. User should not be able to write. - User is above PQ limit and the quota limit is raised above current usage. Should now be able to write. Change-Id: Iad81c706aaf838cacfdf2971ee100950c47d1585 HPE-bug-id: LUS-9935 Test-Parameters: testlist=sanity-quota env=ONLY=1i Signed-off-by: Sergey Cheremencev Reviewed-on: https://review.whamcloud.com/45257 Tested-by: jenkins Reviewed-by: Petros Koutoupis Tested-by: Maloo Reviewed-by: Elena Gryaznova Reviewed-by: Oleg Drokin --- lustre/tests/sanity-quota.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 34d6452..0cc20c7 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -1108,6 +1108,76 @@ test_1h() { } run_test 1h "Block hard limit test using fallocate" +test_1i() { + local global_limit=200 # 200M + local limit1=10 # 10M + local TESTDIR="$DIR/$tdir/" + local testfile="$TESTDIR/$tfile-0" + local testfile1="$TESTDIR/$tfile-1" + local testfile2="$TESTDIR/$tfile-2" + local qpool1="qpool1" + + mds_supports_qp + setup_quota_test || error "setup quota failed with $?" + stack_trap cleanup_quota_test EXIT + + # enable ost quota + set_ost_qtype $QTYPE || error "enable ost quota failed" + + log "User quota (block hardlimit:$global_limit MB)" + $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR || + error "set user quota failed" + + pool_add $qpool1 || error "pool_add failed" + pool_add_targets $qpool1 0 0 || + error "pool_add_targets failed" + + $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR || + error "set user quota failed" + + # make sure the system is clean + local used=$(getquota -u $TSTUSR global curspace) + [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0." + + $LFS setstripe $TESTDIR -c 1 -i 0 || error "setstripe $TESTDIR failed" + + # hit pool limit + test_1_check_write $testfile "user" $limit1 + $LFS setquota -u $TSTUSR -B 0 --pool $qpool1 $DIR || + error "set user quota failed" + + $LFS quota -uv $TSTUSR --pool $qpool1 $DIR + $RUNAS $DD of=$testfile1 count=$((limit1/2)) || + quota_error u $TSTUSR "write failure, but expect success" + + rm -f $testfile + rm -f $testfile1 + wait_delete_completed || error "wait_delete_completed failed" + sync_all_data || true + + $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR || + error "set user quota failed" + test_1_check_write $testfile "user" $limit1 + local tmp_limit=$(($limit1*2)) + # increase pool limit + $LFS setquota -u $TSTUSR -B ${tmp_limit}M --pool $qpool1 $DIR || + error "set user quota failed" + # now write shouldn't fail + $RUNAS $DD of=$testfile1 count=$((limit1/3)) || + quota_error u $TSTUSR "write failure, but expect success" + # decrease pool limit + $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR || + error "set user quota failed" + $RUNAS $DD of=$testfile2 count=$((limit1/3)) + # flush cache, ensure noquota flag is set on client + cancel_lru_locks osc + sync; sync_all_data || true + $RUNAS $DD of=$testfile2 seek=$((limit1/3)) count=1 && + quota_error u $TSTUSR "write success, but expect failure" + return 0 +} +run_test 1i "Quota pools: different limit and usage relations" + # test inode hardlimit test_2() { local TESTFILE="$DIR/$tdir/$tfile-0" -- 1.8.3.1