summaryrefslogtreecommitdiffstats
path: root/tests/basic/quota.t
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basic/quota.t')
-rwxr-xr-xtests/basic/quota.t159
1 files changed, 100 insertions, 59 deletions
diff --git a/tests/basic/quota.t b/tests/basic/quota.t
index cfc4f06950d..46d1bafff84 100755
--- a/tests/basic/quota.t
+++ b/tests/basic/quota.t
@@ -2,10 +2,18 @@
. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc
+. $(dirname $0)/../nfs.rc
. $(dirname $0)/../dht.rc
+. $(dirname $0)/../nfs.rc
+
+#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST
cleanup;
+QDD=$(dirname $0)/quota
+# compile the test write program and run it
+build_tester $(dirname $0)/quota.c -o $QDD
+
TESTS_EXPECTED_IN_LOOP=19
TEST glusterd
@@ -14,54 +22,41 @@ TEST $CLI volume info;
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4};
-function hard_limit()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $2}'
-}
-
-function soft_limit()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $3}'
-}
-
-function usage()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}'
-}
-
EXPECT "$V0" volinfo_field $V0 'Volume Name';
EXPECT 'Created' volinfo_field $V0 'Status';
EXPECT '4' brick_count $V0
+TEST $CLI volume set $V0 nfs.disable false
TEST $CLI volume start $V0;
EXPECT 'Started' volinfo_field $V0 'Status';
-TEST glusterfs -s $H0 --volfile-id $V0 $M0;
+TEST $GFS -s $H0 --volfile-id $V0 $M0;
TEST mkdir -p $M0/test_dir/in_test_dir
-## ------------------------------
-## Verify quota commands
-## ------------------------------
+## --------------------------------------------------------------------------
+## Verify quota commands and check if quota-deem-statfs is enabled by default
+## --------------------------------------------------------------------------
TEST $CLI volume quota $V0 enable
+EXPECT 'on' volinfo_field $V0 'features.quota'
+EXPECT 'on' volinfo_field $V0 'features.inode-quota'
+EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
+
TEST $CLI volume quota $V0 limit-usage /test_dir 100MB
TEST $CLI volume quota $V0 limit-usage /test_dir/in_test_dir 150MB
-EXPECT "150.0MB" hard_limit "/test_dir/in_test_dir";
-EXPECT "80%" soft_limit "/test_dir/in_test_dir";
+EXPECT "150.0MB" quota_hard_limit "/test_dir/in_test_dir";
+EXPECT "80%" quota_soft_limit "/test_dir/in_test_dir";
TEST $CLI volume quota $V0 remove /test_dir/in_test_dir
-EXPECT "100.0MB" hard_limit "/test_dir";
+EXPECT "100.0MB" quota_hard_limit "/test_dir";
TEST $CLI volume quota $V0 limit-usage /test_dir 10MB
-EXPECT "10.0MB" hard_limit "/test_dir";
-EXPECT "80%" soft_limit "/test_dir";
+EXPECT "10.0MB" quota_hard_limit "/test_dir";
+EXPECT "80%" quota_soft_limit "/test_dir";
TEST $CLI volume quota $V0 soft-timeout 0
TEST $CLI volume quota $V0 hard-timeout 0
@@ -70,24 +65,51 @@ TEST $CLI volume quota $V0 hard-timeout 0
## Verify quota enforcement
## -----------------------------
-TEST ! dd if=/dev/urandom of=$M0/test_dir/1.txt bs=1M count=12
+# Try to create a 12MB file which should fail
+TEST ! $QDD $M0/test_dir/1.txt 256 48
TEST rm $M0/test_dir/1.txt
# wait for marker's accounting to complete
-EXPECT_WITHIN 10 "0Bytes" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
+
+TEST $QDD $M0/test_dir/2.txt 256 32
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
+
+# Checking internal xattr
+# This confirms that pgfid is also filtered
+TEST ! "getfattr -d -e hex -m . $M0/test_dir/2.txt | grep pgfid ";
+# just check for quota xattr are visible or not
+TEST ! "getfattr -d -e hex -m . $M0/test_dir | grep quota";
+
+# setfattr should fail
+TEST ! setfattr -n trusted.glusterfs.quota.limit-set -v 10 $M0/test_dir;
+
+# remove xattr should fail
+TEST ! setfattr -x trusted.glusterfs.quota.limit-set $M0/test_dir;
-TEST dd if=/dev/urandom of=$M0/test_dir/2.txt bs=1M count=8
-EXPECT_WITHIN 20 "8.0MB" usage "/test_dir"
TEST rm $M0/test_dir/2.txt
-EXPECT_WITHIN 10 "0Bytes" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
## rename tests
-TEST dd if=/dev/urandom of=$M0/test_dir/2 bs=1M count=8
-EXPECT_WITHIN 20 "8.0MB" usage "/test_dir"
+TEST $QDD $M0/test_dir/2 256 32
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
TEST mv $M0/test_dir/2 $M0/test_dir/0
-EXPECT_WITHIN 10 "8.0MB" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
TEST rm $M0/test_dir/0
-EXPECT_WITHIN 10 "0Bytes" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
+
+## rename tests under different directories
+TEST mkdir -p $M0/1/2;
+TEST $CLI volume quota $V0 limit-usage /1/2 100MB 70%;
+
+# The corresponding write(3) should fail with EDQUOT ("Disk quota exceeded")
+TEST ! $QDD $M0/1/2/file 256 408
+
+TEST mkdir -p $M0/1/3;
+TEST $QDD $M0/1/3/file 256 408
+
+#The corresponding rename(3) should fail with EDQUOT ("Disk quota exceeded")
+TEST ! mv $M0/1/3/ $M0/1/2/3_mvd;
## ---------------------------
@@ -97,18 +119,21 @@ EXPECT_WITHIN 10 "0Bytes" usage "/test_dir"
# though this may change.
## -----------------------------
-TEST mount -t nfs -o nolock,soft,intr $H0:/$V0 $N0;
+##Wait for connection establishment between nfs server and brick process
+EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available;
+
+TEST mount_nfs $H0:/$V0 $N0 nolock;
TEST $CLI volume quota $V0 limit-usage /test_dir 100MB
TEST $CLI volume quota $V0 limit-usage /test_dir/in_test_dir 150MB
-EXPECT "150.0MB" hard_limit "/test_dir/in_test_dir";
+EXPECT "150.0MB" quota_hard_limit "/test_dir/in_test_dir";
## -----------------------------
###################################################
## ------------------------------------------------
-## <Test quota functionality in add-brick senarios>
+## <Test quota functionality in add-brick scenarios>
## ------------------------------------------------
###################################################
QUOTALIMIT=100
@@ -136,8 +161,7 @@ done
#53-62
for i in `seq 1 9`; do
- TEST_IN_LOOP dd if=/dev/urandom of="$M0/$TESTDIR/dir1/10MBfile$i" \
- bs=1M count=10;
+ TEST_IN_LOOP $QDD "$M0/$TESTDIR/dir1/10MBfile$i" 256 40
done
# 63-64
@@ -147,26 +171,19 @@ TEST $CLI volume add-brick $V0 $H0:$B0/brick{3,4}
TEST $CLI volume rebalance $V0 start;
## Wait for rebalance
-while true; do
- rebalance_completed
- if [ $? -eq 1 ]; then
- sleep 1;
- else
- break;
- fi
-done
+EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed
## <Try creating data beyond limit>
## --------------------------------
for i in `seq 1 200`; do
- dd if=/dev/urandom of="$M0/$TESTDIR/dir1/1MBfile$i" bs=1M count=1 \
- &>/dev/null
+ $QDD of="$M0/$TESTDIR/dir1/1MBfile$i" 256 4\
+ 2>&1 | egrep -v '(No space left|Disc quota exceeded)'
done
# 65
## <Test whether quota limit crossed more than 10% of limit>
## ---------------------------------------------------------
-USED_KB=`du -s $M0/$TESTDIR/dir1 | cut -f1`;
+USED_KB=`du -ks $M0/$TESTDIR/dir1 | cut -f1`;
USED_MB=$(($USED_KB/1024));
TEST [ $USED_MB -le $((($QUOTALIMIT * 110) / 100)) ]
@@ -180,16 +197,40 @@ TEST getfattr -d -m "trusted.glusterfs.quota.limit-set" -e hex \
--absolute-names $B0/brick{3,4};
## -------------------------------------------------
-## </Test quota functionality in add-brick senarios>
+## </Test quota functionality in add-brick scenarios>
## -------------------------------------------------
-TEST $CLI volume quota $V0 disable
-TEST $CLI volume stop $V0;
-EXPECT 'Stopped' volinfo_field $V0 'Status';
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0
+
+## ---------------------------
+## Test quota volume options
+## ---------------------------
+TEST $CLI volume reset $V0
+EXPECT 'on' volinfo_field $V0 'features.quota'
+EXPECT 'on' volinfo_field $V0 'features.inode-quota'
+EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
+
+TEST $CLI volume reset $V0 force
+EXPECT 'on' volinfo_field $V0 'features.quota'
+EXPECT 'on' volinfo_field $V0 'features.inode-quota'
+EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
+
+TEST $CLI volume reset $V0 features.quota-deem-statfs
+EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
+
+TEST $CLI volume set $V0 features.quota-deem-statfs off
+EXPECT 'off' volinfo_field $V0 'features.quota-deem-statfs'
-TEST $CLI volume delete $V0;
-TEST ! $CLI volume info $V0;
+TEST $CLI volume set $V0 features.quota-deem-statfs on
+EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
-umount -l $N0
+TEST $CLI volume quota $V0 disable
+EXPECT 'off' volinfo_field $V0 'features.quota'
+EXPECT 'off' volinfo_field $V0 'features.inode-quota'
+EXPECT '' volinfo_field $V0 'features.quota-deem-statfs'
+
+TEST $CLI volume stop $V0;
+rm -f $QDD
cleanup;
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=1332045