|
Packit Service |
e080da |
#!/bin/bash
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
. $(dirname $0)/../include.rc
|
|
Packit Service |
e080da |
. $(dirname $0)/../volume.rc
|
|
Packit Service |
e080da |
. $(dirname $0)/../nfs.rc
|
|
Packit Service |
e080da |
. $(dirname $0)/../dht.rc
|
|
Packit Service |
e080da |
. $(dirname $0)/../nfs.rc
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
cleanup;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
QDD=$(dirname $0)/quota
|
|
Packit Service |
e080da |
# compile the test write program and run it
|
|
Packit Service |
e080da |
build_tester $(dirname $0)/quota.c -o $QDD
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TESTS_EXPECTED_IN_LOOP=19
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST glusterd
|
|
Packit Service |
e080da |
TEST pidof glusterd
|
|
Packit Service |
e080da |
TEST $CLI volume info;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4};
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
|
Packit Service |
e080da |
EXPECT 'Created' volinfo_field $V0 'Status';
|
|
Packit Service |
e080da |
EXPECT '4' brick_count $V0
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume set $V0 nfs.disable false
|
|
Packit Service |
e080da |
TEST $CLI volume start $V0;
|
|
Packit Service |
e080da |
EXPECT 'Started' volinfo_field $V0 'Status';
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $GFS -s $H0 --volfile-id $V0 $M0;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST mkdir -p $M0/test_dir/in_test_dir
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## --------------------------------------------------------------------------
|
|
Packit Service |
e080da |
## Verify quota commands and check if quota-deem-statfs is enabled by default
|
|
Packit Service |
e080da |
## --------------------------------------------------------------------------
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 enable
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota'
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.inode-quota'
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage /test_dir 100MB
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage /test_dir/in_test_dir 150MB
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
EXPECT "150.0MB" quota_hard_limit "/test_dir/in_test_dir";
|
|
Packit Service |
e080da |
EXPECT "80%" quota_soft_limit "/test_dir/in_test_dir";
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 remove /test_dir/in_test_dir
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
EXPECT "100.0MB" quota_hard_limit "/test_dir";
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage /test_dir 10MB
|
|
Packit Service |
e080da |
EXPECT "10.0MB" quota_hard_limit "/test_dir";
|
|
Packit Service |
e080da |
EXPECT "80%" quota_soft_limit "/test_dir";
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 soft-timeout 0
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 hard-timeout 0
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## ------------------------------
|
|
Packit Service |
e080da |
## Verify quota enforcement
|
|
Packit Service |
e080da |
## -----------------------------
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# Try to create a 12MB file which should fail
|
|
Packit Service |
e080da |
TEST ! $QDD $M0/test_dir/1.txt 256 48
|
|
Packit Service |
e080da |
TEST rm $M0/test_dir/1.txt
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# wait for marker's accounting to complete
|
|
Packit Service |
e080da |
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $QDD $M0/test_dir/2.txt 256 32
|
|
Packit Service |
e080da |
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# Checking internal xattr
|
|
Packit Service |
e080da |
# This confirms that pgfid is also filtered
|
|
Packit Service |
e080da |
TEST ! "getfattr -d -e hex -m . $M0/test_dir/2.txt | grep pgfid ";
|
|
Packit Service |
e080da |
# just check for quota xattr are visible or not
|
|
Packit Service |
e080da |
TEST ! "getfattr -d -e hex -m . $M0/test_dir | grep quota";
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# setfattr should fail
|
|
Packit Service |
e080da |
TEST ! setfattr -n trusted.glusterfs.quota.limit-set -v 10 $M0/test_dir;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# remove xattr should fail
|
|
Packit Service |
e080da |
TEST ! setfattr -x trusted.glusterfs.quota.limit-set $M0/test_dir;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST rm $M0/test_dir/2.txt
|
|
Packit Service |
e080da |
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## rename tests
|
|
Packit Service |
e080da |
TEST $QDD $M0/test_dir/2 256 32
|
|
Packit Service |
e080da |
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
|
|
Packit Service |
e080da |
TEST mv $M0/test_dir/2 $M0/test_dir/0
|
|
Packit Service |
e080da |
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
|
|
Packit Service |
e080da |
TEST rm $M0/test_dir/0
|
|
Packit Service |
e080da |
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## rename tests under different directories
|
|
Packit Service |
e080da |
TEST mkdir -p $M0/1/2;
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage /1/2 100MB 70%;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# The corresponding write(3) should fail with EDQUOT ("Disk quota exceeded")
|
|
Packit Service |
e080da |
TEST ! $QDD $M0/1/2/file 256 408
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST mkdir -p $M0/1/3;
|
|
Packit Service |
e080da |
TEST $QDD $M0/1/3/file 256 408
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#The corresponding rename(3) should fail with EDQUOT ("Disk quota exceeded")
|
|
Packit Service |
e080da |
TEST ! mv $M0/1/3/ $M0/1/2/3_mvd;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## ---------------------------
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## ------------------------------
|
|
Packit Service |
e080da |
## Check if presence of nfs mount results in ESTALE errors for I/O
|
|
Packit Service |
e080da |
# on a fuse mount. Note: Quota command internally uses a fuse mount,
|
|
Packit Service |
e080da |
# though this may change.
|
|
Packit Service |
e080da |
## -----------------------------
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
##Wait for connection establishment between nfs server and brick process
|
|
Packit Service |
e080da |
EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST mount_nfs $H0:/$V0 $N0 nolock;
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage /test_dir 100MB
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage /test_dir/in_test_dir 150MB
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
EXPECT "150.0MB" quota_hard_limit "/test_dir/in_test_dir";
|
|
Packit Service |
e080da |
## -----------------------------
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
###################################################
|
|
Packit Service |
e080da |
## ------------------------------------------------
|
|
Packit Service |
e080da |
## <Test quota functionality in add-brick scenarios>
|
|
Packit Service |
e080da |
## ------------------------------------------------
|
|
Packit Service |
e080da |
###################################################
|
|
Packit Service |
e080da |
QUOTALIMIT=100
|
|
Packit Service |
e080da |
QUOTALIMITROOT=2048
|
|
Packit Service |
e080da |
TESTDIR="addbricktest"
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
rm -rf $M0/*;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## <Create directories and test>
|
|
Packit Service |
e080da |
## -----------------------------
|
|
Packit Service |
e080da |
# 41-42
|
|
Packit Service |
e080da |
TEST mkdir $M0/$TESTDIR
|
|
Packit Service |
e080da |
TEST mkdir $M0/$TESTDIR/dir{1..10};
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# 43-52
|
|
Packit Service |
e080da |
## <set limits>
|
|
Packit Service |
e080da |
## -----------------------------
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 limit-usage / "$QUOTALIMITROOT"MB;
|
|
Packit Service |
e080da |
for i in {1..10}; do
|
|
Packit Service |
e080da |
TEST_IN_LOOP $CLI volume quota $V0 limit-usage /$TESTDIR/dir$i \
|
|
Packit Service |
e080da |
"$QUOTALIMIT"MB;
|
|
Packit Service |
e080da |
done
|
|
Packit Service |
e080da |
## </Enable quota and set limits>
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#53-62
|
|
Packit Service |
e080da |
for i in `seq 1 9`; do
|
|
Packit Service |
e080da |
TEST_IN_LOOP $QDD "$M0/$TESTDIR/dir1/10MBfile$i" 256 40
|
|
Packit Service |
e080da |
done
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# 63-64
|
|
Packit Service |
e080da |
## <Add brick and start rebalance>
|
|
Packit Service |
e080da |
## -------------------------------
|
|
Packit Service |
e080da |
TEST $CLI volume add-brick $V0 $H0:$B0/brick{3,4}
|
|
Packit Service |
e080da |
TEST $CLI volume rebalance $V0 start;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## Wait for rebalance
|
|
Packit Service |
e080da |
EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## <Try creating data beyond limit>
|
|
Packit Service |
e080da |
## --------------------------------
|
|
Packit Service |
e080da |
for i in `seq 1 200`; do
|
|
Packit Service |
e080da |
$QDD of="$M0/$TESTDIR/dir1/1MBfile$i" 256 4\
|
|
Packit Service |
e080da |
2>&1 | egrep -v '(No space left|Disc quota exceeded)'
|
|
Packit Service |
e080da |
done
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# 65
|
|
Packit Service |
e080da |
## <Test whether quota limit crossed more than 10% of limit>
|
|
Packit Service |
e080da |
## ---------------------------------------------------------
|
|
Packit Service |
e080da |
USED_KB=`du -ks $M0/$TESTDIR/dir1 | cut -f1`;
|
|
Packit Service |
e080da |
USED_MB=$(($USED_KB/1024));
|
|
Packit Service |
e080da |
TEST [ $USED_MB -le $((($QUOTALIMIT * 110) / 100)) ]
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
# 66-67
|
|
Packit Service |
e080da |
## <Test the xattrs healed to new brick>
|
|
Packit Service |
e080da |
## -------------------------------------
|
|
Packit Service |
e080da |
TEST getfattr -d -m "trusted.glusterfs.quota.limit-set" -e hex \
|
|
Packit Service |
e080da |
--absolute-names $B0/brick{3,4}/$TESTDIR/dir{1..10};
|
|
Packit Service |
e080da |
# Test on root.
|
|
Packit Service |
e080da |
TEST getfattr -d -m "trusted.glusterfs.quota.limit-set" -e hex \
|
|
Packit Service |
e080da |
--absolute-names $B0/brick{3,4};
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## -------------------------------------------------
|
|
Packit Service |
e080da |
## </Test quota functionality in add-brick scenarios>
|
|
Packit Service |
e080da |
## -------------------------------------------------
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
## ---------------------------
|
|
Packit Service |
e080da |
## Test quota volume options
|
|
Packit Service |
e080da |
## ---------------------------
|
|
Packit Service |
e080da |
TEST $CLI volume reset $V0
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota'
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.inode-quota'
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume reset $V0 force
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota'
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.inode-quota'
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume reset $V0 features.quota-deem-statfs
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume set $V0 features.quota-deem-statfs off
|
|
Packit Service |
e080da |
EXPECT 'off' volinfo_field $V0 'features.quota-deem-statfs'
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume set $V0 features.quota-deem-statfs on
|
|
Packit Service |
e080da |
EXPECT 'on' volinfo_field $V0 'features.quota-deem-statfs'
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume quota $V0 disable
|
|
Packit Service |
e080da |
EXPECT 'off' volinfo_field $V0 'features.quota'
|
|
Packit Service |
e080da |
EXPECT 'off' volinfo_field $V0 'features.inode-quota'
|
|
Packit Service |
e080da |
EXPECT '' volinfo_field $V0 'features.quota-deem-statfs'
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
TEST $CLI volume stop $V0;
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
rm -f $QDD
|
|
Packit Service |
e080da |
cleanup;
|
|
Packit Service |
e080da |
#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=1332045
|