From 79683794c2ee9c6b5c1182e2a378598c2037a9ff Mon Sep 17 00:00:00 2001 From: Susant Palai Date: Thu, 12 Dec 2013 06:20:55 +0000 Subject: quota: filter glusterfs quota xattrs Change-Id: I86ebe02735ee88598640240aa888e02b48ecc06c BUG: 1040423 Signed-off-by: Susant Palai Reviewed-on: http://review.gluster.org/6490 Tested-by: Gluster Build System Reviewed-by: Raghavendra G --- tests/bugs/bug-1040423.t | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 tests/bugs/bug-1040423.t (limited to 'tests') diff --git a/tests/bugs/bug-1040423.t b/tests/bugs/bug-1040423.t new file mode 100755 index 000000000..6dae9eac6 --- /dev/null +++ b/tests/bugs/bug-1040423.t @@ -0,0 +1,72 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup + +function _init() { +# Start glusterd +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +# Lets create volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; + +## Verify volume is created +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +#Start volume and verify +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 + +#Enable Quota +TEST $CLI volume quota $V0 enable + +#As quotad consumes some time to connect to brick process we invoke sleep +sleep 10; + +#set limit of 1GB of quota on root +TEST $CLI volume quota $V0 limit-usage / 1GB +} + +function get_hardlimit() +{ + VOLUME=$1 + + $CLI volume quota $VOLUME list | tail -1 | sed "s/ \{1,\}/ /g" | + cut -d' ' -f 2 +} + +function check_fattrs { + +touch $M0/file1; + +#This confirms that pgfid is also filtered +TEST ! "getfattr -d -e hex -m . $M0/file1 | grep pgfid "; + +#just check for quota xattr are visible or not +TEST ! "getfattr -d -e hex -m . $M0 | grep quota"; + +#setfattr should fail +TEST ! setfattr -n trusted.glusterfs.quota.limit-set -v 10 $M0; + +#remove xattr should fail +TEST ! setfattr -x trusted.glusterfs.quota.limit-set $M0; + +#check if list command still shows the correct value or not + +EXPECT "1.0GB" get_hardlimit $V0 + +} + +_init; +check_fattrs; +cleanup + + + + -- cgit From 6c9fe8fa8896c5f4fbe8c9bac6c2c7f9add92a0b Mon Sep 17 00:00:00 2001 From: Varun Shastry Date: Mon, 2 Dec 2013 15:49:58 +0530 Subject: cluster/dht: Set quota limit key in dht_selfheal of dirs. Also fixed check in dht_is_subvol_in_layout to check if the layouts are zero'ed out. Change-Id: I4bf8ebf66d3ef1946309b6c9aac9e79bf8a6d495 BUG: 969461 Signed-off-by: shishir gowda Signed-off-by: Varun Shastry Reviewed-on: http://review.gluster.org/6392 Reviewed-by: Raghavendra G Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- tests/basic/quota.t | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'tests') diff --git a/tests/basic/quota.t b/tests/basic/quota.t index 5c531adbf..81b1c2100 100755 --- a/tests/basic/quota.t +++ b/tests/basic/quota.t @@ -5,6 +5,8 @@ cleanup; +TESTS_EXPECTED_IN_LOOP=19 + TEST glusterd TEST pidof glusterd TEST $CLI volume info; @@ -102,6 +104,75 @@ TEST $CLI volume quota $V0 limit-usage /test_dir/in_test_dir 150MB EXPECT "150.0MB" hard_limit "/test_dir/in_test_dir"; ## ----------------------------- + +################################################### +## ------------------------------------------------ +## +## ------------------------------------------------ +################################################### +QUOTALIMIT=1024 +QUOTALIMITROOT=2048 +TESTDIR="addbricktest" + +rm -rf $M0/*; + +## +## ----------------------------- +# 41-42 +TEST mkdir $M0/$TESTDIR +TEST mkdir $M0/$TESTDIR/dir{1..10}; + + +# 43-52 +## +## ----------------------------- +TEST $CLI volume quota $V0 limit-usage / "$QUOTALIMITROOT"MB; +for i in {1..10}; do + TEST_IN_LOOP $CLI volume quota $V0 limit-usage /$TESTDIR/dir$i \ + "$QUOTALIMIT"MB; +done +## + +#53-62 +for i in `seq 1 9`; do + TEST_IN_LOOP dd if=/dev/urandom of="$M0/$TESTDIR/dir1/100MBfile$i" \ + bs=1M count=100; +done + +# 63-64 +## +## ------------------------------- +TEST $CLI volume add-brick $V0 $H0:$B0/brick{3,4} +TEST $CLI volume rebalance $V0 start; + + +## +## -------------------------------- +for i in `seq 1 200`; do + dd if=/dev/urandom of="$M0/$TESTDIR/dir1/10MBfile$i" bs=1M count=10 \ + &>/dev/null +done + +# 65 +## +## --------------------------------------------------------- +USED_KB=`du -s $M0/$TESTDIR/dir1 | cut -f1`; +USED_MB=$(($USED_KB/1024)); +TEST [ $USED_MB -le $((($QUOTALIMIT * 110) / 100)) ] + +# 66-67 +## +## ------------------------------------- +TEST getfattr -d -m "trusted.glusterfs.quota.limit-set" -e hex \ + --absolute-names $B0/brick{3,4}/$TESTDIR/dir{1..10}; +# Test on root. +TEST getfattr -d -m "trusted.glusterfs.quota.limit-set" -e hex \ + --absolute-names $B0/brick{3,4}; + +## ------------------------------------------------- +## +## ------------------------------------------------- + TEST $CLI volume quota $V0 disable TEST $CLI volume stop $V0; EXPECT 'Stopped' volinfo_field $V0 'Status'; -- cgit From 460ed4184801d5346c58cc32a34704910345a184 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Thu, 23 Jan 2014 12:12:07 +0100 Subject: features/compress: rename "compress" option to "network.compression" Prevent mistaking the "compress" options for storage (at rest) compression. The cdc-xlator is implemented to support compressing of network traffic (READ and WRITE FOPs). URL: http://www.gluster.org/community/documentation/index.php/Features/On-Wire_Compression_+_Decompression Change-Id: I9fedf4106dcb226d135ab92e4b533aff284881d7 BUG: 1053670 CC: Venky Shankar CC: Prashanth Pai Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/6765 Reviewed-by: Prashanth Pai Reviewed-by: Kaleb KEITHLEY Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- tests/basic/cdc.t | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/basic/cdc.t b/tests/basic/cdc.t index 4cd915aa9..69f39f7d1 100755 --- a/tests/basic/cdc.t +++ b/tests/basic/cdc.t @@ -24,21 +24,21 @@ EXPECT 'off' volinfo_field $V0 'performance.quick-read' TEST $CLI volume set $V0 strict-write-ordering on EXPECT 'on' volinfo_field $V0 'performance.strict-write-ordering' -## Turn on cdc xlator by setting features.compress to on -TEST $CLI volume set $V0 compress on -EXPECT 'on' volinfo_field $V0 'features.compress' -EXPECT 'server' volinfo_field $V0 'compress.mode' +## Turn on cdc xlator by setting network.compression to on +TEST $CLI volume set $V0 network.compression on +EXPECT 'on' volinfo_field $V0 'network.compression' +EXPECT 'server' volinfo_field $V0 'network.compression.mode' -## Make sure that user cannot change compress.mode +## Make sure that user cannot change network.compression.mode ## This would break the cdc xlator if allowed! -TEST $CLI volume set $V0 compress.mode client -EXPECT 'server' volinfo_field $V0 'compress.mode' +TEST $CLI volume set $V0 network.compression.mode client +EXPECT 'server' volinfo_field $V0 'network.compression.mode' -## Turn on compress.debug option +## Turn on network.compression.debug option ## This will dump compressed data onto disk as gzip file ## This is used to check if compression actually happened -TEST $CLI volume set $V0 compress.debug on -EXPECT 'on' volinfo_field $V0 'compress.debug' +TEST $CLI volume set $V0 network.compression.debug on +EXPECT 'on' volinfo_field $V0 'network.compression.debug' ## Start the volume TEST $CLI volume start $V0; @@ -96,11 +96,11 @@ TEST umount $M0 TEST $CLI volume stop $V0; EXPECT 'Stopped' volinfo_field $V0 'Status'; -## Turn on compress.min-size and set it to 100 bytes +## Turn on network.compression.min-size and set it to 100 bytes ## Compression should not take place if file size ## is less than 100 bytes -TEST $CLI volume set $V0 compress.min-size 100 -EXPECT '100' volinfo_field $V0 'compress.min-size' +TEST $CLI volume set $V0 network.compression.min-size 100 +EXPECT '100' volinfo_field $V0 'network.compression.min-size' ## Start the volume TEST $CLI volume start $V0; @@ -118,11 +118,11 @@ TEST ! test -e /tmp/cdcdump.gz TEST rm -f /tmp/cdc* $M0/cdc* TEST umount $M0 -## Reset the compress options -TEST $CLI volume reset $V0 compress.debug -TEST $CLI volume reset $V0 compress.min-size -TEST $CLI volume reset $V0 compress.mode -TEST $CLI volume reset $V0 features.compress +## Reset the network.compression options +TEST $CLI volume reset $V0 network.compression.debug +TEST $CLI volume reset $V0 network.compression.min-size +TEST $CLI volume reset $V0 network.compression.mode +TEST $CLI volume reset $V0 network.compression ## Stop the volume TEST $CLI volume stop $V0; -- cgit From 48b8186bdc2f5e45b58aadf849b2bd60c9a77330 Mon Sep 17 00:00:00 2001 From: Dawit Alemu Date: Mon, 30 Dec 2013 22:59:39 -0500 Subject: cli: Add options to the CLI that let the user control the reset of stats "volume profile info" automatically clears incremental stats. There isn't a command to: - fetch stats without clearing incremental stats and - clear cumulative and incremental stats This change introduces two arguments (i.e. peek and clear). 'clear' will wipe both incremental and cumulative stats. 'peek' fetches stats without wiping incremental stats. 'volume profile info peek' - fetches incremental and cumulative stats without wiping incremental stats 'volume profile info incremental peek' - fetches incremental stats without wiping incremental stats 'volume profile info clear' - clears both incremental and cumultiave stats Change-Id: I91834515ad672eca5f882809941147d7d997c4c9 BUG: 1047416 Signed-off-by: Dawit Alemu Reviewed-on: http://review.gluster.org/6620 Tested-by: Gluster Build System Reviewed-by: Kaushal M Reviewed-by: Vijay Bellur --- tests/bugs/bug-1030580.t | 8 ------ tests/bugs/bug-1047416.t | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/volume.rc | 23 +++++++++++++++++ 3 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 tests/bugs/bug-1047416.t (limited to 'tests') diff --git a/tests/bugs/bug-1030580.t b/tests/bugs/bug-1030580.t index ed1cdb864..642c6dc44 100644 --- a/tests/bugs/bug-1030580.t +++ b/tests/bugs/bug-1030580.t @@ -9,14 +9,6 @@ function write_to_file { dd of=$M0/1 if=/dev/zero bs=1M count=128 oflag=append 2>&1 >/dev/null } -function cumulative_stat_count { - echo "$1" | grep "Cumulative Stats:" | wc -l -} - -function incremental_stat_count { - echo "$1" | grep "Interval$2Stats:" | wc -l -} - TEST glusterd TEST pidof glusterd TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 diff --git a/tests/bugs/bug-1047416.t b/tests/bugs/bug-1047416.t new file mode 100644 index 000000000..53c7f8614 --- /dev/null +++ b/tests/bugs/bug-1047416.t @@ -0,0 +1,66 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +function write_to_file { + dd of=$M0/1 if=/dev/zero bs=1M count=128 oflag=append 2>&1 >/dev/null +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 +TEST $CLI volume profile $V0 start +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + +# Verify 'volume profile info' prints both cumulative and incremental stats +write_to_file & +wait +output=$($CLI volume profile $V0 info) +EXPECT 2 cumulative_stat_count "$output" +EXPECT 2 incremental_stat_count "$output" ' 0 ' + +# Verify 'volume profile info peek' prints both cumulative and incremental stats +# without clearing incremental stats +write_to_file & +wait +output=$($CLI volume profile $V0 info peek) +EXPECT 2 cumulative_stat_count "$output" +EXPECT 2 incremental_stat_count "$output" ' 1 ' + +write_to_file & +wait +output=$($CLI volume profile $V0 info peek) +EXPECT 2 cumulative_stat_count "$output" +EXPECT 2 incremental_stat_count "$output" ' 1 ' + +# Verify 'volume profile info incremental peek' prints incremental stats only +# without clearing incremental stats +write_to_file & +wait +output=$($CLI volume profile $V0 info incremental peek) +EXPECT 0 cumulative_stat_count "$output" +EXPECT 2 incremental_stat_count "$output" ' 1 ' + +write_to_file & +wait +output=$($CLI volume profile $V0 info incremental peek) +EXPECT 0 cumulative_stat_count "$output" +EXPECT 2 incremental_stat_count "$output" ' 1 ' + +# Verify 'volume profile info clear' clears both incremental and cumulative stats +write_to_file & +wait +output=$($CLI volume profile $V0 info clear) +EXPECT 2 cleared_stat_count "$output" + +output=$($CLI volume profile $V0 info) +EXPECT 2 cumulative_stat_count "$output" +EXPECT 2 incremental_stat_count "$output" ' 0 ' +EXPECT 4 data_read_count "$output" ' 0 ' +EXPECT 4 data_written_count "$output" ' 0 ' + +cleanup; diff --git a/tests/volume.rc b/tests/volume.rc index b1aa904fb..5e2f95e76 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -279,3 +279,26 @@ function get_hex_xattr { local path=$2 getfattr -d -m. -e hex $2 2>/dev/null | grep $1 | cut -f2 -d'=' | cut -f2 -d'x' } + +function cumulative_stat_count { + echo "$1" | grep "Cumulative Stats:" | wc -l +} + +function incremental_stat_count { + echo "$1" | grep "Interval$2Stats:" | wc -l +} + +function cleared_stat_count { + echo "$1" | grep "Cleared stats." | wc -l +} + +function data_read_count { + echo "$1" | grep "Data Read:$2bytes" | wc -l +} + +function data_written_count { + echo "$1" | grep "Data Written:$2bytes" | wc -l +} + + + -- cgit From 9a34ea6a0a95154013676cabf8528b2679fb36c4 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Fri, 24 Jan 2014 18:30:32 -0800 Subject: tests: support regex in EXPECT constructs Instead of just strings, provide the ability to specify a regex of the pattern to expect Change-Id: I6ada978197dceecc28490a2a40de73a04ab9abcd Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/6788 Reviewed-by: Pranith Kumar Karampuri Tested-by: Gluster Build System --- tests/include.rc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/include.rc b/tests/include.rc index 0369d2610..44259872a 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -67,10 +67,10 @@ function test_expect_footer() local a=$2 local err="" - if [ "x${e}" != "x${a}" ]; then + if ! [[ "$a" =~ $e ]]; then err="Got \"$a\" instead of \"$e\"" fi - [[ "x${e}" == "x${a}" ]]; + [[ "$a" =~ $e ]]; test_footer "$err"; } @@ -96,11 +96,11 @@ function test_expect_not_footer() local a=$2 local err="" - if [ "x${e}" == "x${a}" ]; then + if [[ "$a" =~ $e ]]; then err="Got \"$a\" when not expecting it" fi - [[ "x${e}" != "x${a}" ]]; + ! [[ "$a" =~ "$e" ]]; test_footer "$err"; } -- cgit From 49eb5ea29cf8d6eab0c5f60d70fe8d6a0113b61e Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 2 Dec 2013 09:32:53 +0530 Subject: features/quota: remove in-memory accounting of files in enforcer Accounting was done in enforcer (though marker is the ultimate source of truth) to offset cached directory size becoming stale. However, with enforcer being moved to brick we can no longer maintain correct cluster wide size for a directory. Hence removing accounting code from enforcer. Change-Id: I5ea94234da4da85ed5f5ced1354d8de3454b3fcb BUG: 969461 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/6434 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- tests/bugs/bug-1023974.t | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/bugs/bug-1023974.t b/tests/bugs/bug-1023974.t index 56766b979..06d33c12f 100644 --- a/tests/bugs/bug-1023974.t +++ b/tests/bugs/bug-1023974.t @@ -21,6 +21,8 @@ TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0; TEST mkdir -p $M0/1/2; TEST $CLI volume quota $V0 limit-usage /1/2 100MB 70%; +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=1M count=102; -- cgit From f05607fe05f7189dc65a6f328f83db0cbb946426 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 23 Dec 2013 14:54:05 +0530 Subject: mgmt/glusterd: make sure quota enforcer has established connection with quotad before marking quota as enabled. without this patch there is a window of time when quota is marked as enabled in quota-enforcer, but connection to quotad wouldn't have been established. Any checklimit done during this period can result in a failed fop because of unavailability of quotad. Change-Id: I0d509fabc434dd55ce9ec59157123524197fcc80 Signed-off-by: Raghavendra G BUG: 969461 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/6572 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- tests/basic/quota-anon-fd-nfs.t | 84 +++++++++++++++++++++++++++++++++++++++++ tests/basic/quota-nfs-anon.t | 46 ---------------------- tests/bugs/bug-1035576.t | 2 +- tests/bugs/bug-848251.t | 1 - tests/bugs/bug-990028.t | 1 - 5 files changed, 85 insertions(+), 49 deletions(-) create mode 100755 tests/basic/quota-anon-fd-nfs.t delete mode 100644 tests/basic/quota-nfs-anon.t (limited to 'tests') diff --git a/tests/basic/quota-anon-fd-nfs.t b/tests/basic/quota-anon-fd-nfs.t new file mode 100755 index 000000000..be7bc35db --- /dev/null +++ b/tests/basic/quota-anon-fd-nfs.t @@ -0,0 +1,84 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../fileio.rc + +cleanup; + +TESTS_EXPECTED_IN_LOOP=16 +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/brick1; +EXPECT 'Created' volinfo_field $V0 'Status'; + + +# The test makes use of inode-lru-limit to hit a scenario, where we +# find an inode whose ancestry is not there. Following is the +# hypothesis (which is confirmed by seeing logs indicating that +# codepath has been executed, but not through a good understanding of +# NFS internals). + +# At the end of an fop, the reference count of an inode would be +# zero. The inode (and its ancestry) persists in memory only +# because of non-zero lookup count. These looked up inodes are put +# in an lru queue of size 1 (here). So, there can be at most one +# such inode in memory. + +# NFS Server makes use of anonymous fds. So, if it cannot find +# valid fd, it does a nameless lookup. This gives us an inode +# whose ancestry is NULL. When a write happens on this inode, +# quota-enforcer/marker finds a NULL ancestry and asks +# storage/posix to build it. + +TEST $CLI volume set $V0 network.inode-lru-limit 1 +TEST $CLI volume set $V0 performance.nfs.write-behind off + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +TEST $CLI volume quota $V0 enable +TEST $CLI volume quota $V0 limit-usage / 1 + +TEST mount -t nfs -o noac,soft,nolock,vers=3 $H0:/$V0 $N0 +deep=/0/1/2/3/4/5/6/7/8/9 +TEST mkdir -p $N0/$deep + +TEST touch $N0/$deep/file1 $N0/$deep/file2 $N0/$deep/file3 $N0/$deep/file4 + +TEST fd_open 3 'w' "$N0/$deep/file1" +TEST fd_open 4 'w' "$N0/$deep/file2" +TEST fd_open 5 'w' "$N0/$deep/file3" +TEST fd_open 6 'w' "$N0/$deep/file4" + +# consume all quota +TEST ! dd if=/dev/zero of="$N0/$deep/file" bs=1MB count=1 + +# At the end of each fop in server, reference count of the +# inode associated with each of the file above drops to zero and hence +# put into lru queue. Since lru-limit is set to 1, an fop next file +# will displace the current inode from itable. This will ensure that +# when writes happens on same fd, fd resolution results in +# nameless lookup from server and quota_writev encounters an fd +# associated with an inode whose parent is not present in itable. + +for j in $(seq 1 2); do + for i in $(seq 3 6); do + # failing writes indicate that we are enforcing quota set on / + # even with anonymous fds. + TEST_IN_LOOP ! fd_write $i "content" + TEST_IN_LOOP sync + done +done + +exec 3>&- +exec 4>&- +exec 5>&- +exec 6>&- + +$CLI volume statedump $V0 all + +TEST umount -l $N0 + +cleanup; diff --git a/tests/basic/quota-nfs-anon.t b/tests/basic/quota-nfs-anon.t deleted file mode 100644 index 7b5ea5f28..000000000 --- a/tests/basic/quota-nfs-anon.t +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -. $(dirname $0)/../include.rc -. $(dirname $0)/../volume.rc - -cleanup; - -TEST glusterd -TEST $CLI volume create $V0 $H0:$B0/${V0}{1} - -function volinfo_field() -{ - local vol=$1; - local field=$2; - - $CLI volume info $vol | grep "^$field: " | sed 's/.*: //'; -} - - -## Verify volume is is created -EXPECT "$V0" volinfo_field $V0 'Volume Name'; -EXPECT 'Created' volinfo_field $V0 'Status'; - - -## Start volume and verify -TEST $CLI volume start $V0; -EXPECT 'Started' volinfo_field $V0 'Status'; - -TEST $CLI volume quota $V0 enable; - -## Mount NFS -TEST mount -t nfs -o nolock,soft,intr $H0:/$V0 $N0; -mkdir -p $N0/0/1 -TEST $CLI volume quota $V0 limit-usage /0/1 1GB 75%; - -deep=/0/1/2/3/4/5/6/7/8/9 -mkdir -p $N0/$deep -dd if=/dev/zero of=$N0/$deep/file bs=1M count=502 & - -kill_brick $V0 $H0 $B0/${V0}{1} -kill -TERM $(get_nfs_pid) - -$CLI volume start $V0 force; - - -cleanup; diff --git a/tests/bugs/bug-1035576.t b/tests/bugs/bug-1035576.t index 08c8a5ea2..52d93dd87 100644 --- a/tests/bugs/bug-1035576.t +++ b/tests/bugs/bug-1035576.t @@ -21,7 +21,7 @@ TEST $CLI volume set $V0 performance.read-ahead off TEST $CLI volume set $V0 background-self-heal-count 0 TEST $CLI volume set $V0 self-heal-daemon off TEST $CLI volume quota $V0 enable -sleep 5 # wait for brick to connect to quotad + TEST kill_brick $V0 $H0 $B0/${V0}0 TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 cd $M0 diff --git a/tests/bugs/bug-848251.t b/tests/bugs/bug-848251.t index 844162283..a5c80b1b4 100644 --- a/tests/bugs/bug-848251.t +++ b/tests/bugs/bug-848251.t @@ -19,7 +19,6 @@ TEST $CLI volume quota $V0 enable; TEST MOUNTDIR="/tmp/$RANDOM" TEST mkdir $MOUNTDIR TEST glusterfs -s $H0 --volfile-id=$V0 $MOUNTDIR -sleep 10 function set_quota(){ mkdir "$MOUNTDIR/$name" diff --git a/tests/bugs/bug-990028.t b/tests/bugs/bug-990028.t index ece7235cd..fbf4175be 100755 --- a/tests/bugs/bug-990028.t +++ b/tests/bugs/bug-990028.t @@ -22,7 +22,6 @@ function __init() TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 TEST $CLI volume quota $V0 enable - sleep 15 } #CASE-1 -- cgit From add56c1fd5c4ca13ebd6c84c458383d727cb2a3c Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Fri, 27 Dec 2013 17:54:50 +0530 Subject: tests: Add rpc coverage tests. 1. Moves rpc-coverage.sh from extras/ to tests/basic/ 2. Fixes a symlink test Change-Id: I2fb8f8441434acfd7bd7fff72deedfbd2410d08c BUG: 764966 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/6609 Reviewed-by: Niels de Vos Tested-by: Gluster Build System Reviewed-by: Raghavendra Bhat --- tests/basic/rpc-coverage.sh | 483 ++++++++++++++++++++++++++++++++++++++++++++ tests/basic/rpc-coverage.t | 25 +++ 2 files changed, 508 insertions(+) create mode 100755 tests/basic/rpc-coverage.sh create mode 100644 tests/basic/rpc-coverage.t (limited to 'tests') diff --git a/tests/basic/rpc-coverage.sh b/tests/basic/rpc-coverage.sh new file mode 100755 index 000000000..dc66969d0 --- /dev/null +++ b/tests/basic/rpc-coverage.sh @@ -0,0 +1,483 @@ +#!/bin/bash + +# This script can be used to provoke 35 fops (if afr is used), +# 28 fops (if afr is not used) (-fstat,-readdirp, and lk,xattrop calls) +# Pending are 7 procedures. +# getspec, fsyncdir, access, fentrylk, fsetxattr, fgetxattr, rchecksum +# TODO: add commands which can generate fops for missing fops + +## Script tests below File Operations over RPC (when afr is used) + +# CREATE +# ENTRYLK +# FINODELK +# FLUSH +# FSTAT +# FSYNC +# FTRUNCATE +# FXATTROP +# GETXATTR +# INODELK +# LINK +# LK +# LOOKUP +# MKDIR +# MKNOD +# OPEN +# OPENDIR +# READ +# READDIR +# READDIRP +# READLINK +# RELEASE +# RELEASEDIR +# REMOVEXATTR +# RENAME +# RMDIR +# SETATTR +# SETXATTR +# STAT +# STATFS +# SYMLINK +# TRUNCATE +# UNLINK +# WRITE +# XATTROP + +#set -e; +set -o pipefail; + +function fail() { + echo "$*: failed."; + exit 1; +} + +function test_mkdir() +{ + mkdir -p $PFX/dir; + test $(stat -c '%F' $PFX/dir) == "directory" || fail "mkdir" +} + + +function test_create() +{ + : > $PFX/dir/file; + + test "$(stat -c '%F' $PFX/dir/file)" == "regular empty file" || fail "create" +} + + +function test_statfs() +{ + local size; + + size=$(stat -f -c '%s' $PFX/dir/file); + test "x$size" != "x0" || fail "statfs" +} + + +function test_open() +{ + exec 4<$PFX/dir/file || fail "open" + exec 4>&- || fail "open" +} + + +function test_write() +{ + dd if=/dev/zero of=$PFX/dir/file bs=65536 count=16 2>/dev/null; + test $(stat -c '%s' $PFX/dir/file) == 1048576 || fail "open" +} + + +function test_read() +{ + local count; + + count=$(dd if=$PFX/dir/file bs=64k count=16 2>/dev/null | wc -c); + test $count == 1048576 || fail "read" +} + + +function test_truncate() +{ + truncate -s 512 $PFX/dir/file; + test $(stat -c '%s' $PFX/dir/file) == 512 || fail "truncate" + + truncate -s 0 $PFX/dir/file; + test $(stat -c '%s' $PFX/dir/file) == 0 || fail "truncate" +} + + +function test_fstat() +{ + local msg; + + export PFX; + msg=$(sh -c 'tail -f $PFX/dir/file --pid=$$ & sleep 1 && echo hooha > $PFX/dir/file && sleep 1'); + test "x$msg" == "xhooha" || fail "fstat" +} + + +function test_mknod() +{ + mknod -m 0666 $PFX/dir/block b 13 42; + test "$(stat -c '%F %a %t %T' $PFX/dir/block)" == "block special file 666 d 2a" \ + || fail "mknod for block device" + + mknod -m 0666 $PFX/dir/char c 13 42; + test "$(stat -c '%F %a %t %T' $PFX/dir/char)" == "character special file 666 d 2a" \ + || fail "mknod for character device" + + mknod -m 0666 $PFX/dir/fifo p; + test "$(stat -c '%F %a' $PFX/dir/fifo)" == "fifo 666" || \ + fail "mknod for fifo" +} + + +function test_symlink() +{ + local msg; + + pushd; + cd $PFX/dir; + ln -s file symlink; + popd; + test "$(stat -c '%F' $PFX/dir/symlink)" == "symbolic link" || fail "Creation of symlink" + + msg=$(cat $PFX/dir/symlink); + test "x$msg" == "xhooha" || fail "Content match for symlink" +} + + +function test_hardlink() +{ + local ino1; + local ino2; + local nlink1; + local nlink2; + local msg; + + ln $PFX/dir/file $PFX/dir/hardlink; + + ino1=$(stat -c '%i' $PFX/dir/file); + nlink1=$(stat -c '%h' $PFX/dir/file); + ino2=$(stat -c '%i' $PFX/dir/hardlink); + nlink2=$(stat -c '%h' $PFX/dir/hardlink); + + test $ino1 == $ino2 || fail "Inode comparison for hardlink" + test $nlink1 == 2 || fail "Link count for hardlink" + test $nlink2 == 2 || fail "Link count for hardlink" + + msg=$(cat $PFX/dir/hardlink); + + test "x$msg" == "xhooha" || fail "Content match for hardlinks" +} + + +function test_rename() +{ + local ino1; + local ino2; + local ino3; + local msg; + + #### file + + ino1=$(stat -c '%i' $PFX/dir/file); + + mv $PFX/dir/file $PFX/dir/file2 || fail "mv" + msg=$(cat $PFX/dir/file2); + test "x$msg" == "xhooha" || fail "File contents comparison after mv" + + ino2=$(stat -c '%i' $PFX/dir/file2); + test $ino1 == $ino2 || fail "Inode comparison after mv" + + mv $PFX/dir/file2 $PFX/dir/file; + msg=$(cat $PFX/dir/file); + test "x$msg" == "xhooha" || fail "File contents comparison after mv" + + ino3=$(stat -c '%i' $PFX/dir/file); + test $ino1 == $ino3 || fail "Inode comparison after mv" + + #### dir + + ino1=$(stat -c '%i' $PFX/dir); + + mv $PFX/dir $PFX/dir2 || fail "Directory mv" + ino2=$(stat -c '%i' $PFX/dir2); + test $ino1 == $ino2 || fail "Inode comparison after directory mv" + + mv $PFX/dir2 $PFX/dir || fail "Directory mv" + ino3=$(stat -c '%i' $PFX/dir); + test $ino1 == $ino3 || fail "Inode comparison after directory mv" +} + + +function test_chmod() +{ + local mode0; + local mode1; + local mode2; + + + #### file + + mode0=$(stat -c '%a' $PFX/dir/file); + chmod 0753 $PFX/dir/file || fail "chmod" + + mode1=$(stat -c '%a' $PFX/dir/file); + test 0$mode1 == 0753 || fail "Mode comparison after chmod" + + chmod 0$mode0 $PFX/dir/file || fail "chmod" + mode2=$(stat -c '%a' $PFX/dir/file); + test 0$mode2 == 0$mode0 || fail "Mode comparison after chmod" + + #### dir + + mode0=$(stat -c '%a' $PFX/dir); + chmod 0753 $PFX/dir || fail "chmod" + + mode1=$(stat -c '%a' $PFX/dir); + test 0$mode1 == 0753 || fail "Mode comparison after chmod" + + chmod 0$mode0 $PFX/dir || fail "chmod" + mode2=$(stat -c '%a' $PFX/dir); + test 0$mode2 == 0$mode0 || fail "Mode comparison after chmod" +} + + +function test_chown() +{ + local user1; + local user2; + local group1; + local group2; + + #### file + + user1=$(stat -c '%u' $PFX/dir/file); + group1=$(stat -c '%g' $PFX/dir/file); + + chown 13:42 $PFX/dir/file || fail "chown" + + user2=$(stat -c '%u' $PFX/dir/file); + group2=$(stat -c '%g' $PFX/dir/file); + + test $user2 == 13 || fail "User comparison after chown" + test $group2 == 42 || fail "Group comparison after chown" + + chown $user1:$group1 $PFX/dir/file || fail "chown" + + user2=$(stat -c '%u' $PFX/dir/file); + group2=$(stat -c '%g' $PFX/dir/file); + + test $user2 == $user1 || fail "User comparison after chown" + test $group2 == $group1 || fail "Group comparison after chown" + + #### dir + + user1=$(stat -c '%u' $PFX/dir); + group1=$(stat -c '%g' $PFX/dir); + + chown 13:42 $PFX/dir || fail "chown" + + user2=$(stat -c '%u' $PFX/dir); + group2=$(stat -c '%g' $PFX/dir); + + test $user2 == 13 || fail "User comparison after chown" + test $group2 == 42 || fail "Group comparison after chown" + + chown $user1:$group1 $PFX/dir || fail "chown" + + user2=$(stat -c '%u' $PFX/dir); + group2=$(stat -c '%g' $PFX/dir); + + test $user2 == $user1 || fail "User comparison after chown" + test $group2 == $group1 || fail "Group comparison after chown" +} + + +function test_utimes() +{ + local acc0; + local acc1; + local acc2; + local mod0; + local mod1; + local mod2; + + #### file + + acc0=$(stat -c '%X' $PFX/dir/file); + mod0=$(stat -c '%Y' $PFX/dir/file); + + sleep 1; + touch -a $PFX/dir/file || fail "atime change on file" + + acc1=$(stat -c '%X' $PFX/dir/file); + mod1=$(stat -c '%Y' $PFX/dir/file); + + sleep 1; + touch -m $PFX/dir/file || fail "mtime change on file" + + acc2=$(stat -c '%X' $PFX/dir/file); + mod2=$(stat -c '%Y' $PFX/dir/file); + + test $acc0 != $acc1 || fail "atime mismatch comparison on file" + test $acc1 == $acc2 || fail "atime match comparison on file" + test $mod0 == $mod1 || fail "mtime match comparison on file" + test $mod1 != $mod2 || fail "mtime mismatch comparison on file" + + #### dir + + acc0=$(stat -c '%X' $PFX/dir); + mod0=$(stat -c '%Y' $PFX/dir); + + sleep 1; + touch -a $PFX/dir || fail "atime change on directory" + + acc1=$(stat -c '%X' $PFX/dir); + mod1=$(stat -c '%Y' $PFX/dir); + + sleep 1; + touch -m $PFX/dir || fail "mtime change on directory" + + acc2=$(stat -c '%X' $PFX/dir); + mod2=$(stat -c '%Y' $PFX/dir); + + test $acc0 != $acc1 || fail "atime mismatch comparison on directory" + test $acc1 == $acc2 || fail "atime match comparison on directory" + test $mod0 == $mod1 || fail "mtime match comparison on directory" + test $mod1 != $mod2 || fail "mtime mismatch comparison on directory" +} + + +function test_locks() +{ + exec 200>$PFX/dir/lockfile || fail "exec" + + ## exclusive locks test + flock -e 200 || fail "flock -e" + ! flock -n -e $PFX/dir/lockfile -c true || fail "! flock -n -e" + ! flock -n -s $PFX/dir/lockfile -c true || fail "! flock -n -s" + flock -u 200 || fail "flock -u" + + ## shared locks test + flock -s 200 || fail "flock -s" + ! flock -n -e $PFX/dir/lockfile -c true || fail "! flock -n -e" + flock -n -s $PFX/dir/lockfile -c true || fail "! flock -n -s" + flock -u 200 || fail "flock -u" + + exec 200>&- || fail "exec" + +} + + +function test_readdir() +{ + /bin/ls $PFX/dir >/dev/null || fail "ls" +} + + +function test_setxattr() +{ + setfattr -n trusted.testing -v c00k33 $PFX/dir/file || fail "setfattr" +} + + +function test_listxattr() +{ + getfattr -m trusted $PFX/dir/file 2>/dev/null | grep -q trusted.testing || fail "getfattr" +} + + +function test_getxattr() +{ + getfattr -n trusted.testing $PFX/dir/file 2>/dev/null | grep -q c00k33 || fail "getfattr" +} + + +function test_removexattr() +{ + setfattr -x trusted.testing $PFX/dir/file || fail "setfattr remove" + getfattr -n trusted.testing $PFXf/dir/file 2>&1 | grep -q "No such attribute" +} + + +function test_unlink() +{ + rm $PFX/dir/file || fail "rm" +} + + +function test_rmdir() +{ + rm -rf $PFX || fail "rm -rf" +} + + +function run_tests() +{ + test_mkdir; + test_create; + test_statfs; + test_open; + test_write; + test_read; + test_truncate; + test_fstat; + test_mknod; + test_hardlink; + test_symlink; + test_rename; + test_chmod; + test_chown; + test_utimes; + test_locks; + test_readdir; + test_setxattr; + test_listxattr; + test_getxattr; + test_removexattr; + test_unlink; + test_rmdir; +} + + +function _init() +{ + DIR=$(pwd); +} + + +function parse_cmdline() +{ + if [ "x$1" == "x" ] ; then + echo "Usage: $0 /path/mount" + exit 1 + fi + + DIR=$1; + + if [ ! -d "$DIR" ] ; then + echo "$DIR: not a directory" + exit 1 + fi + + PFX="$DIR/coverage"; + rm -rvf $PFX; +} + + +function main() +{ + parse_cmdline "$@"; + + run_tests; + + exit 0; +} + + +_init && main "$@"; diff --git a/tests/basic/rpc-coverage.t b/tests/basic/rpc-coverage.t new file mode 100644 index 000000000..5dfeaa942 --- /dev/null +++ b/tests/basic/rpc-coverage.t @@ -0,0 +1,25 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '8' brick_count $V0 + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M1; + +TEST $(dirname $0)/rpc-coverage.sh $M1 +cleanup; -- cgit