summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-07-10 14:37:50 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-07-12 21:34:53 -0700
commit46d4d7ade012f86044135dd4af3101f851484cda (patch)
treee5308db8044e62788e0bde1f21ed54a904af40fe /tests
parent2e44d1580497eb75f325ad3104249a425ddf592a (diff)
features/quota : Fix spurious failure
Problem : Basically, in this test case a file is created which exceeds the quota limit. Once the limit is reached that file will be deleted. At the same moment we are testing inode-quota. It can so happen that before the marker updates the information related to deletion of file, a new file creation operation comes and sees that quota limit is still exceeded. Solution : Inducing a check to see if marker updation completed successfully. Updated all the test case which has the similar machanism and also moved the "usage" function to a common place "volume.rc" Change-Id: I36ddbc5ebbf1b74c9d326a0d1d5f3b32f20a906a BUG: 1229297 Signed-off-by: Sachin Pandit <spandit@redhat.com> Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/11125 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/basic/ec/quota.t28
-rwxr-xr-xtests/basic/quota-nfs.t9
-rwxr-xr-xtests/basic/quota.t42
-rw-r--r--tests/bugs/disperse/bug-1227869.t8
-rwxr-xr-xtests/bugs/distribute/bug-1161156.t9
-rw-r--r--tests/bugs/quota/afr-quota-xattr-mdata-heal.t2
-rw-r--r--tests/bugs/quota/bug-1038598.t51
-rw-r--r--tests/bugs/quota/bug-1178130.t10
-rw-r--r--tests/bugs/quota/bug-1235182.t8
-rw-r--r--tests/bugs/quota/inode-quota.t1
-rw-r--r--tests/volume.rc33
11 files changed, 63 insertions, 138 deletions
diff --git a/tests/basic/ec/quota.t b/tests/basic/ec/quota.t
index cc2d4bd9efa..f093085bde0 100755
--- a/tests/basic/ec/quota.t
+++ b/tests/basic/ec/quota.t
@@ -3,24 +3,6 @@
. $(dirname $0)/../../include.rc
. $(dirname $0)/../../volume.rc
-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}'
-}
-
cleanup
QDD=$(dirname $0)/quota
# compile the test write program and run it
@@ -41,8 +23,8 @@ TEST $CLI volume quota $V0 enable
TEST $CLI volume quota $V0 limit-usage /test 10MB
-EXPECT "10.0MB" hard_limit "/test";
-EXPECT "80%" soft_limit "/test";
+EXPECT "10.0MB" quota_hard_limit "/test";
+EXPECT "80%" quota_soft_limit "/test";
TEST $CLI volume quota $V0 soft-timeout 0
TEST $CLI volume quota $V0 hard-timeout 0
@@ -50,13 +32,13 @@ TEST $CLI volume quota $V0 hard-timeout 0
TEST ! $QDD $M0/test/file1.txt 256 48
TEST rm $M0/test/file1.txt
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" usage "/test"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test"
TEST $QDD $M0/test/file2.txt 256 32
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" usage "/test"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test"
TEST rm $M0/test/file2.txt
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" usage "/test"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test"
TEST $CLI volume stop $V0
EXPECT "1" get_aux
diff --git a/tests/basic/quota-nfs.t b/tests/basic/quota-nfs.t
index ef337a7b3ae..f295aaee79b 100755
--- a/tests/basic/quota-nfs.t
+++ b/tests/basic/quota-nfs.t
@@ -4,13 +4,6 @@
. $(dirname $0)/../volume.rc
. $(dirname $0)/../nfs.rc
-function usage()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | \
- grep "$QUOTA_PATH" | awk '{print $4}'
-}
-
cleanup;
QDD=$(dirname $0)/quota
# compile the test write program and run it
@@ -42,7 +35,7 @@ TEST $CLI volume quota $V0 hard-timeout 0
TEST $QDD $N0/$deep/newfile_1 256 20
# wait for write behind to complete.
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" usage "/"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" quotausage "/"
# Try to create a 100Mb file which should fail
TEST ! $QDD $N0/$deep/newfile_2 256 400
diff --git a/tests/basic/quota.t b/tests/basic/quota.t
index 5552c4fdc3d..ec8fa0afcb9 100755
--- a/tests/basic/quota.t
+++ b/tests/basic/quota.t
@@ -20,24 +20,6 @@ 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
@@ -58,16 +40,16 @@ 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
@@ -81,20 +63,20 @@ 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 $MARKER_UPDATE_TIMEOUT "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" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
TEST rm $M0/test_dir/2.txt
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
## rename tests
TEST $QDD $M0/test_dir/2 256 32
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
TEST mv $M0/test_dir/2 $M0/test_dir/0
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quotausage "/test_dir"
TEST rm $M0/test_dir/0
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" usage "/test_dir"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quotausage "/test_dir"
## ---------------------------
@@ -112,7 +94,7 @@ 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";
## -----------------------------
diff --git a/tests/bugs/disperse/bug-1227869.t b/tests/bugs/disperse/bug-1227869.t
index 83dc7655592..00fad825fae 100644
--- a/tests/bugs/disperse/bug-1227869.t
+++ b/tests/bugs/disperse/bug-1227869.t
@@ -9,12 +9,6 @@ QDD=$(dirname $0)/quota
# compile the test write program and run it
build_tester $(dirname $0)/../../basic/quota.c -o $QDD
-function usage()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}'
-}
-
TEST glusterd
TEST pidof glusterd
TEST $CLI volume create $V0 disperse 3 $H0:$B0/${V0}{1..3}
@@ -30,7 +24,7 @@ TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
TEST $QDD $M0/file 256 40
-EXPECT "10.0MB" usage "/"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "10.0MB" quotausage "/"
EXPECT "0" echo $(df -k $M0 | grep -q '10240 '; echo $?)
EXPECT "0" echo $(df -k $M0 | grep -q '92160 '; echo $?)
diff --git a/tests/bugs/distribute/bug-1161156.t b/tests/bugs/distribute/bug-1161156.t
index bedbf74ec05..572338a2257 100755
--- a/tests/bugs/distribute/bug-1161156.t
+++ b/tests/bugs/distribute/bug-1161156.t
@@ -4,13 +4,6 @@
. $(dirname $0)/../../volume.rc
. $(dirname $0)/../../nfs.rc
-function usage()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | \
- grep "$QUOTA_PATH" | awk '{print $4}'
-}
-
cleanup;
QDD=$(dirname $0)/quota
@@ -44,7 +37,7 @@ TEST $CLI volume quota $V0 hard-timeout 0
TEST $QDD $N0/$mydir/newfile_1 256 20
# wait for write behind to complete.
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" usage "/"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" quotausage "/"
TEST ! $QDD $N0/$mydir/newfile_2 256 40
# Test rename within a directory. It should pass even when the
diff --git a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
index 82921ff7b86..cac06a52960 100644
--- a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
+++ b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
@@ -16,7 +16,7 @@ TEST $CLI volume quota $V0 limit-usage /d 1MB
TEST touch $M0/d/a
echo abc > $M0/d/a
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "512Bytes" quota_usage "/"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "512Bytes" quotausage "/"
#Set the acl xattrs directly on backend, for some reason on mount it gives error
acl_access_val="0x0200000001000600ffffffff04000400ffffffff10000400ffffffff20000400ffffffff"
diff --git a/tests/bugs/quota/bug-1038598.t b/tests/bugs/quota/bug-1038598.t
index 10fdb23424f..7d69a98cbd4 100644
--- a/tests/bugs/quota/bug-1038598.t
+++ b/tests/bugs/quota/bug-1038598.t
@@ -14,37 +14,6 @@ TEST $CLI volume info;
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2};
-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}'
-}
-
-function sl_exceeded()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $6}'
-}
-
-function hl_exceeded()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $7}'
-
-}
-
EXPECT "$V0" volinfo_field $V0 'Volume Name';
EXPECT 'Created' volinfo_field $V0 'Status';
EXPECT '2' brick_count $V0
@@ -60,26 +29,26 @@ TEST glusterfs -s $H0 --volfile-id $V0 $M0;
TEST mkdir -p $M0/test_dir
TEST $CLI volume quota $V0 limit-usage /test_dir 10MB 50
-EXPECT "10.0MB" hard_limit "/test_dir";
-EXPECT "50%" soft_limit "/test_dir";
+EXPECT "10.0MB" quota_hard_limit "/test_dir";
+EXPECT "50%" quota_soft_limit "/test_dir";
TEST $QDD $M0/test_dir/file1.txt 256 16
-EXPECT "4.0MB" usage "/test_dir";
-EXPECT 'No' sl_exceeded "/test_dir";
-EXPECT 'No' hl_exceeded "/test_dir";
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "4.0MB" quotausage "/test_dir";
+EXPECT 'No' quota_sl_exceeded "/test_dir";
+EXPECT 'No' quota_hl_exceeded "/test_dir";
TEST $QDD $M0/test_dir/file1.txt 256 24
-EXPECT "6.0MB" usage "/test_dir";
-EXPECT 'Yes' sl_exceeded "/test_dir";
-EXPECT 'No' hl_exceeded "/test_dir";
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "6.0MB" quotausage "/test_dir";
+EXPECT 'Yes' quota_sl_exceeded "/test_dir";
+EXPECT 'No' quota_hl_exceeded "/test_dir";
#set timeout to 0 so that quota gets enforced without any lag
TEST $CLI volume set $V0 features.hard-timeout 0
TEST $CLI volume set $V0 features.soft-timeout 0
TEST ! $QDD $M0/test_dir/file1.txt 256 60
-EXPECT 'Yes' sl_exceeded "/test_dir";
-EXPECT 'Yes' hl_exceeded "/test_dir";
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT 'Yes' quota_sl_exceeded "/test_dir";
+EXPECT 'Yes' quota_hl_exceeded "/test_dir";
TEST $CLI volume stop $V0
EXPECT "1" get_aux
diff --git a/tests/bugs/quota/bug-1178130.t b/tests/bugs/quota/bug-1178130.t
index a1ed1109580..f75bcd4f03c 100644
--- a/tests/bugs/quota/bug-1178130.t
+++ b/tests/bugs/quota/bug-1178130.t
@@ -9,12 +9,6 @@
cleanup;
-function usage()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}'
-}
-
QDD=$(dirname $0)/quota
# compile the test write program and run it
build_tester $(dirname $0)/../../basic/quota.c -o $QDD
@@ -35,7 +29,7 @@ TEST $CLI volume quota $V0 hard-timeout 0
TEST $CLI volume quota $V0 soft-timeout 0
TEST $QDD $M0/file 256 40
-EXPECT "10.0MB" usage "/"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "10.0MB" quotausage "/"
TEST kill_brick $V0 $H0 $B0/${V0}2
TEST mv $M0/file $M0/file2
@@ -45,7 +39,7 @@ TEST $CLI volume start $V0 force;
EXPECT_WITHIN $HEAL_TIMEOUT "0" STAT "$B0/${V0}2/file2"
#usage should remain same after rename and self-heal operation
-EXPECT "10.0MB" usage "/"
+EXPECT "10.0MB" quotausage "/"
TEST $CLI volume stop $V0
TEST $CLI volume delete $V0
diff --git a/tests/bugs/quota/bug-1235182.t b/tests/bugs/quota/bug-1235182.t
index 0bd43a9cb04..ec62b69638d 100644
--- a/tests/bugs/quota/bug-1235182.t
+++ b/tests/bugs/quota/bug-1235182.t
@@ -9,12 +9,6 @@
cleanup;
-function usage()
-{
- local QUOTA_PATH=$1;
- $CLI volume quota $V0 list $QUOTA_PATH | grep "$QUOTA_PATH" | awk '{print $4}'
-}
-
QDD=$(dirname $0)/quota
# compile the test write program and run it
build_tester $(dirname $0)/../../basic/quota.c -o $QDD
@@ -47,7 +41,7 @@ echo "Wait for process with pid $PID to complete"
wait $PID
echo "Process with pid $PID finished"
-EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "100.0MB" usage "/"
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "100.0MB" quotausage "/"
TEST $CLI volume stop $V0
TEST $CLI volume delete $V0
diff --git a/tests/bugs/quota/inode-quota.t b/tests/bugs/quota/inode-quota.t
index 1b04f4062fb..cad63e1fd3c 100644
--- a/tests/bugs/quota/inode-quota.t
+++ b/tests/bugs/quota/inode-quota.t
@@ -80,6 +80,7 @@ EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quota_list_field "/test_dir" 2
# try creating a 15MB file and it should succeed
TEST ! $QDD $M0/test_dir/test2.txt 256 60
TEST rm -f $M0/test_dir/test2.txt
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quota_list_field "/test_dir" 2
#------------------------------------------------------
diff --git a/tests/volume.rc b/tests/volume.rc
index 8782f461850..4bbaf108cd1 100644
--- a/tests/volume.rc
+++ b/tests/volume.rc
@@ -559,19 +559,42 @@ function drop_cache() {
function quota_list_field () {
local QUOTA_PATH=$1
local FIELD=$2
- $CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH\
- | awk '{print $FIELD}'
+ local cmd="$CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH | awk '{print \$$FIELD}'"
+
+ $cmd
}
function quota_object_list_field () {
local QUOTA_PATH=$1
local FIELD=$2
- $CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH\
- | awk '{print $FIELD}'
+ local cmd="$CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH | awk '{print \$$FIELD}'"
+
+ $cmd
}
-function quota_usage()
+function quotausage()
{
quota_list_field $1 4
}
+function quota_hard_limit()
+{
+ quota_list_field $1 2
+}
+
+function quota_soft_limit()
+{
+ quota_list_field $1 3
+}
+
+function quota_sl_exceeded()
+{
+ quota_list_field $1 6
+}
+
+function quota_hl_exceeded()
+{
+ quota_list_field $1 7
+
+}
+