diff options
Diffstat (limited to 'tests/bugs/posix')
| -rwxr-xr-x | tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t | 14 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-1175711.c | 40 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-1619720.t | 58 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-1651445.t | 54 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-990028.t | 8 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-gfid-path.t | 70 | ||||
| -rw-r--r-- | tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c | 160 |
7 files changed, 296 insertions, 108 deletions
diff --git a/tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t b/tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t index e67616db618..3839c6e3380 100755 --- a/tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t +++ b/tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t @@ -11,17 +11,21 @@ function get_gid() { stat -c '%g' $1; } +function check_stat() { + stat $1 + echo $? +} cleanup; TEST glusterd TEST pidof glusterd -TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{1,2,3,4,5,6}; EXPECT "$V0" volinfo_field $V0 'Volume Name'; EXPECT 'Created' volinfo_field $V0 'Status'; -EXPECT '8' brick_count $V0 +EXPECT '6' brick_count $V0 TEST $CLI volume start $V0; EXPECT 'Started' volinfo_field $V0 'Status'; @@ -37,7 +41,10 @@ EXPECT 100 get_uid $M0; EXPECT 101 get_gid $M0; TEST $CLI volume stop $V0; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" online_brick_count + TEST $CLI volume start $V0; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "6" online_brick_count EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 @@ -45,9 +52,8 @@ EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 2 EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 3 EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 4 EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 5 -EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 6 -EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 7 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" check_stat $M0 EXPECT 100 get_uid $M0; EXPECT 101 get_gid $M0; diff --git a/tests/bugs/posix/bug-1175711.c b/tests/bugs/posix/bug-1175711.c index fbbea3f636b..8ab193c4014 100644 --- a/tests/bugs/posix/bug-1175711.c +++ b/tests/bugs/posix/bug-1175711.c @@ -6,32 +6,32 @@ int main(int argc, char **argv) { - DIR *dir = NULL; - struct dirent *entry = NULL; - int ret = 0; - char *path = NULL; + DIR *dir = NULL; + struct dirent *entry = NULL; + int ret = 0; + char *path = NULL; - assert (argc == 2); - path = argv[1]; + assert(argc == 2); + path = argv[1]; - dir = opendir(path); - if (!dir) { - printf("opendir(%s) failed.\n", path); - return -1; - } + dir = opendir(path); + if (!dir) { + printf("opendir(%s) failed.\n", path); + return -1; + } #ifdef _DIRENT_HAVE_D_TYPE - while ((entry = readdir(dir)) != NULL) { - if (entry->d_type == DT_UNKNOWN) { - printf("d_type found to be DT_UNKNOWN\n"); - ret = -1; - break; - } + while ((entry = readdir(dir)) != NULL) { + if (entry->d_type == DT_UNKNOWN) { + printf("d_type found to be DT_UNKNOWN\n"); + ret = -1; + break; } + } #endif - if (dir) - closedir(dir); + if (dir) + closedir(dir); - return ret; + return ret; } diff --git a/tests/bugs/posix/bug-1619720.t b/tests/bugs/posix/bug-1619720.t new file mode 100755 index 00000000000..bfd304dc809 --- /dev/null +++ b/tests/bugs/posix/bug-1619720.t @@ -0,0 +1,58 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../dht.rc + +cleanup; + + +# Test steps: +# The test checks to make sure that the trusted.pgfid.xx xattr is set on +# both the linkto and data files post the final rename. +# The test creates files file-1 and file-3 so that src_hashed = dst_hashed, +# src_cached = dst_cached and xxx_hashed != xxx_cached. +# It then renames file-1 to file-3 which triggers the posix_mknod call +# which updates the trusted.pgfid.xx xattr. + + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 +TEST $CLI volume set $V0 storage.build-pgfid on + +## Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/tmp + + + +# Not the best way to do this but I need files which hash to the same subvol and +# whose cached subvols are the same. +# In a 2 subvol distributed volume, file-{1,3} hash to the same subvol. +# file-2 will hash to the other subvol + +TEST touch $M0/tmp/file-2 +pgfid_xattr_name=$(getfattr -m "trusted.pgfid.*" $B0/${V0}1/tmp/file-2 | grep "trusted.pgfid") +echo $pgfid_xattr_name + + +TEST mv $M0/tmp/file-2 $M0/tmp/file-1 +TEST touch $M0/tmp/file-2 +TEST mv $M0/tmp/file-2 $M0/tmp/file-3 + +# At this point, both the file-1 and file-3 data files exist on one subvol +# and both linkto files on the other + +TEST mv -f $M0/tmp/file-1 $M0/tmp/file-3 + + +TEST getfattr -n $pgfid_xattr_name $B0/${V0}0/tmp/file-3 +TEST getfattr -n $pgfid_xattr_name $B0/${V0}1/tmp/file-3 + +# Not required for the test but an extra check if required. +# The linkto file was not renamed Without the fix. +#TEST mv $M0/tmp/file-3 $M0/tmp/file-6 +cleanup; diff --git a/tests/bugs/posix/bug-1651445.t b/tests/bugs/posix/bug-1651445.t new file mode 100644 index 00000000000..4d08b69b9b0 --- /dev/null +++ b/tests/bugs/posix/bug-1651445.t @@ -0,0 +1,54 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../snapshot.rc + +cleanup + +TEST verify_lvm_version +TEST glusterd +TEST pidof glusterd +TEST init_n_bricks 3 +TEST setup_lvm 3 + +TEST $CLI volume create $V0 replica 3 $H0:$L{1,2,3} +TEST $CLI volume start $V0 + +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 + +#Setting the size in bytes +TEST $CLI volume set $V0 storage.reserve 40MB + +#wait 5s to reset disk_space_full flag +sleep 5 + +TEST dd if=/dev/zero of=$M0/a bs=100M count=1 +TEST dd if=/dev/zero of=$M0/b bs=10M count=1 + +# Wait 5s to update disk_space_full flag because thread check disk space +# after every 5s + +sleep 5 +# setup_lvm create lvm partition of 150M and 40M are reserve so after +# consuming more than 110M next dd should fail +TEST ! dd if=/dev/zero of=$M0/c bs=5M count=1 +TEST dd if=/dev/urandom of=$M0/a bs=1022 count=1 oflag=seek_bytes,sync seek=102 conv=notrunc + +rm -rf $M0/* + +#Setting the size in percent and repeating the above steps +TEST $CLI volume set $V0 storage.reserve 40 + +sleep 5 + +TEST dd if=/dev/zero of=$M0/a bs=80M count=1 +TEST dd if=/dev/zero of=$M0/b bs=10M count=1 + +sleep 5 +TEST ! dd if=/dev/zero of=$M0/c bs=5M count=1 + +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup diff --git a/tests/bugs/posix/bug-990028.t b/tests/bugs/posix/bug-990028.t index 5006a611630..bef36a8897d 100755 --- a/tests/bugs/posix/bug-990028.t +++ b/tests/bugs/posix/bug-990028.t @@ -78,7 +78,7 @@ function links_across_directories() TEST [ $LINES = 2 ] for i in $(seq 1 2); do - HL=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/dir$i/file$i 2>&1 | grep "trusted.pgfid" | cut -d$'\n' -f$i | cut -d'=' -f2` + HL=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/dir$i/file$i 2>&1 | grep "trusted.pgfid" | awk -v n=$i 'NR==n' | cut -d'=' -f2` TEST_IN_LOOP [ $HL = "0x00000001" ] done @@ -155,9 +155,3 @@ links_across_directories; TEST $CLI volume stop $V0 cleanup - -# Mainly marking it as known-issue as it is consistently failing. -# Revert back once fixing this. - -#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=1517961 -#G_TESTDEF_TEST_STATUS_CENTOS6=KNOWN_ISSUE,BUG=1517961 diff --git a/tests/bugs/posix/bug-gfid-path.t b/tests/bugs/posix/bug-gfid-path.t new file mode 100644 index 00000000000..1bbbe9f0670 --- /dev/null +++ b/tests/bugs/posix/bug-gfid-path.t @@ -0,0 +1,70 @@ +#!/bin/bash + +# This test case is for the bug where, even though a file is +# created when gfid2path option is turned off (default is ON), +# getfattr of "glusterfs.gfidtopath" was succeeding for that +# file. Ideally the getfattr should fail, as the file does not +# have its path(s) stored as a extended attribute (because it +# was created when gfid2path option was off) + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2,3,4}; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '4' brick_count $V0 + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/dir +TEST mkdir $M0/new +TEST mkdir $M0/3 + +TEST touch $M0/dir/file + +# except success as by default gfid2path is enabled +# and the glusterfs.gfidtopath xattr should give the +# path of the object as the value + +TEST getfattr -n glusterfs.gfidtopath $M0/dir/file + +# turn off gfid2path feature +TEST $CLI volume set $V0 storage.gfid2path off + +TEST touch $M0/new/foo + +# again enable gfid2path. This has to be enabled before +# trying the getfattr. Because, glusterfs.gfidtopath xattr +# request is handled only if gfid2path is enabled. If not, +# then getxattr on glusterfs.gfid2path fails anyways. In this +# context we want getfattr to fail, because the file was created +# when gfid2path feature was disabled and not because gfid2path +# feature itself is disabled. +TEST $CLI volume set $V0 storage.gfid2path on + +# getfattr should fail as it is attempted on a file +# which does not have its path stored as a xattr +# (because file got created after disabling gfid2path) +TEST ! getfattr -n glusterfs.gfidtopath $M0/new/foo; + + + +TEST touch $M0/3/new + +# should be successful +TEST getfattr -n glusterfs.gfidtopath $M0/3/new + +TEST rm -rf $M0/* + +cleanup; diff --git a/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c b/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c index 325edbbed97..4ed3181d48f 100644 --- a/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c +++ b/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c @@ -5,94 +5,100 @@ #include <string.h> int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { - glfs_t *fs = NULL; - int ret = 0; - int i = 0; - glfs_fd_t *fd = NULL; - char *logfile = NULL; - char *hostname = NULL; + glfs_t *fs = NULL; + int ret = 0; + int i = 0; + glfs_fd_t *fd = NULL; + char *logfile = NULL; + char *hostname = NULL; - if (argc != 4) { - fprintf (stderr, - "Expect following args %s <hostname> <Vol> <log file>\n" - , argv[0]); - return -1; - } + if (argc != 4) { + fprintf(stderr, + "Expect following args %s <hostname> <Vol> <log file>\n", + argv[0]); + return -1; + } - hostname = argv[1]; - logfile = argv[3]; + hostname = argv[1]; + logfile = argv[3]; - fs = glfs_new (argv[2]); - if (!fs) { - fprintf (stderr, "glfs_new: returned NULL (%s)\n", - strerror (errno)); - return -1; - } + fs = glfs_new(argv[2]); + if (!fs) { + fprintf(stderr, "glfs_new: returned NULL (%s)\n", strerror(errno)); + return -1; + } - ret = glfs_set_volfile_server (fs, "tcp", hostname, 24007); - if (ret < 0) { - fprintf (stderr, "glfs_set_volfile_server failed ret:%d (%s)\n", - ret, strerror (errno)); - return -1; - } + ret = glfs_set_volfile_server(fs, "tcp", hostname, 24007); + if (ret < 0) { + fprintf(stderr, "glfs_set_volfile_server failed ret:%d (%s)\n", ret, + strerror(errno)); + return -1; + } - ret = glfs_set_logging (fs, logfile, 7); - if (ret < 0) { - fprintf (stderr, "glfs_set_logging failed with ret: %d (%s)\n", - ret, strerror (errno)); - return -1; - } + ret = glfs_set_logging(fs, logfile, 7); + if (ret < 0) { + fprintf(stderr, "glfs_set_logging failed with ret: %d (%s)\n", ret, + strerror(errno)); + return -1; + } - ret = glfs_init (fs); - if (ret < 0) { - fprintf (stderr, "glfs_init failed with ret: %d (%s)\n", - ret, strerror (errno)); - return -1; - } + ret = glfs_init(fs); + if (ret < 0) { + fprintf(stderr, "glfs_init failed with ret: %d (%s)\n", ret, + strerror(errno)); + return -1; + } - fd = glfs_opendir (fs, "/"); - if (!fd) { - fprintf (stderr, "glfs_opendir failed with (%s)\n", - strerror (errno)); - return -1; - } + fd = glfs_opendir(fs, "/"); + if (!fd) { + fprintf(stderr, "glfs_opendir failed with (%s)\n", strerror(errno)); + return -1; + } - ret = glfs_fremovexattr (fd, "trusted.gfid"); - if (ret == 0 || errno != EPERM) { - fprintf (stderr, "glfs_fremovexattr gfid exited with ret: " - "%d (%s)\n", ret, strerror (errno)); - return -1; - } + ret = glfs_fremovexattr(fd, "trusted.gfid"); + if (ret == 0 || errno != EPERM) { + fprintf(stderr, + "glfs_fremovexattr gfid exited with ret: " + "%d (%s)\n", + ret, strerror(errno)); + return -1; + } - ret = glfs_fremovexattr (fd, "trusted.glusterfs.volume-id"); - if (ret == 0 || errno != EPERM) { - fprintf (stderr, "glfs_fremovexattr volume-id exited with ret: " - "%d (%s)\n", ret, strerror (errno)); - return -1; - } + ret = glfs_fremovexattr(fd, "trusted.glusterfs.volume-id"); + if (ret == 0 || errno != EPERM) { + fprintf(stderr, + "glfs_fremovexattr volume-id exited with ret: " + "%d (%s)\n", + ret, strerror(errno)); + return -1; + } - ret = glfs_fsetxattr (fd, "trusted.abc", "abc", 3, 0); - if (ret < 0) { - fprintf (stderr, "glfs_fsetxattr trusted.abc exited with ret: " - "%d (%s)\n", ret, strerror (errno)); - return -1; - } + ret = glfs_fsetxattr(fd, "trusted.abc", "abc", 3, 0); + if (ret < 0) { + fprintf(stderr, + "glfs_fsetxattr trusted.abc exited with ret: " + "%d (%s)\n", + ret, strerror(errno)); + return -1; + } - ret = glfs_fremovexattr (fd, "trusted.abc"); - if (ret < 0) { - fprintf (stderr, "glfs_fremovexattr trusted.abc exited with " - "ret: %d (%s)\n", ret, strerror (errno)); - return -1; - } + ret = glfs_fremovexattr(fd, "trusted.abc"); + if (ret < 0) { + fprintf(stderr, + "glfs_fremovexattr trusted.abc exited with " + "ret: %d (%s)\n", + ret, strerror(errno)); + return -1; + } - (void) glfs_closedir(fd); - ret = glfs_fini (fs); - if (ret < 0) { - fprintf (stderr, "glfs_fini failed with ret: %d (%s)\n", - ret, strerror (errno)); - return -1; - } - return 0; + (void)glfs_closedir(fd); + ret = glfs_fini(fs); + if (ret < 0) { + fprintf(stderr, "glfs_fini failed with ret: %d (%s)\n", ret, + strerror(errno)); + return -1; + } + return 0; } |
