diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/basic/ec/quota.t | 9 | ||||
-rwxr-xr-x | tests/basic/quota-ancestry-building.t | 8 | ||||
-rwxr-xr-x | tests/basic/quota-anon-fd-nfs.t | 11 | ||||
-rwxr-xr-x | tests/basic/quota-nfs.t | 13 | ||||
-rw-r--r-- | tests/basic/quota.c | 82 | ||||
-rwxr-xr-x | tests/basic/quota.t | 18 | ||||
-rw-r--r-- | tests/bugs/distribute/bug-1099890.t | 15 | ||||
-rwxr-xr-x | tests/bugs/distribute/bug-1161156.t | 13 | ||||
-rw-r--r-- | tests/bugs/quota/bug-1023974.t | 11 | ||||
-rw-r--r-- | tests/bugs/quota/bug-1038598.t | 12 | ||||
-rw-r--r-- | tests/bugs/quota/bug-1087198.t | 15 | ||||
-rw-r--r-- | tests/bugs/quota/inode-quota.t | 13 |
12 files changed, 157 insertions, 63 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; diff --git a/tests/bugs/distribute/bug-1099890.t b/tests/bugs/distribute/bug-1099890.t index f48162c972b..40f70d4938b 100644 --- a/tests/bugs/distribute/bug-1099890.t +++ b/tests/bugs/distribute/bug-1099890.t @@ -10,6 +10,10 @@ cleanup; +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + TEST glusterd; TEST pidof glusterd; @@ -49,14 +53,14 @@ EXPECT "150M" echo `df -h $M0 -P | tail -1 | awk {'print $2'}` # Create a new file 'foo' under the root of the volume, which hashes to subvol-0 # of DHT, that consumes 40M -TEST dd if=/dev/zero of=$M0/foo bs=5120k count=8 +TEST $QDD $M0/foo 256 160 TEST stat $B0/${V0}1/foo TEST ! stat $B0/${V0}2/foo # Create a new file 'bar' under the root of the volume, which hashes to subvol-1 # of DHT, that consumes 40M -TEST dd if=/dev/zero of=$M0/bar bs=5120k count=8 +TEST $QDD $M0/bar 256 160 TEST ! stat $B0/${V0}1/bar TEST stat $B0/${V0}2/bar @@ -84,7 +88,7 @@ TEST touch $M0/empty1; # If this bug is fixed, then DHT should be routing the creation to subvol-1 only # as it has more than min-free-disk space available. -TEST dd if=/dev/zero of=$M0/file bs=1k count=1 +TEST $QDD $M0/file 1 1 sleep 1; TEST ! stat $B0/${V0}1/file TEST stat $B0/${V0}2/file @@ -96,7 +100,7 @@ TEST touch $M0/empty2; # Now I create a new file that hashes to subvol-0, at the end of which, there # will be less than min-free-disk space available on it. -TEST dd if=/dev/zero of=$M0/fil bs=5120k count=4 +TEST $QDD $M0/fil 256 80 sleep 1; TEST stat $B0/${V0}1/fil TEST ! stat $B0/${V0}2/fil @@ -108,7 +112,7 @@ TEST touch $M0/empty3; # Now I create a file that hashes to subvol-0 but since it has less than # min-free-disk space available, its data will be cached on subvol-1. -TEST dd if=/dev/zero of=$M0/zz bs=5120k count=1 +TEST $QDD $M0/zz 256 20 TEST stat $B0/${V0}1/zz TEST stat $B0/${V0}2/zz @@ -123,4 +127,5 @@ EXPECT "1" get_aux UMOUNT_LOOP ${B0}/${V0}{1,2} rm -f ${B0}/brick{1,2} +rm -f $QDD cleanup diff --git a/tests/bugs/distribute/bug-1161156.t b/tests/bugs/distribute/bug-1161156.t index cc9522dc1a8..bedbf74ec05 100755 --- a/tests/bugs/distribute/bug-1161156.t +++ b/tests/bugs/distribute/bug-1161156.t @@ -13,6 +13,10 @@ function usage() cleanup; +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + TEST glusterd TEST pidof glusterd TEST $CLI volume info; @@ -30,7 +34,7 @@ mydir="dir" TEST mkdir -p $N0/$mydir TEST mkdir -p $N0/newdir -TEST dd if=/dev/zero of=$N0/$mydir/file bs=1k count=10240 +TEST $QDD $N0/$mydir/file 256 40 TEST $CLI volume quota $V0 enable TEST $CLI volume quota $V0 limit-usage / 20MB @@ -38,10 +42,10 @@ TEST $CLI volume quota $V0 limit-usage /newdir 5MB TEST $CLI volume quota $V0 soft-timeout 0 TEST $CLI volume quota $V0 hard-timeout 0 -TEST dd if=/dev/zero of=$N0/$mydir/newfile_1 bs=512 count=10240 +TEST $QDD $N0/$mydir/newfile_1 256 20 # wait for write behind to complete. EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" usage "/" -TEST ! dd if=/dev/zero of=$N0/$mydir/newfile_2 bs=1k count=10240 conv=fdatasync +TEST ! $QDD $N0/$mydir/newfile_2 256 40 # Test rename within a directory. It should pass even when the # corresponding directory quota is filled. @@ -53,4 +57,7 @@ TEST ! mv $N0/dir/newfile_3 $N0/newdir/ umount_nfs $N0 TEST $CLI volume stop $V0 EXPECT "1" get_aux + +rm -f $QDD + cleanup; diff --git a/tests/bugs/quota/bug-1023974.t b/tests/bugs/quota/bug-1023974.t index 06b66bf35a3..2fb93320045 100644 --- a/tests/bugs/quota/bug-1023974.t +++ b/tests/bugs/quota/bug-1023974.t @@ -9,6 +9,10 @@ cleanup; +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + TEST glusterd TEST pidof glusterd; TEST $CLI volume info; @@ -26,13 +30,16 @@ TEST $CLI volume quota $V0 hard-timeout 0 TEST $CLI volume quota $V0 soft-timeout 0 #The corresponding write(3) should fail with EDQUOT ("Disk quota exceeded") -TEST ! dd if=/dev/urandom of=$M0/1/2/file bs=1024k count=102; +TEST ! $QDD $M0/1/2/file 256 408 TEST mkdir -p $M0/1/3; -TEST dd if=/dev/urandom of=$M0/1/3/file bs=1024k count=102; +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; TEST $CLI volume stop $V0 EXPECT "1" get_aux + +rm -f $QDD + cleanup; diff --git a/tests/bugs/quota/bug-1038598.t b/tests/bugs/quota/bug-1038598.t index d930a4f62e8..10fdb23424f 100644 --- a/tests/bugs/quota/bug-1038598.t +++ b/tests/bugs/quota/bug-1038598.t @@ -4,6 +4,10 @@ cleanup; +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + TEST glusterd TEST pidof glusterd TEST $CLI volume info; @@ -59,12 +63,12 @@ TEST $CLI volume quota $V0 limit-usage /test_dir 10MB 50 EXPECT "10.0MB" hard_limit "/test_dir"; EXPECT "50%" soft_limit "/test_dir"; -TEST dd if=/dev/zero of=$M0/test_dir/file1.txt bs=1024k count=4 +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"; -TEST dd if=/dev/zero of=$M0/test_dir/file1.txt bs=1024k count=6 +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"; @@ -73,10 +77,12 @@ EXPECT 'No' hl_exceeded "/test_dir"; TEST $CLI volume set $V0 features.hard-timeout 0 TEST $CLI volume set $V0 features.soft-timeout 0 -TEST ! dd if=/dev/zero of=$M0/test_dir/file1.txt bs=1024k count=15 +TEST ! $QDD $M0/test_dir/file1.txt 256 60 EXPECT 'Yes' sl_exceeded "/test_dir"; EXPECT 'Yes' hl_exceeded "/test_dir"; TEST $CLI volume stop $V0 EXPECT "1" get_aux +rm -f $QDD + cleanup; diff --git a/tests/bugs/quota/bug-1087198.t b/tests/bugs/quota/bug-1087198.t index 6eaae076fcc..44aa1b75e7a 100644 --- a/tests/bugs/quota/bug-1087198.t +++ b/tests/bugs/quota/bug-1087198.t @@ -19,6 +19,10 @@ cleanup; +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + #1 ## Step 1 TEST glusterd @@ -54,11 +58,11 @@ TEST $CLI volume quota $V0 limit-usage /$QUOTA_LIMIT_DIR 100KB #16 ## Step 3 and 4 -TEST dd if=/dev/urandom of=$N0/$QUOTA_LIMIT_DIR/95KB_file bs=1k count=95 +TEST $QDD $N0/$QUOTA_LIMIT_DIR/95KB_file 1 95 #Uncomment below TEST once the bug# 1202292 is fixed #TEST grep -e "\"Usage crossed soft limit:.*used by /$QUOTA_LIMIT_DIR\"" -- $BRICK_LOG_DIR/* -TEST dd if=/dev/urandom of=$N0/100KB_file bs=1k count=100 +TEST $QDD $N0/100KB_file 1 100 #Uncomment below TEST once the bug# 1202292 is fixed #TEST grep -e "\"Usage crossed soft limit:.*used by /\"" -- $BRICK_LOG_DIR/* @@ -67,11 +71,11 @@ TEST dd if=/dev/urandom of=$N0/100KB_file bs=1k count=100 TEST sleep 10 ## Step 6 -TEST dd if=/dev/urandom of=$N0/$QUOTA_LIMIT_DIR/1KB_file bs=1k count=1 +TEST $QDD $N0/$QUOTA_LIMIT_DIR/1KB_file 1 1 TEST grep -e "\"Usage is above soft limit:.*used by /$QUOTA_LIMIT_DIR\"" -- $BRICK_LOG_DIR/* #23 -TEST dd if=/dev/urandom of=$N0/1KB_file bs=1k count=1 +TEST $QDD $N0/1KB_file 1 1 TEST grep -e "\"Usage is above soft limit:.*used by /\"" -- $BRICK_LOG_DIR/* #25 @@ -80,4 +84,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/bugs/quota/inode-quota.t b/tests/bugs/quota/inode-quota.t index 58376d5058f..55a26fa0d2b 100644 --- a/tests/bugs/quota/inode-quota.t +++ b/tests/bugs/quota/inode-quota.t @@ -20,6 +20,10 @@ function quota_object_list_field () { cleanup; +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + TESTS_EXPECTED_IN_LOOP=9 TEST glusterd @@ -81,18 +85,14 @@ EXPECT "10" quota_object_list_field "/test_dir" 2 # Check the quota enforcement mechanism for usage #----------------------------------------------------- -# Compile the program which basically created a file -# of required size -TEST $CC $(dirname $0)/../../basic/quota.c -o $(dirname $0)/quota - # try creating a 8MB file and it should fail -TEST $(dirname $0)/quota $M0/test_dir/test1.txt '8388608' +TEST $QDD $M0/test_dir/test1.txt 256 32 EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "8.0MB" quota_list_field "/test_dir" 2 TEST rm -f $M0/test_dir/test1.txt EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "0Bytes" quota_list_field "/test_dir" 2 # try creating a 15MB file and it should succeed -TEST ! $(dirname $0)/quota $M0/test_dir/test2.txt '15728640' +TEST ! $QDD $M0/test_dir/test2.txt 256 60 TEST rm -f $M0/test_dir/test2.txt @@ -130,4 +130,5 @@ TEST $CLI volume stop $V0 EXPECT "1" get_aux TEST $CLI volume delete $V0 +rm -f $QDD cleanup; |