summaryrefslogtreecommitdiffstats
path: root/tests/basic
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-05-28 12:30:02 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-05-28 23:29:07 -0700
commitf6e72c45ad754073bc8269e954d236bab9e4a0e7 (patch)
treebd2ab7c55e85aab08cfbf6ccaa151ea1158e97ac /tests/basic
parente3408108e36dac08d217f558b5cc69dff71bbcbf (diff)
Quota: fix testcases not to send parallel writes for accurate
quota enforcement This is a backport of http://review.gluster.org/#/c/10878 > Currently quota enforcer doesn't consider parallel writes > and allows quota to exceed limit where there are high rate > of parallel writes. Bug# 1223658 tracks the issue. > > This patch fixes the spurious failures by not sending > parallel writes. > Using O_SYNC and O_APPEND flags and block size > not more that 256k (For higher block size NFS client > splits the block into 256k chinks and does parallel writes) > > Change-Id: I297c164b030cecb87ce5b494c02b09e8b073b276 > BUG: 1223798 > Signed-off-by: vmallika <vmallika@redhat.com> > Reviewed-on: http://review.gluster.org/10878 > Tested-by: NetBSD Build System > Tested-by: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Raghavendra G <rgowdapp@redhat.com> > Tested-by: Raghavendra G <rgowdapp@redhat.com> Change-Id: I78b6250eb0b3fbbbab1d4348d4e81d6292c6c6bb BUG: 1224894 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/10910 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'tests/basic')
-rwxr-xr-xtests/basic/ec/quota.t9
-rwxr-xr-xtests/basic/quota-ancestry-building.t8
-rwxr-xr-xtests/basic/quota-anon-fd-nfs.t11
-rwxr-xr-xtests/basic/quota-nfs.t13
-rw-r--r--tests/basic/quota.c82
-rwxr-xr-xtests/basic/quota.t18
6 files changed, 101 insertions, 40 deletions
diff --git a/tests/basic/ec/quota.t b/tests/basic/ec/quota.t
index 0dbc07738d2..cc2d4bd9efa 100755
--- a/tests/basic/ec/quota.t
+++ b/tests/basic/ec/quota.t
@@ -22,6 +22,9 @@ function usage()
}
cleanup
+QDD=$(dirname $0)/quota
+# compile the test write program and run it
+build_tester $(dirname $0)/../quota.c -o $QDD
TEST glusterd
TEST pidof glusterd
@@ -44,13 +47,12 @@ EXPECT "80%" soft_limit "/test";
TEST $CLI volume quota $V0 soft-timeout 0
TEST $CLI volume quota $V0 hard-timeout 0
-TEST ! dd if=/dev/urandom of=$M0/test/file1.txt bs=1024k count=12
-sleep 5
+TEST ! $QDD $M0/test/file1.txt 256 48
TEST rm $M0/test/file1.txt
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" usage "/test"
-TEST dd if=/dev/urandom of=$M0/test/file2.txt bs=1024k count=8
+TEST $QDD $M0/test/file2.txt 256 32
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" usage "/test"
TEST rm $M0/test/file2.txt
@@ -58,4 +60,5 @@ EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" usage "/test"
TEST $CLI volume stop $V0
EXPECT "1" get_aux
+rm -f $QDD
cleanup;
diff --git a/tests/basic/quota-ancestry-building.t b/tests/basic/quota-ancestry-building.t
index e86e1e250ee..5824db37879 100755
--- a/tests/basic/quota-ancestry-building.t
+++ b/tests/basic/quota-ancestry-building.t
@@ -8,6 +8,10 @@ cleanup;
# This tests quota enforcing on an inode without any path information.
# This should cover anon-fd type of workload as well.
+QDD=$(dirname $0)/quota
+# compile the test write program and run it
+build_tester $(dirname $0)/quota.c -o $QDD
+
TESTS_EXPECTED_IN_LOOP=8
TEST glusterd
TEST pidof glusterd
@@ -37,7 +41,7 @@ TEST fd_open 5 'w' "$M0/$deep/file3"
TEST fd_open 6 'w' "$M0/$deep/file4"
# consume all quota
-TEST ! dd if=/dev/zero of="$M0/$deep/file" bs=1000000 count=1
+TEST ! $QDD $M0/$deep/file 256 4
# simulate name-less lookups for re-open where the parent information is lost.
# Stopping and starting the bricks will trigger client re-open which happens on
@@ -62,4 +66,6 @@ exec 6>&-
TEST $CLI volume stop $V0
EXPECT "1" get_aux
+
+rm -f $QDD
cleanup;
diff --git a/tests/basic/quota-anon-fd-nfs.t b/tests/basic/quota-anon-fd-nfs.t
index 6af8a3c7375..aaba0b1d16e 100755
--- a/tests/basic/quota-anon-fd-nfs.t
+++ b/tests/basic/quota-anon-fd-nfs.t
@@ -7,6 +7,10 @@
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=16
TEST glusterd
TEST pidof glusterd
@@ -62,10 +66,8 @@ echo "World" >> $N0/$deep/new_file_1
echo 1 >> $N0/$deep/new_file_1
echo 2 >> $N0/$deep/new_file_1
-# compile the test write program and run it
-build_tester $(dirname $0)/quota.c -o $(dirname $0)/quota;
# Try to create a 1M file which should fail
-TEST ! $(dirname $0)/quota $N0/$deep/new_file_2 "1048576"
+TEST ! $QDD $N0/$deep/new_file_2 256 4
# At the end of each fop in server, reference count of the
@@ -96,4 +98,7 @@ EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0
TEST $CLI volume stop $V0
EXPECT "1" get_aux
+
+rm -f $QDD
+
cleanup;
diff --git a/tests/basic/quota-nfs.t b/tests/basic/quota-nfs.t
index db73debef58..ef337a7b3ae 100755
--- a/tests/basic/quota-nfs.t
+++ b/tests/basic/quota-nfs.t
@@ -12,6 +12,9 @@ function usage()
}
cleanup;
+QDD=$(dirname $0)/quota
+# compile the test write program and run it
+build_tester $(dirname $0)/quota.c -o $QDD
TEST glusterd
TEST pidof glusterd
@@ -30,21 +33,19 @@ TEST mount_nfs $H0:/$V0 $N0
deep=/0/1/2/3/4/5/6/7/8/9
TEST mkdir -p $N0/$deep
-TEST dd if=/dev/zero of=$N0/$deep/file bs=1k count=10240
+TEST $QDD $N0/$deep/file 256 40
TEST $CLI volume quota $V0 enable
TEST $CLI volume quota $V0 limit-usage / 20MB
TEST $CLI volume quota $V0 soft-timeout 0
TEST $CLI volume quota $V0 hard-timeout 0
-TEST dd if=/dev/zero of=$N0/$deep/newfile_1 bs=512 count=10240
+TEST $QDD $N0/$deep/newfile_1 256 20
# wait for write behind to complete.
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" usage "/"
-# compile the test write program and run it
-TEST $CC $(dirname $0)/quota.c -o $(dirname $0)/quota;
# Try to create a 100Mb file which should fail
-TEST ! $(dirname $0)/quota $N0/$deep/newfile_2 "104857600"
+TEST ! $QDD $N0/$deep/newfile_2 256 400
TEST rm -f $N0/$deep/newfile_2
## Before killing daemon to avoid deadlocks
@@ -52,4 +53,6 @@ umount_nfs $N0
TEST $CLI volume stop $V0
EXPECT "1" get_aux
+
+rm -f $QDD
cleanup;
diff --git a/tests/basic/quota.c b/tests/basic/quota.c
index 4cc0322e132..50f56d6d718 100644
--- a/tests/basic/quota.c
+++ b/tests/basic/quota.c
@@ -3,45 +3,87 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+
+ssize_t
+nwrite (int fd, const void *buf, size_t count)
+{
+ ssize_t ret = 0;
+ ssize_t written = 0;
+
+ for (written = 0; written != count; written += ret) {
+ ret = write (fd, buf + written, count - written);
+ if (ret < 0) {
+ if (errno == EINTR)
+ ret = 0;
+ else
+ goto out;
+ }
+ }
+
+ ret = written;
+out:
+ return ret;
+}
int
-file_write (char *filename, int filesize)
+file_write (char *filename, int bs, int count)
{
- int fd, ret = 0;
- int i = 0;
- char buf[1024] = {'a',};
- fd = open (filename, O_RDWR|O_CREAT|O_APPEND, 0600);
- while (i < filesize) {
- ret = write(fd, buf, sizeof(buf));
+ int fd = 0;
+ int ret = -1;
+ int i = 0;
+ char *buf = NULL;
+
+ bs = bs * 1024;
+
+ buf = (char *) malloc (bs);
+ if (buf == NULL)
+ goto out;
+
+ memset (buf, 0, bs);
+
+ fd = open (filename, O_RDWR|O_CREAT|O_SYNC, 0600);
+ while (i < count) {
+ ret = nwrite(fd, buf, bs);
if (ret == -1) {
close (fd);
- return ret;
- }
- i += sizeof(buf);
- ret = fdatasync(fd);
- if (ret) {
- close (fd);
- return ret;
+ goto out;
}
+ i++;
}
+
+ ret = fdatasync(fd);
+ if (ret) {
+ close (fd);
+ goto out;
+ }
+
ret = close(fd);
if (ret)
- return ret;
+ goto out;
- return 0;
+ ret = 0;
+
+out:
+ if (buf)
+ free (buf);
+ return ret;
}
int
main (int argc, char **argv)
{
- if (argc != 3) {
- printf("Usage: %s <filename> <size(in bytes)>\n", argv[0]);
+ if (argc != 4) {
+ printf("Usage: %s <filename> <block size in k> <count>\n",
+ argv[0]);
return EXIT_FAILURE;
}
- printf ("argv[2] is %s\n", argv[2]);
- if (file_write (argv[1], atoi(argv[2])) == -1)
+ if (file_write (argv[1], atoi(argv[2]), atoi(argv[3])) < 0) {
+ perror ("write failed");
return EXIT_FAILURE;
+ }
return EXIT_SUCCESS;
}
diff --git a/tests/basic/quota.t b/tests/basic/quota.t
index 7a3aaee2bcf..5552c4fdc3d 100755
--- a/tests/basic/quota.t
+++ b/tests/basic/quota.t
@@ -8,6 +8,10 @@
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
@@ -72,22 +76,20 @@ TEST $CLI volume quota $V0 hard-timeout 0
## Verify quota enforcement
## -----------------------------
-# compile the test write program and run it
-TEST $CC $(dirname $0)/quota.c -o $(dirname $0)/quota;
# Try to create a 12MB file which should fail
-TEST ! $(dirname $0)/quota $M0/test_dir/1.txt "12582912"
+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"
-TEST dd if=/dev/urandom of=$M0/test_dir/2.txt bs=1024k count=8
+TEST $QDD $M0/test_dir/2.txt 256 32
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" usage "/test_dir"
TEST rm $M0/test_dir/2.txt
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" usage "/test_dir"
## rename tests
-TEST dd if=/dev/urandom of=$M0/test_dir/2 bs=1024k count=8
+TEST $QDD $M0/test_dir/2 256 32
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" usage "/test_dir"
TEST mv $M0/test_dir/2 $M0/test_dir/0
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" usage "/test_dir"
@@ -144,8 +146,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=1024k count=10;
+ TEST_IN_LOOP $QDD "$M0/$TESTDIR/dir1/10MBfile$i" 256 40
done
# 63-64
@@ -160,7 +161,7 @@ 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=1024k count=1 \
+ $QDD of="$M0/$TESTDIR/dir1/1MBfile$i" 256 4\
2>&1 | egrep -v '(No space left|Disc quota exceeded)'
done
@@ -194,4 +195,5 @@ EXPECT 'Stopped' volinfo_field $V0 'Status';
TEST $CLI volume delete $V0;
TEST ! $CLI volume info $V0;
+rm -f $QDD
cleanup;