diff options
Diffstat (limited to 'tests/bitrot')
| -rw-r--r-- | tests/bitrot/br-signer-threads-config-1797869.t | 73 | ||||
| -rw-r--r-- | tests/bitrot/br-state-check.t | 83 | ||||
| -rw-r--r-- | tests/bitrot/br-stub.c | 195 | ||||
| -rw-r--r-- | tests/bitrot/br-stub.t | 66 | ||||
| -rw-r--r-- | tests/bitrot/bug-1207627-bitrot-scrub-status.t | 52 | ||||
| -rw-r--r-- | tests/bitrot/bug-1221914.t | 51 | ||||
| -rw-r--r-- | tests/bitrot/bug-1244613.t | 95 | ||||
| -rw-r--r-- | tests/bitrot/bug-1294786.t | 95 | ||||
| -rw-r--r-- | tests/bitrot/bug-1373520.t | 71 | ||||
| -rw-r--r-- | tests/bitrot/bug-1700078.t | 87 | ||||
| -rw-r--r-- | tests/bitrot/bug-internal-xattrs-check-1243391.t | 42 |
11 files changed, 910 insertions, 0 deletions
diff --git a/tests/bitrot/br-signer-threads-config-1797869.t b/tests/bitrot/br-signer-threads-config-1797869.t new file mode 100644 index 00000000000..657ef3eedaf --- /dev/null +++ b/tests/bitrot/br-signer-threads-config-1797869.t @@ -0,0 +1,73 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../cluster.rc + +function get_bitd_count_1 { + ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H1 | wc -l +} + +function get_bitd_count_2 { + ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H2 | wc -l +} + +function get_bitd_pid_1 { + ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H1 | awk '{print $2}' +} + +function get_bitd_pid_2 { + ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H2 | awk '{print $2}' +} + +function get_signer_th_count_1 { + ps -eL | grep $(get_bitd_pid_1) | grep glfs_brpobj | wc -l +} + +function get_signer_th_count_2 { + ps -eL | grep $(get_bitd_pid_2) | grep glfs_brpobj | wc -l +} + +cleanup; + +TEST launch_cluster 2 + +TEST $CLI_1 peer probe $H2; +EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count; + +TEST $CLI_1 volume create $V0 $H1:$B1 +TEST $CLI_1 volume create $V1 $H2:$B2 +EXPECT 'Created' volinfo_field_1 $V0 'Status'; +EXPECT 'Created' volinfo_field_1 $V1 'Status'; + +TEST $CLI_1 volume start $V0 +TEST $CLI_1 volume start $V1 +EXPECT 'Started' volinfo_field_1 $V0 'Status'; +EXPECT 'Started' volinfo_field_1 $V1 'Status'; + +#Enable bitrot +TEST $CLI_1 volume bitrot $V0 enable +TEST $CLI_1 volume bitrot $V1 enable +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_2 + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "4" get_signer_th_count_1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "4" get_signer_th_count_2 + +old_bitd_pid_1=$(get_bitd_pid_1) +old_bitd_pid_2=$(get_bitd_pid_2) +TEST $CLI_1 volume bitrot $V0 signer-threads 1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_signer_th_count_1 +EXPECT_NOT "$old_bitd_pid_1" get_bitd_pid_1; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "4" get_signer_th_count_2 +EXPECT "$old_bitd_pid_2" get_bitd_pid_2; + +old_bitd_pid_1=$(get_bitd_pid_1) +old_bitd_pid_2=$(get_bitd_pid_2) +TEST $CLI_1 volume bitrot $V1 signer-threads 2 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" get_signer_th_count_2 +EXPECT_NOT "$old_bitd_pid_2" get_bitd_pid_2; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_signer_th_count_1 +EXPECT "$old_bitd_pid_1" get_bitd_pid_1; + +cleanup; diff --git a/tests/bitrot/br-state-check.t b/tests/bitrot/br-state-check.t new file mode 100644 index 00000000000..2142275699e --- /dev/null +++ b/tests/bitrot/br-state-check.t @@ -0,0 +1,83 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc + +cleanup; +SCRIPT_TIMEOUT=350 + +TEST glusterd +TEST pidof glusterd + +## Create a distribute volume +TEST $CLI volume create $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 $H0:$B0/${V0}3; +TEST $CLI volume start $V0; + +## Enable bitrot on volume $V0 +TEST $CLI volume bitrot $V0 enable + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_scrubd_count + +## perform a series of scrub related state change tests. As of now, there' +## no way to check if a given change has been correctly acknowledged by +## the scrub process as there isn't an _interface_ to check scrub internal +## state (yet). What's been verified here is scrub state machine execution +## w.r.t. locking and faults. + +## 0x0: verify scrub rescheduling +TEST $CLI volume bitrot $V0 scrub-frequency monthly +TEST $CLI volume bitrot $V0 scrub-frequency daily +TEST $CLI volume bitrot $V0 scrub-frequency hourly + +## 0x1: test reschedule after pause/resume +TEST $CLI volume bitrot $V0 scrub pause +TEST $CLI volume bitrot $V0 scrub-frequency daily +TEST $CLI volume bitrot $V0 scrub resume + +## 0x2: test reschedule w/ an offline brick +TEST kill_brick $V0 $H0 $B0/${V0}1 + +TEST $CLI volume bitrot $V0 scrub-frequency hourly +TEST $CLI volume bitrot $V0 scrub-throttle aggressive + +## 0x3: test pause/resume w/ an offline brick +TEST $CLI volume bitrot $V0 scrub pause +TEST $CLI volume bitrot $V0 scrub-frequency monthly +TEST $CLI volume bitrot $V0 scrub resume + +## 0x4: test "start" from a paused scrub state + +TEST $CLI volume bitrot $V0 scrub pause +TEST $CLI volume start $V0 force + +## 0x4a: try pausing an already paused scrub +TEST ! $CLI volume bitrot $V0 scrub pause + +## 0x4b: perform configuration changes +TEST $CLI volume bitrot $V0 scrub-frequency hourly +TEST $CLI volume bitrot $V0 scrub-throttle lazy +TEST $CLI volume bitrot $V0 scrub resume + +## 0x5: test cleanup upon brick going offline +TEST kill_brick $V0 $H0 $B0/${V0}1 +TEST kill_brick $V0 $H0 $B0/${V0}2 +TEST kill_brick $V0 $H0 $B0/${V0}3 + +## 0x6: test cleanup upon brick going offline when srubber is paused +## (initially paused and otherwise) + +## 0x6a: initially paused case +TEST $CLI volume bitrot $V0 scrub pause +TEST $CLI volume start $V0 force +TEST kill_brick $V0 $H0 $B0/${V0}3 +TEST $CLI volume bitrot $V0 scrub resume + +## 0x6b: paused _after_ execution +TEST $CLI volume start $V0 force +TEST $CLI volume bitrot $V0 scrub pause +TEST kill_brick $V0 $H0 $B0/${V0}2 + +cleanup; +#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=1332473 diff --git a/tests/bitrot/br-stub.c b/tests/bitrot/br-stub.c new file mode 100644 index 00000000000..1111f710f59 --- /dev/null +++ b/tests/bitrot/br-stub.c @@ -0,0 +1,195 @@ +#define _GNU_SOURCE + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdint.h> +#include <sys/types.h> +#include <sys/xattr.h> +#include <errno.h> + +#include "bit-rot-object-version.h" + +/* NOTE: no size discovery */ +int +brstub_validate_version(char *bpath, unsigned long version) +{ + int ret = 0; + int match = 0; + size_t xsize = 0; + br_version_t *xv = NULL; + + xsize = sizeof(br_version_t); + + xv = calloc(1, xsize); + if (!xv) { + match = -1; + goto err; + } + + ret = getxattr(bpath, "trusted.bit-rot.version", xv, xsize); + if (ret < 0) { + if (errno == ENODATA) + match = -2; + goto err; + } + + if (xv->ongoingversion != version) { + match = -3; + fprintf(stderr, "ongoingversion: %lu\n", xv->ongoingversion); + } + free(xv); + +err: + return match; +} + +int +brstub_write_validation(char *filp, char *bpath, unsigned long startversion) +{ + int fd1 = 0; + int fd2 = 0; + int ret = 0; + char *string = "string\n"; + + /* read only check */ + fd1 = open(filp, O_RDONLY); + if (fd1 < 0) + goto err; + close(fd1); + + ret = brstub_validate_version(bpath, startversion); + if (ret != -2) + goto err; + + /* single open (write/) check */ + fd1 = open(filp, O_RDWR); + if (fd1 < 0) + goto err; + + ret = write(fd1, string, strlen(string)); + if (ret <= 0) + goto err; + /** + * Fsync is done so that the write call has properly reached the + * disk. For fuse mounts write-behind xlator would have held the + * writes with itself and for nfs, client would have held the + * write in its cache. So write fop would not have triggered the + * versioning as it would have not reached the bit-rot-stub. + */ + fsync(fd1); + ret = brstub_validate_version(bpath, startversion); + if (ret != 0) + goto err; + ret = write(fd1, string, strlen(string)); + if (ret <= 0) + goto err; + fsync(fd1); /* let it reach the disk */ + + ret = brstub_validate_version(bpath, startversion); + if (ret != 0) + goto err; + + close(fd1); + + /** + * Well, this is not a _real_ test per se . For this test to pass + * the inode should not get a forget() in the interim. Therefore, + * perform this test asap. + */ + + /* multi open (write/) check */ + fd1 = open(filp, O_RDWR); + if (fd1 < 0) + goto err; + fd2 = open(filp, O_WRONLY); + if (fd1 < 0) + goto err; + + ret = write(fd1, string, strlen(string)); + if (ret <= 0) + goto err; + + ret = write(fd2, string, strlen(string)); + if (ret <= 0) + goto err; + + /* probably do a syncfs() */ + fsync(fd1); + fsync(fd2); + + close(fd1); + close(fd2); + + /** + * incremented once per write()/write().../close()/close() sequence + */ + ret = brstub_validate_version(bpath, startversion); + if (ret != 0) + goto err; + + return 0; + +err: + return -1; +} + +int +brstub_new_object_validate(char *filp, char *brick) +{ + int ret = 0; + char *fname = NULL; + char bpath[PATH_MAX] = { + 0, + }; + + fname = basename(filp); + if (!fname) + goto err; + + (void)snprintf(bpath, PATH_MAX, "%s/%s", brick, fname); + + printf("Validating initial version..\n"); + ret = brstub_validate_version(bpath, 2); + if (ret != -2) /* version _should_ be missing */ + goto err; + + printf("Validating version on modifications..\n"); + ret = brstub_write_validation(filp, bpath, 2); + if (ret < 0) + goto err; + + return 0; + +err: + return -1; +} + +int +main(int argc, char **argv) +{ + int ret = 0; + char *filp = NULL; + char *brick = NULL; + + if (argc != 3) { + printf("Usage: %s <path> <brick>\n", argv[0]); + goto err; + } + + filp = argv[1]; + brick = argv[2]; + + printf("Validating object version [%s]\n", filp); + ret = brstub_new_object_validate(filp, brick); + if (ret < 0) + goto err; + + return 0; + +err: + return -1; +} diff --git a/tests/bitrot/br-stub.t b/tests/bitrot/br-stub.t new file mode 100644 index 00000000000..cc0319afac9 --- /dev/null +++ b/tests/bitrot/br-stub.t @@ -0,0 +1,66 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc + +#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST + +STUB_SOURCE=$(dirname $0)/br-stub.c +STUB_EXEC=$(dirname $0)/br-stub + +cleanup; + +TEST glusterd +TEST pidof glusterd + +## Create a distribute volume (B=2) +TEST $CLI volume create $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}2; +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '2' brick_count $V0 +TEST $CLI volume set $V0 nfs.disable false + +## Turn off write-behind (write-behind clubs writes together) +TEST $CLI volume set $V0 performance.write-behind off +#EXPECT 'off' volinfo_field $V0 'performance.open-behind' + +## Start the volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## enable bitrot +TEST $CLI volume bitrot $V0 enable; + +## Wait for gluster nfs to come up +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available + +## Mount the volume +TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; +TEST mount_nfs $H0:/$V0 $N0 nolock; + +## Build stub C source +build_tester $STUB_SOURCE -o $STUB_EXEC -I$(dirname $0)/../../xlators/features/bit-rot/src/stub +TEST [ -e $STUB_EXEC ] + +## create & check version +fname="$M0/filezero" +touch $fname; +backpath=$(get_backend_paths $fname) + +TEST $STUB_EXEC $fname $(dirname $backpath) + +rm -f $fname; + +## test nfs +fname="$N0/filezero" +touch $fname; # backpath remains same.. + +TEST $STUB_EXEC $fname $(dirname $backpath) + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" umount_nfs $N0 + +##cleanups.. +rm -f $STUB_EXEC + +cleanup; diff --git a/tests/bitrot/bug-1207627-bitrot-scrub-status.t b/tests/bitrot/bug-1207627-bitrot-scrub-status.t new file mode 100644 index 00000000000..a361986fdaf --- /dev/null +++ b/tests/bitrot/bug-1207627-bitrot-scrub-status.t @@ -0,0 +1,52 @@ +#!/bin/bash + +## Test case for bitrot scrub status BZ:1207627 + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +## Start glusterd +TEST glusterd; +TEST pidof glusterd; + +## Lets create and start the volume +TEST $CLI volume create $V0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 + +## Enable bitrot for volume $V0 +TEST $CLI volume bitrot $V0 enable + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count + +## Setting scrubber frequency daily +TEST $CLI volume bitrot $V0 scrub-frequency hourly + +## Setting scrubber throttle value lazy +TEST $CLI volume bitrot $V0 scrub-throttle lazy + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Active' scrub_status $V0 'State of scrub' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'lazy' scrub_status $V0 'Scrub impact' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'hourly' scrub_status $V0 'Scrub frequency' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT '/var/log/glusterfs/bitd.log' scrub_status $V0 'Bitrot error log location' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT '/var/log/glusterfs/scrub.log' scrub_status $V0 'Scrubber error log location' + +## Set expiry-timeout to 1 sec +TEST $CLI volume set $V0 features.expiry-time 1 + +##Mount $V0 +TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0 + +#Create sample file +TEST `echo "1234" > $M0/FILE1` +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'trusted.bit-rot.signature' check_for_xattr 'trusted.bit-rot.signature' "/$B0/${V0}1/FILE1" + +##Corrupt the file +TEST `echo "corrupt" >> /$B0/${V0}1/FILE1` + +## Ondemand scrub +TEST $CLI volume bitrot $V0 scrub ondemand +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'trusted.bit-rot.bad-file' check_for_xattr 'trusted.bit-rot.bad-file' "/$B0/${V0}1/FILE1" + +cleanup; diff --git a/tests/bitrot/bug-1221914.t b/tests/bitrot/bug-1221914.t new file mode 100644 index 00000000000..7f6c10c50df --- /dev/null +++ b/tests/bitrot/bug-1221914.t @@ -0,0 +1,51 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc + +STUB_SOURCE=$(dirname $0)/br-stub.c +STUB_EXEC=$(dirname $0)/br-stub + +cleanup; + +TEST glusterd +TEST pidof glusterd + +## Create a distribute volume (B=2) +TEST $CLI volume create $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}2; +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '2' brick_count $V0 + +## Turn off write-behind (write-behind clubs writes together) +TEST $CLI volume set $V0 performance.write-behind off + +## Start the volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Enable bitrot +TEST $CLI volume bitrot $V0 enable; + +## Mount the volume +TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; + +## Build stub C source +build_tester $STUB_SOURCE -o $STUB_EXEC -I$(dirname $0)/../../xlators/features/bit-rot/src/stub +TEST [ -e $STUB_EXEC ] + +## create & check version +fname="$M0/filezero" +$PYTHON -c "import os,stat; os.mknod('${fname}', stat.S_IFREG | stat.S_IRUSR | stat.S_IWUSR | stat.S_IROTH | stat.S_IRGRP)" + +backpath=$(get_backend_paths $fname) + +TEST $STUB_EXEC $fname $(dirname $backpath) + +rm -f $fname; + +##cleanups.. +rm -f $STUB_EXEC + +cleanup; diff --git a/tests/bitrot/bug-1244613.t b/tests/bitrot/bug-1244613.t new file mode 100644 index 00000000000..57b86a94ac0 --- /dev/null +++ b/tests/bitrot/bug-1244613.t @@ -0,0 +1,95 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc +. $(dirname $0)/../fileio.rc + +#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST + +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'; +TEST $CLI volume set $V0 nfs.disable false + +# 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'; + +## Enable bitrot +TEST $CLI volume bitrot $V0 enable; + +## Wait for gluster nfs to come up +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available + +TEST mount_nfs $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 +echo "Hello" > $N0/$deep/new_file_1 +echo "World" >> $N0/$deep/new_file_1 +echo 1 >> $N0/$deep/new_file_1 +echo 2 >> $N0/$deep/new_file_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 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 + 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 + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0 + +TEST $CLI volume stop $V0 + +cleanup; diff --git a/tests/bitrot/bug-1294786.t b/tests/bitrot/bug-1294786.t new file mode 100644 index 00000000000..5b4b6ddb4d3 --- /dev/null +++ b/tests/bitrot/bug-1294786.t @@ -0,0 +1,95 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../cluster.rc + +function get_bitd_count_1 { + ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H1 | wc -l +} + +function get_bitd_count_2 { + ps auxww | grep glusterfs | grep bitd.pid | grep -v grep | grep $H2 | wc -l +} + +function get_node_uuid { + getfattr -n trusted.glusterfs.node-uuid --only-values $M0/FILE1 2>/dev/null +} + +cleanup; + +TEST launch_cluster 2 + +TEST $CLI_1 peer probe $H2; +EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count; + +TEST $CLI_1 volume create $V0 replica 2 $H1:$B1 $H2:$B2 +EXPECT 'Created' volinfo_field_1 $V0 'Status'; + +TEST $CLI_1 volume start $V0 +EXPECT 'Started' volinfo_field_1 $V0 'Status'; + +uuid1=$($CLI_1 system:: uuid get | awk '{print $2}') +uuid2=$($CLI_2 system:: uuid get | awk '{print $2}') + +##Mount $V0 +TEST $GFS --volfile-id=$V0 --volfile-server=$H1 $M0 + +#Enable bitrot +TEST $CLI_1 volume bitrot $V0 enable +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_2 + +#Create sample file +TEST `echo "1234" > $M0/FILE1` +TEST `echo "5678" > $M0/FILE2` +gfid1=$(getfattr -n glusterfs.gfid.string --only-values $M0/FILE1) +gfid2=$(getfattr -n glusterfs.gfid.string --only-values $M0/FILE2) + +EXPECT "$uuid1" get_node_uuid; + +#Corrupt file from back-end +TEST stat $B1/FILE1 +TEST stat $B1/FILE2 +echo "Corrupted data" >> $B1/FILE1 +echo "Corrupted data" >> $B1/FILE2 +#Manually set bad-file xattr since we can't wait for an hour for scrubber. +TEST setfattr -n trusted.bit-rot.bad-file -v 0x3100 $B1/FILE1 +TEST setfattr -n trusted.bit-rot.bad-file -v 0x3100 $B1/FILE2 +TEST touch "$B1/.glusterfs/quarantine/$gfid1" +TEST chmod 000 "$B1/.glusterfs/quarantine/$gfid1" +TEST touch "$B1/.glusterfs/quarantine/$gfid2" +TEST chmod 000 "$B1/.glusterfs/quarantine/$gfid2" +EXPECT "4" get_quarantine_count "$B1"; + +TEST $CLI_1 volume stop $V0 +TEST $CLI_1 volume start $V0 +EXPECT 'Started' volinfo_field_1 $V0 'Status'; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" cluster_brick_up_status 1 $V0 $H1 $B1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" cluster_brick_up_status 1 $V0 $H2 $B2 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_1 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count_2 +#Trigger lookup so that bitrot xlator marks file as bad in its inode context. +TEST stat $M0/FILE1 +TEST stat $M0/FILE2 + +EXPECT "$uuid2" get_node_uuid; + +#BUG 1308961 +#Remove bad files from mount, it should be removed from quarantine directory. +TEST rm -f $M0/FILE1 +TEST ! stat "$B1/.glusterfs/quarantine/$gfid1" + +#BUG 1308961 +#Set network.inode-lru-limit to 5 and exceed the limit by creating 10 other files. +#The bad entry from quarantine directory should not be removed. +TEST $CLI_1 volume set $V0 network.inode-lru-limit 5 +for i in {1..10} +do + echo "1234" > $M0/file_$i +done +TEST stat "$B1/.glusterfs/quarantine/$gfid2" + +cleanup; diff --git a/tests/bitrot/bug-1373520.t b/tests/bitrot/bug-1373520.t new file mode 100644 index 00000000000..6af5124e86e --- /dev/null +++ b/tests/bitrot/bug-1373520.t @@ -0,0 +1,71 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +#Create a disperse volume +TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5} +TEST $CLI volume start $V0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "6" online_brick_count +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status' + +#Disable self heal daemon as it races in this test with lookup on volume +#stop and start. +$CLI volume set $V0 self-heal-daemon off + +#Disable few perf xlators to get the first lookup on the brick +TEST $CLI volume set $V0 performance.stat-prefetch off +TEST $CLI volume set $V0 performance.force-readdirp off +TEST $CLI volume set $V0 dht.force-readdirp off + +#Mount the volume +TEST $GFS -s $H0 --use-readdirp=no --attribute-timeout=0 --entry-timeout=0 --volfile-id $V0 $M0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 + +#Enable bitrot +TEST $CLI volume bitrot $V0 enable +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count + +#Create sample file +TEST `echo "1234" > $M0/FILE1` +#Create hardlink +TEST `ln $M0/FILE1 $M0/HL_FILE1` + +#Corrupt file from back-end +TEST stat $B0/${V0}5/FILE1 +SIZE=$(stat -c %s $B0/${V0}5/FILE1) +echo "Corrupted data" >> $B0/${V0}5/FILE1 +gfid1=$(getfattr -n glusterfs.gfid.string --only-values $M0/FILE1) + +#Manually set bad-file xattr +TEST setfattr -n trusted.bit-rot.bad-file -v 0x3100 $B0/${V0}5/FILE1 +TEST touch "$B0/${V0}5/.glusterfs/quarantine/$gfid1" +TEST chmod 000 "$B0/${V0}5/.glusterfs/quarantine/$gfid1" +EXPECT "3" get_quarantine_count "$B0/${V0}5"; + +TEST $CLI volume stop $V0 +TEST $CLI volume start $V0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count + +#Delete file and all links from backend +TEST rm -rf $(find $B0/${V0}5 -inum $(stat -c %i $B0/${V0}5/FILE1)) + +#New mount for recovery +TEST $GFS -s $H0 --use-readdirp=no --attribute-timeout=0 --entry-timeout=0 --volfile-id $V0 $M1 + +$CLI volume set $V0 self-heal-daemon on +TEST $CLI volume heal $V0 + +#Access files +TEST cat $M1/FILE1 +EXPECT_WITHIN $HEAL_TIMEOUT "$SIZE" path_size $B0/${V0}5/FILE1 +TEST cat $M1/HL_FILE1 +EXPECT_WITHIN $HEAL_TIMEOUT "$SIZE" path_size $B0/${V0}5/HL_FILE1 + +cleanup; diff --git a/tests/bitrot/bug-1700078.t b/tests/bitrot/bug-1700078.t new file mode 100644 index 00000000000..f27374211fe --- /dev/null +++ b/tests/bitrot/bug-1700078.t @@ -0,0 +1,87 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +## Start glusterd +TEST glusterd; +TEST pidof glusterd; + +## Lets create and start the volume +TEST $CLI volume create $V0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 + +## Enable bitrot for volume $V0 +TEST $CLI volume bitrot $V0 enable + +## Turn off quick-read so that it wont cache the contents +# of the file in lookup. For corrupted files, it might +# end up in reads being served from the cache instead of +# an error. +TEST $CLI volume set $V0 performance.quick-read off + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Active' scrub_status $V0 'State of scrub' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT '/var/log/glusterfs/bitd.log' scrub_status $V0 'Bitrot error log location' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT '/var/log/glusterfs/scrub.log' scrub_status $V0 'Scrubber error log location' + +## Set expiry-timeout to 1 sec +TEST $CLI volume set $V0 features.expiry-time 1 + +##Mount $V0 +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + +## Turn off quick-read xlator so that, the contents are not served from the +# quick-read cache. +TEST $CLI volume set $V0 performance.quick-read off + +#Create sample file +TEST `echo "1234" > $M0/FILE1` +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'trusted.bit-rot.signature' check_for_xattr 'trusted.bit-rot.signature' "/$B0/${V0}1/FILE1" + +##disable bitrot +TEST $CLI volume bitrot $V0 disable + +## modify the file +TEST `echo "write" >> $M0/FILE1` + +# unmount and remount when the file has to be accessed. +# This is to ensure that, when the remount happens, +# and the file is read, its contents are served from the +# brick instead of cache. +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 + +##enable bitrot +TEST $CLI volume bitrot $V0 enable + +# expiry time is set to 1 second. Hence sleep for 2 seconds for the +# oneshot crawler to finish its crawling and sign the file properly. +sleep 2 + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Active' scrub_status $V0 'State of scrub' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT '/var/log/glusterfs/bitd.log' scrub_status $V0 'Bitrot error log location' +EXPECT_WITHIN $PROCESS_UP_TIMEOUT '/var/log/glusterfs/scrub.log' scrub_status $V0 'Scrubber error log location' + +## Ondemand scrub +TEST $CLI volume bitrot $V0 scrub ondemand + +# the scrub ondemand CLI command, just ensures that +# the scrubber has received the ondemand scrub directive +# and started. sleep for 2 seconds for scrubber to finish +# crawling and marking file(s) as bad (if if finds that +# corruption has happened) which are filesystem operations. +sleep 2 + +TEST ! getfattr -n 'trusted.bit-rot.bad-file' $B0/${V0}1/FILE1 + +##Mount $V0 +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + +TEST cat $M0/FILE1 + +cleanup; diff --git a/tests/bitrot/bug-internal-xattrs-check-1243391.t b/tests/bitrot/bug-internal-xattrs-check-1243391.t new file mode 100644 index 00000000000..bc9c12520b2 --- /dev/null +++ b/tests/bitrot/bug-internal-xattrs-check-1243391.t @@ -0,0 +1,42 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +## Create a distribute volume (B=2) +TEST $CLI volume create $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}2; +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '2' brick_count $V0 + + +## Start the volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount the volume +TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; + +echo "123" >> $M0/file; + +TEST ! setfattr -n "trusted.glusterfs.set-signature" -v "123" $M0/file; +TEST ! setfattr -n "trusted.glusterfs.get-signature" -v "123" $M0/file; + +# sign xattr +TEST ! setfattr -n "trusted.bit-rot.signature" -v "123" $M0/file; +TEST ! setfattr -x "trusted.bit-rot.signature" $M0/file; + +# versioning xattr +TEST ! setfattr -n "trusted.bit-rot.version" -v "123" $M0/file; +TEST ! setfattr -x "trusted.bit-rot.version" $M0/file; + +# bad file xattr +TEST ! setfattr -n "trusted.bit-rot.bad-file" -v "123" $M0/file; +TEST ! setfattr -x "trusted.bit-rot.bad-file" $M0/file; + +cleanup; |
