diff options
Diffstat (limited to 'tests/bugs/readdir-ahead')
| -rw-r--r-- | tests/bugs/readdir-ahead/bug-1390050.c | 72 | ||||
| -rw-r--r-- | tests/bugs/readdir-ahead/bug-1390050.t | 29 | ||||
| -rwxr-xr-x | tests/bugs/readdir-ahead/bug-1436090.t | 44 | ||||
| -rwxr-xr-x | tests/bugs/readdir-ahead/bug-1439640.t | 31 | ||||
| -rwxr-xr-x | tests/bugs/readdir-ahead/bug-1446516.t | 21 | ||||
| -rwxr-xr-x | tests/bugs/readdir-ahead/bug-1512437.t | 23 | ||||
| -rw-r--r-- | tests/bugs/readdir-ahead/bug-1670253-consistent-metadata.t | 23 |
7 files changed, 243 insertions, 0 deletions
diff --git a/tests/bugs/readdir-ahead/bug-1390050.c b/tests/bugs/readdir-ahead/bug-1390050.c new file mode 100644 index 00000000000..9578df2dd90 --- /dev/null +++ b/tests/bugs/readdir-ahead/bug-1390050.c @@ -0,0 +1,72 @@ +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <fcntl.h> +#include <dirent.h> +#include <string.h> +#include <errno.h> + +int +main(int argc, char *argv[]) +{ + const char *glfs_dir = NULL, *filepath = NULL; + DIR *dirfd = NULL; + int filefd = 0, ret = 0; + struct stat stbuf = { + 0, + }; + size_t size_before_write = 0; + + glfs_dir = argv[1]; + filepath = argv[2]; + dirfd = opendir(glfs_dir); + if (dirfd == NULL) { + fprintf(stderr, "opening directory failed (%s)\n", strerror(errno)); + goto err; + } + + filefd = open(filepath, O_RDWR); + if (filefd < 0) { + fprintf(stderr, "open failed on path %s (%s)\n", filepath, + strerror(errno)); + goto err; + } + + ret = stat(filepath, &stbuf); + if (ret < 0) { + fprintf(stderr, "stat failed on path %s (%s)\n", filepath, + strerror(errno)); + goto err; + } + + size_before_write = stbuf.st_size; + + ret = write(filefd, "testdata", strlen("testdata123") + 1); + if (ret <= 0) { + fprintf(stderr, "write failed (%s)\n", strerror(errno)); + goto err; + } + + while (readdir(dirfd)) { + /* do nothing */ + } + + ret = stat(filepath, &stbuf); + if (ret < 0) { + fprintf(stderr, "stat failed on path %s (%s)\n", strerror(errno)); + goto err; + } + + if (stbuf.st_size == size_before_write) { + fprintf(stderr, + "file size (%lu) has not changed even after " + "its written to\n", + stbuf.st_size); + goto err; + } + + return 0; +err: + return -1; +} diff --git a/tests/bugs/readdir-ahead/bug-1390050.t b/tests/bugs/readdir-ahead/bug-1390050.t new file mode 100644 index 00000000000..ab1d7d4ead9 --- /dev/null +++ b/tests/bugs/readdir-ahead/bug-1390050.t @@ -0,0 +1,29 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../fileio.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 $H0:$B{0..1}/$V0 +TEST $CLI volume set $V0 readdir-ahead on + +DIRECTORY="$M0/subdir1/subdir2" + +#Make sure md-cache has large timeout to hold stat from readdirp_cbk in its cache +TEST $CLI volume set $V0 performance.md-cache-timeout 600 +TEST $CLI volume start $V0 +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 +rm -rf $M0/* +TEST mkdir -p $DIRECTORY +rm -rf $DIRECTORY/* +TEST touch $DIRECTORY/file{0..10} +rdd_tester=$(dirname $0)/rdd-tester +TEST build_tester $(dirname $0)/bug-1390050.c -o $rdd_tester +TEST $rdd_tester $DIRECTORY $DIRECTORY/file4 +rm -f $rdd_tester +cleanup; + diff --git a/tests/bugs/readdir-ahead/bug-1436090.t b/tests/bugs/readdir-ahead/bug-1436090.t new file mode 100755 index 00000000000..e0877f15684 --- /dev/null +++ b/tests/bugs/readdir-ahead/bug-1436090.t @@ -0,0 +1,44 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../cluster.rc + +cleanup; + +TEST launch_cluster 2; +TEST $CLI_1 peer probe $H2; +EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count + +$CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 +EXPECT 'Created' cluster_volinfo_field 1 $V0 'Status'; + +$CLI_1 volume start $V0 +EXPECT 'Started' cluster_volinfo_field 1 $V0 'Status'; + +TEST glusterfs -s $H1 --volfile-id $V0 $M0; +TEST mkdir $M0/dir1 + +# Create a large file (4 GB), so that rebalance takes time +# Since we really don't care about the contents of the file, we use fallocate +# to generate the file much faster. We could also use truncate, which is even +# faster, but rebalance could take advantage of an sparse file and migrate it +# in an optimized way, but we don't want a fast migration. +TEST fallocate -l 4G $M0/dir1/foo + +TEST mv $M0/dir1/foo $M0/dir1/bar + +TEST $CLI_1 volume rebalance $V0 start force +TEST ! $CLI_1 volume set $V0 parallel-readdir on +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" cluster_rebalance_status_field 1 $V0 +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" cluster_rebalance_status_field 2 $V0 +TEST $CLI_1 volume set $V0 parallel-readdir on +TEST mv $M0/dir1/bar $M0/dir1/foo + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST glusterfs -s $H1 --volfile-id $V0 $M0; +TEST $CLI_1 volume rebalance $V0 start force +TEST ln $M0/dir1/foo $M0/dir1/bar +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" cluster_rebalance_status_field 1 $V0 +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" cluster_rebalance_status_field 2 $V0 +cleanup; diff --git a/tests/bugs/readdir-ahead/bug-1439640.t b/tests/bugs/readdir-ahead/bug-1439640.t new file mode 100755 index 00000000000..dcd54076444 --- /dev/null +++ b/tests/bugs/readdir-ahead/bug-1439640.t @@ -0,0 +1,31 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 $H0:$B{0..1}/$V0 +TEST $CLI volume set $V0 readdir-ahead on +TEST $CLI volume start $V0 + +TEST ! $CLI volume set $V0 parallel-readdir sdf + +TEST $CLI volume set $V0 parallel-readdir off +TEST $CLI volume set $V0 parallel-readdir on + +TEST ! $CLI volume set $V0 rda-cache-limit 0 +TEST ! $CLI volume set $V0 rda-cache-limit -634 +TEST ! $CLI volume set $V0 rda-cache-limit 87adh +TEST ! $CLI volume set $V0 parallel-readdir sdf + +TEST ! $CLI volume set $V0 rda-request-size 0 +TEST ! $CLI volume set $V0 rda-request-size -634 +TEST ! $CLI volume set $V0 rda-request-size 87adh + +TEST $CLI volume set $V0 rda-cache-limit 10MB +TEST $CLI volume set $V0 rda-request-size 128KB + +cleanup; diff --git a/tests/bugs/readdir-ahead/bug-1446516.t b/tests/bugs/readdir-ahead/bug-1446516.t new file mode 100755 index 00000000000..2bf6520d861 --- /dev/null +++ b/tests/bugs/readdir-ahead/bug-1446516.t @@ -0,0 +1,21 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..4} +TEST $CLI volume start $V0 + +TEST $CLI volume set $V0 parallel-readdir on + +TEST $CLI volume set $V0 rda-cache-limit 4GB + +TEST $CLI volume set $V0 parallel-readdir off + +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 + +cleanup; diff --git a/tests/bugs/readdir-ahead/bug-1512437.t b/tests/bugs/readdir-ahead/bug-1512437.t new file mode 100755 index 00000000000..50eaa7d6696 --- /dev/null +++ b/tests/bugs/readdir-ahead/bug-1512437.t @@ -0,0 +1,23 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 + +TEST $CLI volume set $V0 parallel-readdir on +TEST $CLI volume set $V0 readdir-optimize on + +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 +TEST mkdir -p $M0/subdir1/subdir2; +umount $M0 +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 +count=`ls -1 $M0/subdir1 | wc -l` +TEST [ $count -eq 1 ] + +cleanup; diff --git a/tests/bugs/readdir-ahead/bug-1670253-consistent-metadata.t b/tests/bugs/readdir-ahead/bug-1670253-consistent-metadata.t new file mode 100644 index 00000000000..6adfc17c92c --- /dev/null +++ b/tests/bugs/readdir-ahead/bug-1670253-consistent-metadata.t @@ -0,0 +1,23 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2} +TEST $CLI volume set $V0 readdir-ahead on #on by default as of writing this .t. +TEST $CLI volume set $V0 consistent-metadata on +TEST $CLI volume start $V0 +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 +TEST touch $M0/FILE +echo "abc" >> $M0/FILE +EXPECT "^0$" echo $? +EXPECT "abc" cat $M0/FILE +echo "truncate" >$M0/FILE +EXPECT "^0$" echo $? +EXPECT "truncate" cat $M0/FILE +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +cleanup; |
