summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/shard/bug-1260637.t3
-rw-r--r--tests/bugs/shard/bug-shard-discard.c66
-rw-r--r--tests/bugs/shard/bug-shard-discard.t61
-rw-r--r--tests/bugs/shard/bug-shard-zerofill.c6
-rw-r--r--tests/bugs/shard/bug-shard-zerofill.t8
-rw-r--r--tests/bugs/shard/shard-fallocate.c10
-rw-r--r--tests/bugs/shard/zero-flag.t12
7 files changed, 141 insertions, 25 deletions
diff --git a/tests/bugs/shard/bug-1260637.t b/tests/bugs/shard/bug-1260637.t
index f5bf083b5dc..21008ee19dd 100644
--- a/tests/bugs/shard/bug-1260637.t
+++ b/tests/bugs/shard/bug-1260637.t
@@ -1,6 +1,7 @@
#!/bin/bash
. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
cleanup
@@ -34,7 +35,7 @@ TEST ! setfattr -x trusted.glusterfs.shard.file-size $M0/foo
# Verify that shard xattrs are not listed when listxattr is triggered.
TEST ! "getfattr -d -m . $M0/foo | grep shard"
-TEST umount $M0
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
TEST $CLI volume stop $V0
TEST $CLI volume delete $V0
diff --git a/tests/bugs/shard/bug-shard-discard.c b/tests/bugs/shard/bug-shard-discard.c
new file mode 100644
index 00000000000..d51b07f9314
--- /dev/null
+++ b/tests/bugs/shard/bug-shard-discard.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "glfs.h"
+#include "glfs-handles.h"
+
+int
+main (int argc, char *argv[])
+{
+ int ret = 0;
+ off_t off = 0;
+ size_t len = 0;
+ glfs_t *fs = NULL;
+ glfs_fd_t *fd = NULL;
+
+ if (argc != 7) {
+ fprintf (stderr, "Syntax: %s <host> <volname> <file-path> <off> <len> <log-file>\n", argv[0]);
+ return 1;
+ }
+
+ fs = glfs_new (argv[2]);
+ if (!fs) {
+ fprintf (stderr, "glfs_new: returned NULL\n");
+ return 1;
+ }
+
+ ret = glfs_set_volfile_server (fs, "tcp", argv[1], 24007);
+ if (ret != 0) {
+ fprintf (stderr, "glfs_set_volfile_server: retuned %d\n", ret);
+ goto out;
+ }
+
+ ret = glfs_set_logging (fs, argv[6], 7);
+ if (ret != 0) {
+ fprintf (stderr, "glfs_set_logging: returned %d\n", ret);
+ goto out;
+ }
+
+ ret = glfs_init (fs);
+ if (ret != 0) {
+ fprintf (stderr, "glfs_init: returned %d\n", ret);
+ goto out;
+ }
+
+ fd = glfs_open (fs, argv[3], O_RDWR);
+ if (fd == NULL) {
+ fprintf (stderr, "glfs_open: returned NULL\n");
+ goto out;
+ }
+
+ off = atoi (argv[4]);
+ len = atoi (argv[5]);
+
+ ret = glfs_discard (fd, off, len);
+ if (ret <= 0) {
+ fprintf (stderr, "glfs_discard: returned %d\n", ret);
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ if (fd)
+ glfs_close (fd);
+ glfs_fini (fs);
+ return ret;
+}
diff --git a/tests/bugs/shard/bug-shard-discard.t b/tests/bugs/shard/bug-shard-discard.t
new file mode 100644
index 00000000000..4c4e9417b5b
--- /dev/null
+++ b/tests/bugs/shard/bug-shard-discard.t
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+cleanup
+
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..3}
+TEST $CLI volume set $V0 features.shard on
+TEST $CLI volume start $V0
+
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0
+
+# Create a file.
+TEST touch $M0/foo
+TEST dd if=/dev/urandom of=$M0/foo bs=1M count=10
+
+# This should ensure /.shard is created on the bricks.
+TEST stat $B0/${V0}0/.shard
+TEST stat $B0/${V0}1/.shard
+TEST stat $B0/${V0}2/.shard
+TEST stat $B0/${V0}3/.shard
+
+#Note the size of the file, it should be 10M
+EXPECT '10485760' stat -c %s $M0/foo
+
+gfid_foo=$(get_gfid_string $M0/foo)
+
+TEST gcc -Wall -O2 -I api/src -o $(dirname $0)/bug-shard-discard $(dirname $0)/bug-shard-discard.c -lgfapi
+#Call discard on the file at off=7M and len=3M
+TEST $(dirname $0)/bug-shard-discard $H0 $V0 /foo 7340032 3145728 `gluster --print-logdir`/glfs-$V0.log
+
+#Ensure that discard doesn't change the original size of the file.
+EXPECT '10485760' stat -c %s $M0/foo
+
+# Ensure that the last shard is all zero'd out
+EXPECT "1" file_all_zeroes `find $B0 -name $gfid_foo.2`
+EXPECT_NOT "1" file_all_zeroes `find $B0 -name $gfid_foo.1`
+
+# Now unlink the file. And ensure that all shards associated with the file are cleaned up
+TEST unlink $M0/foo
+TEST ! stat $B0/${V0}0/.shard/$gfid_foo.1
+TEST ! stat $B0/${V0}1/.shard/$gfid_foo.1
+TEST ! stat $B0/${V0}2/.shard/$gfid_foo.1
+TEST ! stat $B0/${V0}3/.shard/$gfid_foo.1
+TEST ! stat $B0/${V0}0/.shard/$gfid_foo.2
+TEST ! stat $B0/${V0}1/.shard/$gfid_foo.2
+TEST ! stat $B0/${V0}2/.shard/$gfid_foo.2
+TEST ! stat $B0/${V0}3/.shard/$gfid_foo.2
+TEST ! stat $M0/foo
+
+#clean up everything
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
+TEST $CLI volume stop $V0
+TEST $CLI volume delete $V0
+
+TEST rm -f $(dirname $0)/bug-shard-discard
+
+cleanup
diff --git a/tests/bugs/shard/bug-shard-zerofill.c b/tests/bugs/shard/bug-shard-zerofill.c
index 728e492c7ed..f88c2e2fd02 100644
--- a/tests/bugs/shard/bug-shard-zerofill.c
+++ b/tests/bugs/shard/bug-shard-zerofill.c
@@ -9,8 +9,8 @@ main (int argc, char *argv[])
glfs_fd_t *fd = NULL;
int ret = 1;
- if (argc != 4) {
- fprintf (stderr, "Syntax: %s <host> <volname> <file-path> \n", argv[0]);
+ if (argc != 5) {
+ fprintf (stderr, "Syntax: %s <host> <volname> <file-path> <log-file>\n", argv[0]);
return 1;
}
@@ -25,7 +25,7 @@ main (int argc, char *argv[])
fprintf (stderr, "glfs_set_volfile_server: retuned %d\n", ret);
goto out;
}
- ret = glfs_set_logging (fs, "/var/log/glusterfs/glfs-dis.log", 7);
+ ret = glfs_set_logging (fs, argv[4], 7);
if (ret != 0) {
fprintf (stderr, "glfs_set_logging: returned %d\n", ret);
goto out;
diff --git a/tests/bugs/shard/bug-shard-zerofill.t b/tests/bugs/shard/bug-shard-zerofill.t
index c3211493fe1..ad508c83236 100644
--- a/tests/bugs/shard/bug-shard-zerofill.t
+++ b/tests/bugs/shard/bug-shard-zerofill.t
@@ -3,10 +3,6 @@
. $(dirname $0)/../../include.rc
. $(dirname $0)/../../volume.rc
-function file_all_zeroes {
- < $1 tr -d '\0' | read -n 1 || echo 1
-}
-
cleanup
TEST glusterd
@@ -23,7 +19,7 @@ TEST touch $M0/foo
gfid_foo=$(get_gfid_string $M0/foo)
TEST gcc -Wall -O2 -I api/src -o $(dirname $0)/bug-shard-zerofill $(dirname $0)/bug-shard-zerofill.c -lgfapi
-TEST $(dirname $0)/bug-shard-zerofill $H0 $V0 /foo
+TEST $(dirname $0)/bug-shard-zerofill $H0 $V0 /foo `gluster --print-logdir`/glfs-$V0.log
# This should ensure /.shard is created on the bricks.
TEST stat $B0/${V0}0/.shard
@@ -40,7 +36,7 @@ TEST `echo "abc" >> $M0/foo`
EXPECT_NOT "1" file_all_zeroes $M0/foo
-TEST umount $M0
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
TEST $CLI volume stop $V0
TEST $CLI volume delete $V0
diff --git a/tests/bugs/shard/shard-fallocate.c b/tests/bugs/shard/shard-fallocate.c
index fded6236552..5365c74ef86 100644
--- a/tests/bugs/shard/shard-fallocate.c
+++ b/tests/bugs/shard/shard-fallocate.c
@@ -45,12 +45,11 @@ main (int argc, char *argv[])
int opcode = -1;
off_t offset = 0;
size_t len = 0;
- char logpath[PATH_MAX] = {0,};
glfs_t *fs = NULL;
glfs_fd_t *fd = NULL;
- if (argc != 7) {
- fprintf (stderr, "Syntax: %s <host> <volname> <opcode> <offset> <len> <file-path>\n", argv[0]);
+ if (argc != 8) {
+ fprintf (stderr, "Syntax: %s <host> <volname> <opcode> <offset> <len> <file-path> <log-file>\n", argv[0]);
return 1;
}
@@ -60,16 +59,13 @@ main (int argc, char *argv[])
return 1;
}
- snprintf (logpath, sizeof (logpath), "/var/log/glusterfs/glfs-%s.log",
- argv[2]);
-
ret = glfs_set_volfile_server (fs, "tcp", argv[1], 24007);
if (ret != 0) {
fprintf (stderr, "glfs_set_volfile_server: retuned %d\n", ret);
goto out;
}
- ret = glfs_set_logging (fs, logpath, 7);
+ ret = glfs_set_logging (fs, argv[7], 7);
if (ret != 0) {
fprintf (stderr, "glfs_set_logging: returned %d\n", ret);
goto out;
diff --git a/tests/bugs/shard/zero-flag.t b/tests/bugs/shard/zero-flag.t
index dc88ae1c1ca..fabf83040f0 100644
--- a/tests/bugs/shard/zero-flag.t
+++ b/tests/bugs/shard/zero-flag.t
@@ -4,10 +4,6 @@
. $(dirname $0)/../../volume.rc
. $(dirname $0)/../../fallocate.rc
-function file_all_zeroes {
- < $1 tr -d '\0' | read -n 1 || echo 1
-}
-
cleanup
require_fallocate -l 1m $M0/file
@@ -31,7 +27,7 @@ TEST touch $M0/file1
gfid_file1=$(get_gfid_string $M0/file1)
-TEST $(dirname $0)/zero-flag $H0 $V0 "0" "0" "6291456" /file1
+TEST $(dirname $0)/zero-flag $H0 $V0 "0" "0" "6291456" /file1 `gluster --print-logdir`/glfs-$V0.log
EXPECT '6291456' stat -c %s $M0/file1
@@ -51,7 +47,7 @@ TEST truncate -s 6M $M0/file2
TEST dd if=$M0/tmp of=$M0/file2 bs=1 seek=3145728 count=26 conv=notrunc
md5sum_file2=$(md5sum $M0/file2 | awk '{print $1}')
-TEST $(dirname $0)/zero-flag $H0 $V0 "0" "3145728" "26" /file2
+TEST $(dirname $0)/zero-flag $H0 $V0 "0" "3145728" "26" /file2 `gluster --print-logdir`/glfs-$V0.log
EXPECT '6291456' stat -c %s $M0/file2
EXPECT "$md5sum_file2" echo `md5sum $M0/file2 | awk '{print $1}'`
@@ -69,10 +65,10 @@ TEST stat $B0/$V0*/.shard/$gfid_file3.2
md5sum_file3=$(md5sum $M0/file3 | awk '{print $1}')
EXPECT "1048602" echo `find $B0 -name $gfid_file3.2 | xargs stat -c %s`
-TEST $(dirname $0)/zero-flag $H0 $V0 "0" "5242880" "1048576" /file3
+TEST $(dirname $0)/zero-flag $H0 $V0 "0" "5242880" "1048576" /file3 `gluster --print-logdir`/glfs-$V0.log
EXPECT "$md5sum_file3" echo `md5sum $M0/file3 | awk '{print $1}'`
-TEST umount $M0
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
TEST $CLI volume stop $V0
TEST $CLI volume delete $V0
rm -f $(dirname $0)/zero-flag