diff options
Diffstat (limited to 'tests/basic/fuse')
| -rw-r--r-- | tests/basic/fuse/active-io-graph-switch.t | 65 | ||||
| -rw-r--r-- | tests/basic/fuse/seek.c | 102 |
2 files changed, 117 insertions, 50 deletions
diff --git a/tests/basic/fuse/active-io-graph-switch.t b/tests/basic/fuse/active-io-graph-switch.t new file mode 100644 index 00000000000..6ec3e1fcbfa --- /dev/null +++ b/tests/basic/fuse/active-io-graph-switch.t @@ -0,0 +1,65 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +TESTS_EXPECTED_IN_LOOP=12 + +function perform_io_on_mount { + local m="$1" + local f="$2" + local lockfile="$3" + while [ -f "$m/$lockfile" ]; + do + dd if=/dev/zero of=$m/$f bs=1M count=1 + done +} + +function perform_graph_switch { + for i in {1..3} + do + TEST_IN_LOOP $CLI volume set $V0 performance.stat-prefetch off + sleep 3 + TEST_IN_LOOP $CLI volume set $V0 performance.stat-prefetch on + sleep 3 + done +} + +function count_files { + ls $M0 | wc -l +} + +cleanup; +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2} +TEST $CLI volume set $V0 flush-behind off +TEST $CLI volume start $V0 +TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 +TEST touch $M0/lock +for i in {1..100}; do perform_io_on_mount $M0 $i lock & done +EXPECT_WITHIN 5 "101" count_files + +perform_graph_switch +TEST rm -f $M0/lock +wait +EXPECT "100" count_files +TEST rm -f $M0/{1..100} +EXPECT "0" count_files + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 + +#Repeat the tests with reader-thread-count +TEST $GFS --reader-thread-count=10 --volfile-id=/$V0 --volfile-server=$H0 $M0 +TEST touch $M0/lock +for i in {1..100}; do perform_io_on_mount $M0 $i lock & done +EXPECT_WITHIN 5 "101" count_files + +perform_graph_switch +TEST rm -f $M0/lock +wait +EXPECT "100" count_files +TEST rm -f $M0/{1..100} +EXPECT "0" count_files + +cleanup diff --git a/tests/basic/fuse/seek.c b/tests/basic/fuse/seek.c index e4db41c03d7..30943ad0f33 100644 --- a/tests/basic/fuse/seek.c +++ b/tests/basic/fuse/seek.c @@ -17,64 +17,66 @@ #include <unistd.h> int -main (int argc, char **argv) +main(int argc, char **argv) { - int ret = EXIT_SUCCESS; - int fd = -1; - char *filename = NULL; - struct stat st = { 0, }; - off_t hole_start = 0; - off_t hole_end = 0; + int ret = EXIT_SUCCESS; + int fd = -1; + char *filename = NULL; + struct stat st = { + 0, + }; + off_t hole_start = 0; + off_t hole_end = 0; - if (argc != 2) { - fprintf (stderr, "Invalid argument, use %s <file>\n", argv[0]); - return EXIT_FAILURE; - } - - filename = argv[1]; + if (argc != 2) { + fprintf(stderr, "Invalid argument, use %s <file>\n", argv[0]); + return EXIT_FAILURE; + } - fd = open (filename, O_RDONLY); - if (fd <= 0) { - perror ("open"); - return EXIT_FAILURE; - } + filename = argv[1]; - if (fstat (fd, &st)) { - perror ("fstat"); - return EXIT_FAILURE; - } + fd = open(filename, O_RDONLY); + if (fd <= 0) { + perror("open"); + return EXIT_FAILURE; + } - while (hole_end < st.st_size) { - hole_start = lseek (fd, hole_end, SEEK_HOLE); - if (hole_start == -1 && errno == ENXIO) { - /* no more holes */ - break; - } else if (hole_start == -1 && errno == ENOTSUP) { - /* SEEK_HOLE is not supported */ - perror ("lseek(SEEK_HOLE)"); - ret = EXIT_FAILURE; - break; - } else if (hole_start == -1) { - perror ("no more holes"); - break; - } + if (fstat(fd, &st)) { + perror("fstat"); + return EXIT_FAILURE; + } - hole_end = lseek (fd, hole_start, SEEK_DATA); - if (hole_end == -1 && errno == ENXIO) { - /* no more data */ - break; - } else if (hole_end == -1 && errno == ENOTSUP) { - /* SEEK_DATA is not supported */ - perror ("lseek(SEEK_DATA)"); - ret = EXIT_FAILURE; - break; - } + while (hole_end < st.st_size) { + hole_start = lseek(fd, hole_end, SEEK_HOLE); + if (hole_start == -1 && errno == ENXIO) { + /* no more holes */ + break; + } else if (hole_start == -1 && errno == ENOTSUP) { + /* SEEK_HOLE is not supported */ + perror("lseek(SEEK_HOLE)"); + ret = EXIT_FAILURE; + break; + } else if (hole_start == -1) { + perror("no more holes"); + break; + } - printf ("HOLE found: %ld - %ld%s\n", hole_start, hole_end, - (hole_end == st.st_size) ? " (EOF)" : ""); + hole_end = lseek(fd, hole_start, SEEK_DATA); + if (hole_end == -1 && errno == ENXIO) { + /* no more data */ + break; + } else if (hole_end == -1 && errno == ENOTSUP) { + /* SEEK_DATA is not supported */ + perror("lseek(SEEK_DATA)"); + ret = EXIT_FAILURE; + break; } - close (fd); + printf("HOLE found: %ld - %ld%s\n", hole_start, hole_end, + (hole_end == st.st_size) ? " (EOF)" : ""); + } + + close(fd); - return ret; + return ret; } |
