diff options
Diffstat (limited to 'tests/bugs/distribute')
35 files changed, 2513 insertions, 0 deletions
diff --git a/tests/bugs/distribute/bug-1042725.t b/tests/bugs/distribute/bug-1042725.t new file mode 100644 index 00000000000..5497eb8bc00 --- /dev/null +++ b/tests/bugs/distribute/bug-1042725.t @@ -0,0 +1,49 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2}; +TEST $CLI volume start $V0 + +# Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +#Create files +TEST mkdir $M0/foo +TEST touch $M0/foo/{1..20} +for file in {1..20}; do + ln $M0/foo/$file $M0/foo/${file}_linkfile; +done + +#Stop one of the brick +TEST kill_brick ${V0} ${H0} ${B0}/${V0}1 + +rm -rf $M0/foo 2>/dev/null +TEST stat $M0/foo + +touch $M0/foo/{1..20} 2>/dev/null +touch $M0/foo/{1..20}_linkfile 2>/dev/null + +TEST $CLI volume start $V0 force; +sleep 5 +function verify_duplicate { + count=`ls $M0/foo | sort | uniq --repeated | grep [0-9] -c` + echo $count +} +EXPECT 0 verify_duplicate + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/distribute/bug-1066798.t b/tests/bugs/distribute/bug-1066798.t new file mode 100755 index 00000000000..03de970a637 --- /dev/null +++ b/tests/bugs/distribute/bug-1066798.t @@ -0,0 +1,88 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TESTS_EXPECTED_IN_LOOP=200 + +## Start glusterd +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +## Lets create volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; + +## Verify volume is created +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +## Start volume and verify +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; +TEST glusterfs -s $H0 --volfile-id=$V0 $M0 + +############################################################ +#TEST_PLAN# +#Create a file +#Store the hashed brick information +#Create hard links to it +#Remove the hashed brick +#Check now all the hardlinks are migrated in to "OTHERBRICK" +#Check also in mount point for all the files +#check there is no failures and skips for migration +############################################################ + +TEST touch $M0/file1; + +file_perm=`ls -l $M0/file1 | grep file1 | awk '{print $1}'`; + +if [ -f $B0/${V0}1/file1 ] +then + HASHED=$B0/${V0}1 + OTHER=$B0/${V0}2 +else + HASHED=$B0/${V0}2 + OTHER=$B0/${V0}1 +fi + +#create hundred hard links +for i in {1..50}; +do +TEST_IN_LOOP ln $M0/file1 $M0/link$i; +done + + +TEST $CLI volume remove-brick $V0 $H0:${HASHED} start +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0" "$H0:${HASHED}"; + +#check consistency in mount point +#And also check all the links are migrated to OTHER +for i in {1..50} +do +TEST_IN_LOOP [ -f ${OTHER}/link${i} ]; +TEST_IN_LOOP [ -f ${M0}/link${i} ]; +done; + +#check in OTHER that all the files has proper permission (Means no +#linkto files) + +for i in {1..50} +do +link_perm=`ls -l $OTHER | grep -w link${i} | awk '{print $1}'`; +TEST_IN_LOOP [ "${file_perm}" == "${link_perm}" ] + +done + +#check that remove-brick status should not have any failed or skipped files + +var=`$CLI volume remove-brick $V0 $H0:${HASHED} status | grep completed` + +TEST [ `echo $var | awk '{print $5}'` = "0" ] +TEST [ `echo $var | awk '{print $6}'` = "0" ] + +cleanup +#G_TESTDEF_TEST_STATUS_CENTOS6=BAD_TEST,BUG=000000 +#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000 diff --git a/tests/bugs/distribute/bug-1086228.t b/tests/bugs/distribute/bug-1086228.t new file mode 100755 index 00000000000..e14ea572b61 --- /dev/null +++ b/tests/bugs/distribute/bug-1086228.t @@ -0,0 +1,34 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../fileio.rc +. $(dirname $0)/../../dht.rc +cleanup; + +## Start and create a volume +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2} +TEST $CLI volume start $V0; +TEST glusterfs --direct-io-mode=yes --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; + +echo "D" > $M0/file1; +TEST chmod +st $M0/file1; + +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}"3" +TEST $CLI volume rebalance $V0 start force + +EXPECT_WITHIN "10" "0" rebalance_completed +count=0 +for i in `ls $B0/$V0"3"`; + do + var=`stat -c %A $B0/$V0"3"/$i | cut -c 4`; + echo $B0/$V0"3"/$i $var + if [ "$var" != "S" ]; then + count=$((count + 1)) + fi + done + +TEST [[ $count == 0 ]] +cleanup diff --git a/tests/bugs/distribute/bug-1088231.t b/tests/bugs/distribute/bug-1088231.t new file mode 100755 index 00000000000..8d4d1db73a5 --- /dev/null +++ b/tests/bugs/distribute/bug-1088231.t @@ -0,0 +1,173 @@ +#!/bin/bash +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../fileio.rc +. $(dirname $0)/../../dht.rc + + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 cluster.randomize-hash-range-by-gfid on +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0 +TEST mkdir $M0/a + + +## Bug Description: In case of dht_discover code path, which is triggered +## when lookup done is nameless lookup, at the end of the lookup, even if +## it finds that self-heal is needed to fix-the layout it wont heal because +## healing code path is not added under nameless lookup. + +## What to test: With Patch, Even in case of nameless lookup, if layout +## needs to be fixed, the it will be fixed wherever lookup is successful +## and it will not create any directory for subvols having ENOENT as it is +## nameless lookup. + +gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \ + | grep glusterfs.gfid.string | cut -d '"' -f 2` + +TEST setfattr -x trusted.glusterfs.dht $B0/$V0"0"/a + +## new healing code don't attempt healing if inode is already +## populated. So, unmount and remount before we do stat. +TEST umount $M0 +TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0 + +TEST stat $M0/.gfid/$gfid_with_hyphen + +## Assuming that we have two bricks, we can have two permutations of layout +## Case 1: Brick - A Brick - B +## 0 - 50 51-100 +## +## Case 2: Brick - A Brick - B +## 51 - 100 0 - 50 +## +## To ensure layout is assigned properly, the following tests should be +## performed. +## +## Case 1: Layout_b0_s = 0; Layout_b0_e = 50, Layout_b1_s=51, +## Layout_b1_e = 100; +## +## layout_b1_s = layout_b0_e + 1; +## layout_b0_s = layout_b1_e + 1; but b0_s is 0, so change to 101 +## then compare +## Case 2: Layout_b0_s = 51, Layout_b0_e = 100, Layout_b1_s=0, +## Layout_b1_e = 51 +## +## layout_b0_s = Layout_b1_e + 1; +## layout_b1_s = Layout_b0_e + 1; but b1_s is 0, so chage to 101. + + +##Extract Layout +echo `get_layout $B0/$V0"0"/a` +echo `get_layout $B0/$V0"1"/a` +layout_b0_s=`get_layout $B0/$V0"0"/a | cut -c19-26` +layout_b0_e=`get_layout $B0/$V0"0"/a | cut -c27-34` +layout_b1_s=`get_layout $B0/$V0"1"/a | cut -c19-26` +layout_b1_e=`get_layout $B0/$V0"1"/a | cut -c27-34` + + +##Add 0X to perform Hex arithematic +layout_b0_s="0x"$layout_b0_s +layout_b0_e="0x"$layout_b0_e +layout_b1_s="0x"$layout_b1_s +layout_b1_e="0x"$layout_b1_e + + +## Logic of converting starting layout "0" to "Max_value of layout + 1" +comp1=$(($layout_b0_s + 0)) +if [ "$comp1" == "0" ];then + comp1=4294967296 +fi + +comp2=$(($layout_b1_s + 0)) +if [ "$comp2" == "0" ];then + comp2=4294967296 +fi + +diff1=$(($layout_b0_e + 1)) +diff2=$(($layout_b1_e + 1)) + + +healed=0 + +if [ "$comp1" == "$diff1" ] && [ "$comp2" == "$diff2" ]; then + healed=$(($healed + 1)) +fi + +if [ "$comp1" == "$diff2" ] && [ "$comp2" == "$diff1" ]; then + healed=$(($healed + 1)) +fi + +TEST [ $healed == 1 ] + +cleanup + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 cluster.randomize-hash-range-by-gfid on +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0 +TEST mkdir $M0/a + +gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \ + | grep glusterfs.gfid.string | cut -d '"' -f 2` + +TEST setfattr -x trusted.glusterfs.dht $B0/$V0"0"/a +TEST setfattr -x trusted.glusterfs.dht $B0/$V0"1"/a + +## new healing code don't attempt healing if inode is already +## populated. So, unmount and remount before we do stat. +TEST umount $M0 +TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0 + +TEST stat $M0/.gfid/$gfid_with_hyphen + +##Extract Layout + +layout_b0_s=`get_layout $B0/$V0"0"/a | cut -c19-26` +layout_b0_e=`get_layout $B0/$V0"0"/a | cut -c27-34` +layout_b1_s=`get_layout $B0/$V0"1"/a | cut -c19-26` +layout_b1_e=`get_layout $B0/$V0"1"/a | cut -c27-34` + + +##Add 0X to perform Hex arithematic +layout_b0_s="0x"$layout_b0_s +layout_b0_e="0x"$layout_b0_e +layout_b1_s="0x"$layout_b1_s +layout_b1_e="0x"$layout_b1_e + + + +## Logic of converting starting layout "0" to "Max_value of layout + 1" +comp1=$(($layout_b0_s + 0)) +if [ "$comp1" == "0" ];then + comp1=4294967296 +fi + +comp2=$(($layout_b1_s + 0)) +if [ "$comp2" == "0" ];then + comp2=4294967296 +fi + +diff1=$(($layout_b0_e + 1)) +diff2=$(($layout_b1_e + 1)) + + +healed=0 + +if [ "$comp1" == "$diff1" ] && [ "$comp2" == "$diff2" ]; then + healed=$(($healed + 1)) +fi + +if [ "$comp1" == "$diff2" ] && [ "$comp2" == "$diff1" ]; then + healed=$(($healed + 1)) +fi + +TEST [ $healed == 1 ] +cleanup + diff --git a/tests/bugs/distribute/bug-1099890.t b/tests/bugs/distribute/bug-1099890.t new file mode 100644 index 00000000000..1a19ba880c0 --- /dev/null +++ b/tests/bugs/distribute/bug-1099890.t @@ -0,0 +1,130 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../dht.rc + +## TO-DO: Fix the following once the dht du refresh interval issue is fixed: +## 1. Do away with sleep(1). +## 2. Do away with creation of empty files. + +cleanup; + +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + +TEST glusterd; +TEST pidof glusterd; + +# Create 2 loop devices, one per brick. +TEST truncate -s 100M $B0/brick1 +TEST truncate -s 100M $B0/brick2 + +TEST L1=`SETUP_LOOP $B0/brick1` +TEST MKFS_LOOP $L1 + +TEST L2=`SETUP_LOOP $B0/brick2` +TEST MKFS_LOOP $L2 + +TEST mkdir -p $B0/${V0}{1,2} + +TEST MOUNT_LOOP $L1 $B0/${V0}1 +TEST MOUNT_LOOP $L2 $B0/${V0}2 + +# Create a plain distribute volume with 2 subvols. +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; + +TEST $CLI volume start $V0; +EXPECT "Started" volinfo_field $V0 'Status'; + +TEST $CLI volume quota $V0 enable; + +TEST $CLI volume set $V0 features.quota-deem-statfs on + +TEST $CLI volume quota $V0 limit-usage / 150MB; + +TEST $CLI volume set $V0 cluster.min-free-disk 50% + +TEST glusterfs -s $H0 --volfile-id=$V0 $M0 + +# Make sure quota-deem-statfs is working as expected +EXPECT "150M" echo `df -h $M0 -P | tail -1 | awk {'print $2'}` + +# Create a new file 'foo' under the root of the volume, which hashes to subvol-0 +# of DHT, that consumes 40M +TEST $QDD $M0/foo 256 160 + +TEST stat $B0/${V0}1/foo +TEST ! stat $B0/${V0}2/foo + +# Create a new file 'bar' under the root of the volume, which hashes to subvol-1 +# of DHT, that consumes 40M +TEST $QDD $M0/bar 256 160 + +TEST ! stat $B0/${V0}1/bar +TEST stat $B0/${V0}2/bar + +# Touch a zero-byte file on the root of the volume to make sure the statfs data +# on DHT is refreshed +sleep 1; +TEST touch $M0/empty1; + +# At this point, the available space on each subvol {60M,60M} is greater than +# their min-free-disk {50M,50M}, but if this bug still exists, then +# the total available space on the volume as perceived by DHT should be less +# than min-free-disk, i.e., +# +# consumed space returned per subvol by quota = (40M + 40M) = 80M +# +# Therefore, consumed space per subvol computed by DHT WITHOUT the fix would be: +# (80M/150M)*100 = 53% +# +# Available space per subvol as perceived by DHT with the bug = 47% +# which is less than min-free-disk + +# Now I create a file that hashes to subvol-1 (counting from 0) of DHT. +# If this bug still exists,then DHT should be routing this creation to subvol-0. +# If this bug is fixed, then DHT should be routing the creation to subvol-1 only +# as it has more than min-free-disk space available. + +TEST $QDD $M0/file 1 1 +sleep 1; +TEST ! stat $B0/${V0}1/file +TEST stat $B0/${V0}2/file + +# Touch another zero-byte file on the root of the volume to refresh statfs +# values stored by DHT. + +TEST touch $M0/empty2; + +# Now I create a new file that hashes to subvol-0, at the end of which, there +# will be less than min-free-disk space available on it. +TEST $QDD $M0/fil 256 80 +sleep 1; +TEST stat $B0/${V0}1/fil +TEST ! stat $B0/${V0}2/fil + +# Touch to refresh statfs info cached by DHT + +TEST touch $M0/empty3; + +# Now I create a file that hashes to subvol-0 but since it has less than +# min-free-disk space available, its data will be cached on subvol-1. + +TEST $QDD $M0/zz 256 20 + +TEST stat $B0/${V0}1/zz +TEST stat $B0/${V0}2/zz + +EXPECT "$V0-client-1" dht_get_linkto_target "$B0/${V0}1/zz" + +EXPECT "1" is_dht_linkfile "$B0/${V0}1/zz" + +force_umount $M0 +TEST $CLI volume stop $V0 +UMOUNT_LOOP ${B0}/${V0}{1,2} +rm -f ${B0}/brick{1,2} + +rm -f $QDD +cleanup diff --git a/tests/bugs/distribute/bug-1125824.t b/tests/bugs/distribute/bug-1125824.t new file mode 100755 index 00000000000..7e401092273 --- /dev/null +++ b/tests/bugs/distribute/bug-1125824.t @@ -0,0 +1,103 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../nfs.rc + +#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST + +create_files () { + for i in {1..10}; do + orig=$(printf %s/file%04d $1 $i) + echo "This is file $i" > $orig + done + for i in {1..10}; do + mkdir $(printf %s/dir%04d $1 $i) + done + sync +} + +create_dirs () { + for i in {1..10}; do + mkdir $(printf %s/dir%04d $1 $i) + create_files $(printf %s/dir%04d $1 $i) + done + sync +} + +stat_files () { + for i in {1..10}; do + orig=$(printf %s/file%04d $1 $i) + stat $orig + done + for i in {1..10}; do + stat $(printf %s/dir%04d $1 $i) + done + sync +} + +stat_dirs () { + for i in {1..10}; do + stat $(printf %s/dir%04d $1 $i) + stat_files $(printf %s/dir%04d $1 $i) + done + sync +} + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 replica 2 $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 set $V0 nfs.disable false +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available; +TEST mount_nfs $H0:/$V0 $N0 + +# Create and poulate the NFS inode tables +TEST create_dirs $N0 +TEST stat_dirs $N0 + +# add-bricks changing the state of the volume where some bricks +# would have some directories and others would not +TEST $CLI volume add-brick $V0 replica 2 $H0:$B0/${V0}{5,6,7,8} + +# Post this dht_access was creating a mess for directories which is fixed +# with this commit. The issues could range from getting ENOENT or +# ESTALE or entries missing to directories not having complete +# layouts. +TEST cd $N0 +TEST ls -lR + +TEST $CLI volume rebalance $V0 start force +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0 + +# tests to check post rebalance if layouts and entires are fine and +# accessible by NFS to clear the volume +TEST ls -lR +rm -rf ./* +# There are additional bugs where NFS+DHT does not delete all entries +# on an rm -rf, so we do an additional rm -rf to ensure all is done +# and we are facing this transient issue, rather than a bad directory +# layout that is cached in memory +TEST rm -rf ./* + +# Get out of the mount, so that umount can work +TEST cd / + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0 +TEST $CLI volume stop $V0; +EXPECT 'Stopped' volinfo_field $V0 'Status'; +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/distribute/bug-1161156.t b/tests/bugs/distribute/bug-1161156.t new file mode 100755 index 00000000000..2b9e15407ca --- /dev/null +++ b/tests/bugs/distribute/bug-1161156.t @@ -0,0 +1,58 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../nfs.rc + +#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST + +cleanup; + +QDD=$(dirname $0)/quota +# compile the test write program and run it +build_tester $(dirname $0)/../../basic/quota.c -o $QDD + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4,5,6}; +EXPECT 'Created' volinfo_field $V0 'Status'; + +TEST $CLI volume set $V0 nfs.disable false +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +# Testing with NFS for no particular reason +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT 1 is_nfs_export_available +TEST mount_nfs $H0:/$V0 $N0 +mydir="dir" +TEST mkdir -p $N0/$mydir +TEST mkdir -p $N0/newdir + +TEST $QDD $N0/$mydir/file 256 40 + +TEST $CLI volume quota $V0 enable +TEST $CLI volume quota $V0 limit-usage / 20MB +TEST $CLI volume quota $V0 limit-usage /newdir 5MB +TEST $CLI volume quota $V0 soft-timeout 0 +TEST $CLI volume quota $V0 hard-timeout 0 + +TEST $QDD $N0/$mydir/newfile_1 256 20 +# wait for write behind to complete. +EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "15.0MB" quotausage "/" +TEST ! $QDD $N0/$mydir/newfile_2 256 40 + +# Test rename within a directory. It should pass even when the +# corresponding directory quota is filled. +TEST mv $N0/dir/file $N0/dir/newfile_3 + +# rename should fail here with disk quota exceeded +TEST ! mv $N0/dir/newfile_3 $N0/newdir/ + +umount_nfs $N0 +TEST $CLI volume stop $V0 + +rm -f $QDD + +cleanup; diff --git a/tests/bugs/distribute/bug-1161311.t b/tests/bugs/distribute/bug-1161311.t new file mode 100755 index 00000000000..62796068928 --- /dev/null +++ b/tests/bugs/distribute/bug-1161311.t @@ -0,0 +1,164 @@ +#!/bin/bash + +SCRIPT_TIMEOUT=350 + +# This tests for hard link preservation for files that are linked, when the +# file is undergoing migration + +# --- Improvements and other tests --- +## Fail rebalance of the large file for which links are created during P1/2 +### phases of migration +## Start with multiple hard links to the file and then create more during P1/2 +### phases of migration +## Test the same with NFS as the mount rather than FUSE +## Create links when file is under P2 of migration specifically +## Test with quota, to error out during hard link creation (if possible) + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup +TEST truncate -s 10GB $B0/brick1 +TEST truncate -s 10GB $B0/brick2 +TEST truncate -s 10GB $B0/brick3 + +TEST LO1=`SETUP_LOOP $B0/brick1` +TEST MKFS_LOOP $LO1 + +TEST LO2=`SETUP_LOOP $B0/brick2` +TEST MKFS_LOOP $LO2 + +TEST LO3=`SETUP_LOOP $B0/brick3` +TEST MKFS_LOOP $LO3 + +TEST mkdir -p $B0/${V0}1 $B0/${V0}2 $B0/${V0}3 + + +TEST MOUNT_LOOP $LO1 $B0/${V0}1 +TEST MOUNT_LOOP $LO2 $B0/${V0}2 +TEST MOUNT_LOOP $LO3 $B0/${V0}3 + +checksticky () { + i=0; + while [ ! -k $1 ]; do + sleep 1 + i=$((i+1)); + # Try for 10 seconds to get the sticky bit state + # else fail the test, as we may never see it + if [[ $i == 10 ]]; then + return $i + fi + echo "Waiting... $i" + done + echo "Done... got out @ $i" + return 0 +} + + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3}; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '3' brick_count $V0 + +TEST $CLI volume set $V0 parallel-readdir on +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount FUSE with caching disabled (read-write) +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +# Create a directories to hold the links +TEST mkdir $M0/dir1 +TEST mkdir -p $M0/dir2/dir3 + +# Create a large file (8 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 8G $M0/dir1/FILE2 + +# Rename the file to create a linkto, for rebalance to +# act on the file +## FILE1 and FILE2 hashes are, 678b1c4a e22c1ada, so they fall +## into separate bricks when brick count is 3 +TEST mv $M0/dir1/FILE2 $M0/dir1/FILE1 + +brick_loc=$(get_backend_paths $M0/dir1/FILE1) + +# unmount and remount the volume +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +# Start the rebalance +TEST $CLI volume rebalance $V0 start force + +# Wait for FILE to get the sticky bit on, so that file is under +# active rebalance, before creating the links +TEST checksticky $brick_loc + +# Create the links +## FILE3 FILE5 FILE7 have hashes, c8c91469 566d26ce 22ce7eba +## Which fall into separate bricks on a 3 brick layout +cd $M0 +TEST ln ./dir1/FILE1 ./dir1/FILE7 +TEST ln ./dir1/FILE1 ./dir1/FILE5 +TEST ln ./dir1/FILE1 ./dir1/FILE3 + +TEST ln ./dir1/FILE1 ./dir2/FILE7 +TEST ln ./dir1/FILE1 ./dir2/FILE5 +TEST ln ./dir1/FILE1 ./dir2/FILE3 + +TEST ln ./dir1/FILE1 ./dir2/dir3/FILE7 +TEST ln ./dir1/FILE1 ./dir2/dir3/FILE5 +TEST ln ./dir1/FILE1 ./dir2/dir3/FILE3 +cd / + +# Ideally for this test to have done its job, the file should still be +# under migration, so check the sticky bit again +TEST checksticky $brick_loc + +# Wait for rebalance to complete +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0 + +# Check if all files are clean and migrated right +## stat on the original file should show linkcount of 10 +linkcountsrc=$(stat -c %h $M0/dir1/FILE1) +TEST [[ $linkcountsrc == 10 ]] + +## inode and size of every file should be same as original file +inodesrc=$(stat -c %i $M0/dir1/FILE1) +TEST [[ $(stat -c %i $M0/dir1/FILE3) == $inodesrc ]] +TEST [[ $(stat -c %i $M0/dir1/FILE5) == $inodesrc ]] +TEST [[ $(stat -c %i $M0/dir1/FILE7) == $inodesrc ]] + +TEST [[ $(stat -c %i $M0/dir2/FILE3) == $inodesrc ]] +TEST [[ $(stat -c %i $M0/dir2/FILE5) == $inodesrc ]] +TEST [[ $(stat -c %i $M0/dir2/FILE7) == $inodesrc ]] + +TEST [[ $(stat -c %i $M0/dir2/dir3/FILE3) == $inodesrc ]] +TEST [[ $(stat -c %i $M0/dir2/dir3/FILE5) == $inodesrc ]] +TEST [[ $(stat -c %i $M0/dir2/dir3/FILE7) == $inodesrc ]] + +# Check, newer link creations +cd $M0 +TEST ln ./dir1/FILE1 ./FILE1 +TEST ln ./dir2/FILE3 ./FILE3 +TEST ln ./dir2/dir3/FILE5 ./FILE5 +TEST ln ./dir1/FILE7 ./FILE7 +cd / +linkcountsrc=$(stat -c %h $M0/dir1/FILE1) +TEST [[ $linkcountsrc == 14 ]] + + +# Stop the volume +TEST $CLI volume stop $V0; + +UMOUNT_LOOP ${B0}/${V0}{1..3} +rm -f ${B0}/brick{1..3} +cleanup; diff --git a/tests/bugs/distribute/bug-1190734.t b/tests/bugs/distribute/bug-1190734.t new file mode 100644 index 00000000000..9256088f7a0 --- /dev/null +++ b/tests/bugs/distribute/bug-1190734.t @@ -0,0 +1,93 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../nfs.rc + +#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST + +BRICK_COUNT=3 +FILE_COUNT=100 +FILE_COUNT_TIME=5 + +function create_files { + rm -rf $2 + mkdir $2 + for i in `seq 1 $1`; do + touch $2/file_$i + done +} + +function get_file_count { + ls $1/file_[0-9]* | wc -l +} + +function reset { + $CLI volume stop $V0 + ${UMOUNT_F} $1 + $CLI volume delete $V0 +} + +function start_mount_fuse { + $CLI volume start $V0 + [ $? -ne 0 ] && return 1 + + $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 + [ $? -ne 0 ] && return 1 + + create_files $FILE_COUNT $M0/$1 + [ $? -ne 0 ] && return 1 + + return 0 +} + +function start_mount_nfs { + $CLI volume start $V0 + [ $? -ne 0 ] && return 1 + + sleep 3 + mount_nfs $H0:/$V0 $N0 + [ $? -ne 0 ] && return 1 + + create_files $FILE_COUNT $N0/$1 + [ $? -ne 0 ] && return 1 + + return 0 +} + +cleanup + +TEST glusterd +TEST pidof glusterd + +# Test 1-2 Create repliacted volume + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 \ + $H0:$B0/${V0}2 $H0:$B0/${V0}3 $H0:$B0/${V0}4 $H0:$B0/${V0}5 +TEST $CLI volume set $V0 nfs.disable false + +# ------- test 1: AFR, fuse + remove bricks + +TEST start_mount_fuse test1 +EXPECT_WITHIN $FILE_COUNT_TIME $FILE_COUNT get_file_count $M0/test1 +TEST $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}{2,3} start +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0" "$H0:$B0/${V0}2 $H0:$B0/${V0}3" +TEST $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}{2,3} commit +EXPECT_WITHIN $FILE_COUNT_TIME $FILE_COUNT get_file_count $M0/test1 +reset $M0 + +# ------- test 2: AFR, nfs + remove bricks + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 \ + $H0:$B0/${V0}2 $H0:$B0/${V0}3 $H0:$B0/${V0}4 $H0:$B0/${V0}5 +TEST $CLI volume set $V0 nfs.disable false + +TEST start_mount_nfs test2 +EXPECT_WITHIN $FILE_COUNT_TIME $FILE_COUNT get_file_count $N0/test2 +TEST $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}2 $H0:$B0/${V0}3 start +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0" "$H0:$B0/${V0}2 $H0:$B0/${V0}3" +TEST $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}{2,3} commit +EXPECT_WITHIN $FILE_COUNT_TIME $FILE_COUNT get_file_count $N0/test2 +reset $N0 + +cleanup diff --git a/tests/bugs/distribute/bug-1193636.c b/tests/bugs/distribute/bug-1193636.c new file mode 100644 index 00000000000..ea3f79a4e06 --- /dev/null +++ b/tests/bugs/distribute/bug-1193636.c @@ -0,0 +1,68 @@ +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/xattr.h> +#include <fcntl.h> +#include <string.h> + +#define MY_XATTR_NAME "user.ftest" +#define MY_XATTR_VAL "ftestval" + +void +usage(void) +{ + printf("Usage : bug-1193636 <filename> <xattr_name> <op>\n"); + printf(" op : 0 - set, 1 - remove\n"); +} + +int +main(int argc, char **argv) +{ + int fd; + int err = 0; + char *xattr_name = NULL; + int op = 0; + + if (argc != 4) { + usage(); + exit(1); + } + + op = atoi(argv[3]); + + if ((op != 0) && (op != 1)) { + printf("Invalid operation specified.\n"); + usage(); + exit(1); + } + + xattr_name = argv[2]; + + fd = open(argv[1], O_RDWR); + if (fd == -1) { + printf("Failed to open file %s\n", argv[1]); + exit(1); + } + + if (!op) { + err = fsetxattr(fd, xattr_name, MY_XATTR_VAL, strlen(MY_XATTR_VAL) + 1, + XATTR_CREATE); + + if (err) { + printf("Failed to set xattr %s: %m\n", xattr_name); + exit(1); + } + + } else { + err = fremovexattr(fd, xattr_name); + + if (err) { + printf("Failed to remove xattr %s: %m\n", xattr_name); + exit(1); + } + } + + close(fd); + + return 0; +} diff --git a/tests/bugs/distribute/bug-1193636.t b/tests/bugs/distribute/bug-1193636.t new file mode 100644 index 00000000000..b377910336e --- /dev/null +++ b/tests/bugs/distribute/bug-1193636.t @@ -0,0 +1,74 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + + +checksticky () { + i=0; + while [ ! -k $1 ]; do + sleep 1 + i=$((i+1)); + if [[ $i == 10 ]]; then + return $i + fi + echo "Waiting... $i" + done + echo "done ...got out @ $i" + return 0 +} + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3}; +TEST $CLI volume start $V0 + +# Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +TEST mkdir $M0/dir1 + +# Create a large file (1GB), so that rebalance takes time +dd if=/dev/zero of=$M0/dir1/FILE2 bs=64k count=10240 + +# Rename the file to create a linkto, for rebalance to +# act on the file +TEST mv $M0/dir1/FILE2 $M0/dir1/FILE1 + +brick_loc=$(get_backend_paths $M0/dir1/FILE1) + +build_tester $(dirname $0)/bug-1193636.c + +TEST $CLI volume rebalance $V0 start force + +TEST checksticky $brick_loc + +TEST setfattr -n "user.test1" -v "test1" $M0/dir1/FILE1 +TEST setfattr -n "user.test2" -v "test1" $M0/dir1/FILE1 +TEST setfattr -n "user.test3" -v "test1" $M0/dir1/FILE1 + +TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fsetx 0 +TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fremx 0 + +TEST getfattr -n "user.fremx" $M0/dir1/FILE1 +TEST setfattr -x "user.test2" $M0/dir1/FILE1 + + +TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fremx 1 + +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0 + +TEST getfattr -n "user.fsetx" $M0/dir1/FILE1 +TEST getfattr -n "user.test1" $M0/dir1/FILE1 +TEST ! getfattr -n "user.test2" $M0/dir1/FILE1 +TEST ! getfattr -n "user.fremx" $M0/dir1/FILE1 +TEST getfattr -n "user.test3" $M0/dir1/FILE1 + + +cleanup; diff --git a/tests/bugs/distribute/bug-1204140.t b/tests/bugs/distribute/bug-1204140.t new file mode 100755 index 00000000000..050c069ea30 --- /dev/null +++ b/tests/bugs/distribute/bug-1204140.t @@ -0,0 +1,22 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../dht.rc + +cleanup; + + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 +TEST $CLI volume start $V0 + +## Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0; +TEST touch $M0/new.txt; +TEST getfattr -n "glusterfs.get_real_filename:NEW.txt" $M0; +TEST ! getfattr -n "glusterfs.get_realfilename:NEXT.txt" $M0; + + +cleanup; diff --git a/tests/bugs/distribute/bug-1247563.t b/tests/bugs/distribute/bug-1247563.t new file mode 100644 index 00000000000..a2fc722896f --- /dev/null +++ b/tests/bugs/distribute/bug-1247563.t @@ -0,0 +1,62 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +is_sticky_set () { + echo $1 + if [ -k $1 ]; + then + echo "yes" + else + echo "no" + fi +} + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3}; +TEST $CLI volume start $V0 + +# Mount FUSE +TEST glusterfs --acl -s $H0 --volfile-id $V0 $M0 + +TEST mkdir $M0/dir1 + +echo "Testing pacls on rebalance" > $M0/dir1/FILE1 + +FPATH1=`find $B0/ -name FILE1` + +# Rename the file to create a linkto, for rebalance to +# act on the file + +TEST mv $M0/dir1/FILE1 $M0/dir1/FILE2 +FPATH2=`find $B0/ -perm 1000 -name FILE2` + +setfacl -m user:root:rwx $M0/dir1/FILE2 + +# Run rebalance without the force option to skip +# the file migration +TEST $CLI volume rebalance $V0 start + +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0 + +#Check that the file has been skipped,i.e., the linkto still exists +EXPECT "yes" is_sticky_set $FPATH2 + + +#The linkto file should not have any posix acls set +COUNT=`getfacl $FPATH2 |grep -c "user:root:rwx"` +EXPECT "0" echo $COUNT + +cleanup; + + +#G_TESTDEF_TEST_STATUS_CENTOS6=BAD_TEST,BUG=000000 +#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000 diff --git a/tests/bugs/distribute/bug-1368012.t b/tests/bugs/distribute/bug-1368012.t new file mode 100644 index 00000000000..0b626353aab --- /dev/null +++ b/tests/bugs/distribute/bug-1368012.t @@ -0,0 +1,51 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +function get_permission { + stat -c "%A" $1 +} + +## Start glusterd +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +## Lets create volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; + +## Verify volume is created +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +## Start volume and verify +TEST $CLI volume start $V0; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" online_brick_count +TEST $CLI volume set $V0 performance.stat-prefetch off +EXPECT 'Started' volinfo_field $V0 'Status'; +TEST glusterfs -s $H0 --volfile-id=$V0 $M0 + +##Test case: Add-brick +#------------------------------------------------------------ +#change permission of both root +TEST chmod 444 $M0 + +#store permission for comparision +TEST permission_root=`stat -c "%A" $M0` +TEST echo $permission_root +#Add-brick +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" online_brick_count + +#Allow one lookup to happen +TEST ls $M0 +#Generate another lookup +echo 3 > /proc/sys/vm/drop_caches +TEST ls $M0 +#check root permission +EXPECT_WITHIN "5" $permission_root get_permission $M0 +#check permission on the new-brick +EXPECT $permission_root get_permission $B0/${V0}3 +cleanup diff --git a/tests/bugs/distribute/bug-1389697.t b/tests/bugs/distribute/bug-1389697.t new file mode 100644 index 00000000000..0d428b8d9d2 --- /dev/null +++ b/tests/bugs/distribute/bug-1389697.t @@ -0,0 +1,42 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../cluster.rc + + +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/b1 $H1:$B1/b2 $H2:$B2/b3 +TEST $CLI_1 volume start $V0 + +#Start a fix-layout +TEST $CLI_1 volume rebalance $V0 fix-layout start + +#volume rebalance status should work +TEST $CLI_1 volume rebalance $V0 status +$CLI_1 volume rebalance $V0 status + +val=$($CLI_1 volume rebalance $V0 status |grep "fix-layout" 2>&1) +val=$? +TEST [ $val -eq 0 ]; + +#Start a remove brick for the brick on H2 +TEST $CLI_1 volume remove-brick $V0 $H2:$B2/b3 start +TEST $CLI_1 volume remove-brick $V0 $H2:$B2/b3 status + +#Check remove brick status from H1 +$CLI_1 volume remove-brick $V0 $H2:$B2/b3 status |grep "fix-layout" 2>&1 +val=$? +TEST [ $val -eq 1 ]; + +$CLI_1 volume remove-brick $V0 $H2:$B2/b3 status +$CLI_2 volume remove-brick $V0 $H2:$B2/b3 status + + +TEST $CLI_1 volume remove-brick $V0 $H2:$B2/b3 stop + +cleanup diff --git a/tests/bugs/distribute/bug-1543279.t b/tests/bugs/distribute/bug-1543279.t new file mode 100644 index 00000000000..47b8b4a4a95 --- /dev/null +++ b/tests/bugs/distribute/bug-1543279.t @@ -0,0 +1,67 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../dht.rc + +TESTS_EXPECTED_IN_LOOP=44 +SCRIPT_TIMEOUT=600 + +rename_files() { + MOUNT=$1 + ITERATIONS=$2 + for i in $(seq 1 $ITERATIONS); do uuid="`uuidgen`"; echo "some data" > $MOUNT/test$uuid; mv $MOUNT/test$uuid $MOUNT/test -f || return $?; done +} + +run_test_for_volume() { + VOLUME=$1 + ITERATIONS=$2 + TEST_IN_LOOP $CLI volume start $VOLUME + + TEST_IN_LOOP glusterfs -s $H0 --volfile-id $VOLUME $M0 + TEST_IN_LOOP glusterfs -s $H0 --volfile-id $VOLUME $M1 + TEST_IN_LOOP glusterfs -s $H0 --volfile-id $VOLUME $M2 + TEST_IN_LOOP glusterfs -s $H0 --volfile-id $VOLUME $M3 + + rename_files $M0 $ITERATIONS & + M0_RENAME_PID=$! + + rename_files $M1 $ITERATIONS & + M1_RENAME_PID=$! + + rename_files $M2 $ITERATIONS & + M2_RENAME_PID=$! + + rename_files $M3 $ITERATIONS & + M3_RENAME_PID=$! + + TEST_IN_LOOP wait $M0_RENAME_PID + TEST_IN_LOOP wait $M1_RENAME_PID + TEST_IN_LOOP wait $M2_RENAME_PID + TEST_IN_LOOP wait $M3_RENAME_PID + + TEST_IN_LOOP $CLI volume stop $VOLUME + TEST_IN_LOOP $CLI volume delete $VOLUME + umount $M0 $M1 $M2 $M3 +} + +cleanup + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}{0..8} force +run_test_for_volume $V0 200 + +TEST $CLI volume create $V0 replica 3 arbiter 1 $H0:$B0/${V0}{0..8} force +run_test_for_volume $V0 200 + +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0..8} force +run_test_for_volume $V0 200 + +TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5} force +run_test_for_volume $V0 200 + +cleanup +#G_TESTDEF_TEST_STATUS_CENTOS6=BAD_TEST,BUG=000000 +#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000 diff --git a/tests/bugs/distribute/bug-1600379.t b/tests/bugs/distribute/bug-1600379.t new file mode 100644 index 00000000000..8d2f6154100 --- /dev/null +++ b/tests/bugs/distribute/bug-1600379.t @@ -0,0 +1,54 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +# Initialize +#------------------------------------------------------------ +cleanup; + +# Start glusterd +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +# Create a volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2} + +# Verify volume creation +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +# Start volume and verify successful start +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 --entry-timeout=0 $M0; +#------------------------------------------------------------ + +# Test case - Remove xattr from killed brick on lookup +#------------------------------------------------------------ +# Create a dir and set custom xattr +TEST mkdir $M0/testdir +TEST setfattr -n user.attr -v val $M0/testdir +xattr_val=`getfattr -d $B0/${V0}2/testdir | awk '{print $1}'`; +TEST ${xattr_val}='user.attr="val"'; + +# Kill 2nd brick process +TEST kill_brick $V0 $H0 $B0/${V0}2 +EXPECT_WITHIN ${PROCESS_UP_TIMEOUT} "1" online_brick_count + +# Remove custom xattr +TEST setfattr -x user.attr $M0/testdir + +# Bring up the killed brick process +TEST $CLI volume start $V0 force + +# Perform lookup +sleep 5 +TEST ls $M0/testdir + +# Check brick xattrs +xattr_val_2=`getfattr -d $B0/${V0}2/testdir`; +TEST [ ${xattr_val_2} = ''] ; + +cleanup; diff --git a/tests/bugs/distribute/bug-1667804.t b/tests/bugs/distribute/bug-1667804.t new file mode 100644 index 00000000000..3f7c43111d7 --- /dev/null +++ b/tests/bugs/distribute/bug-1667804.t @@ -0,0 +1,63 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../dht.rc + +function confirm_all_linkto_files () +{ + inpath=$1 + for infile in $inpath/* + do + echo $infile + ret1=$(is_dht_linkfile $infile) + if [ "$ret1" -eq 0 ]; then + echo "$infile is not a linkto file" + echo 0 + return + fi + done + echo 1 +} + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2}; +TEST $CLI volume start $V0 + +# Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +#Create files and rename them in order to create linkto files +TEST mkdir -p $M0/dir0/dir1 +TEST touch $M0/dir0/dir1/file-{1..50} + +for i in {1..50}; do + mv $M0/dir0/dir1/file-$i $M0/dir0/dir1/nfile-$i; +done + +#Remove the second brick to force the creation of linkto files +#on the removed brick + +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 start +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0 $H0:$B0/${V0}2" +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 stop + +EXPECT "1" confirm_all_linkto_files $B0/${V0}2/dir0/dir1 + +#Modify the xattrs of the linkto files on the removed brick to point to itself. + +target=$(cat $M0/.meta/graphs/active/$V0-dht/subvolumes/1/name) + +setfattr -n trusted.glusterfs.dht.linkto -v "$target\0" $B0/${V0}2/dir0/dir1/nfile* + + +TEST rm -rf $M0/dir0 + +cleanup; diff --git a/tests/bugs/distribute/bug-1786679.t b/tests/bugs/distribute/bug-1786679.t new file mode 100755 index 00000000000..219ce51c8a9 --- /dev/null +++ b/tests/bugs/distribute/bug-1786679.t @@ -0,0 +1,69 @@ +#!/bin/bash + +SCRIPT_TIMEOUT=250 + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../dht.rc + + +# create 2 subvols +# create a dir +# create a file +# change layout +# remove the file +# execute create from a different mount +# Without the patch, the file will be present on both of the bricks + +cleanup + +function get_layout () { + +layout=`getfattr -n trusted.glusterfs.dht -e hex $1 2>&1 | grep dht | gawk -F"=" '{print $2}'` + +echo $layout + +} + +function set_layout() +{ + setfattr -n "trusted.glusterfs.dht" -v $1 $2 +} + +TEST glusterd +TEST pidof glusterd + +BRICK1=$B0/${V0}-0 +BRICK2=$B0/${V0}-1 + +TEST $CLI volume create $V0 $H0:$BRICK1 $H0:$BRICK2 +TEST $CLI volume start $V0 + +# Mount FUSE and create symlink +TEST glusterfs -s $H0 --volfile-id $V0 $M0 +TEST mkdir $M0/dir +TEST touch $M0/dir/file +TEST ! stat "$BRICK1/dir/file" +TEST stat "$BRICK2/dir/file" + +layout1="$(get_layout "$BRICK1/dir")" +layout2="$(get_layout "$BRICK2/dir")" + +TEST set_layout $layout1 "$BRICK2/dir" +TEST set_layout $layout2 "$BRICK1/dir" + +TEST rm $M0/dir/file -f +TEST gluster v set $V0 client-log-level DEBUG + +#Without the patch in place, this client will create the file in $BRICK2 +#which will lead to two files being on both the bricks when a new client +#create the file with the same name +TEST touch $M0/dir/file + +TEST glusterfs -s $H0 --volfile-id $V0 $M1 +TEST touch $M1/dir/file + +TEST stat "$BRICK1/dir/file" +TEST ! stat "$BRICK2/dir/file" + +cleanup diff --git a/tests/bugs/distribute/bug-853258.t b/tests/bugs/distribute/bug-853258.t new file mode 100755 index 00000000000..6817d9e2cd3 --- /dev/null +++ b/tests/bugs/distribute/bug-853258.t @@ -0,0 +1,47 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +mkdir -p $H0:$B0/${V0}0 +mkdir -p $H0:$B0/${V0}1 +mkdir -p $H0:$B0/${V0}2 +mkdir -p $H0:$B0/${V0}3 + +# Create and start a volume. +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 +TEST $CLI volume start $V0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status'; +TEST $CLI volume set $V0 cluster.weighted-rebalance off + +# Force assignment of initial ranges. +TEST $CLI volume rebalance $V0 fix-layout start +EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" fix-layout_status_field $V0 + +# Get the original values. +xattrs="" +for i in $(seq 0 2); do + xattrs="$xattrs $(dht_get_layout $B0/${V0}$i)" +done + +# Expand the volume and force assignment of new ranges. +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "4" online_brick_count +# Force assignment of initial ranges. +TEST $CLI volume rebalance $V0 fix-layout start +EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout completed" fix-layout_status_field $V0 + +for i in $(seq 0 3); do + xattrs="$xattrs $(dht_get_layout $B0/${V0}$i)" +done + +overlap=$( $PYTHON $(dirname $0)/overlap.py $xattrs) +# 2863311531 = 0xaaaaaaab = 2/3 overlap +TEST [ "$overlap" -ge 2863311531 ] + +cleanup diff --git a/tests/bugs/distribute/bug-860663.c b/tests/bugs/distribute/bug-860663.c new file mode 100644 index 00000000000..ca0c31ffe8f --- /dev/null +++ b/tests/bugs/distribute/bug-860663.c @@ -0,0 +1,41 @@ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <string.h> +#include <err.h> +#include <sys/param.h> + +int main(argc, argv) int argc; +char **argv; +{ + char *basepath; + char path[MAXPATHLEN + 1]; + unsigned int count; + int i, fd; + + if (argc != 3) + errx(1, "usage: %s path count", argv[0]); + + basepath = argv[1]; + count = atoi(argv[2]); + + if (count > 999999) + errx(1, "count too big"); + + if (strlen(basepath) > MAXPATHLEN - 6) + errx(1, "path too long"); + + for (i = 0; i < count; i++) { + (void)sprintf(path, "%s%06d", basepath, i); + + fd = open(path, O_CREAT | O_RDWR, 0644); + if (fd == -1) + err(1, "create %s failed", path); + + if (close(fd) != 0) + warn("close %s failed", path); + } + + return 0; +} diff --git a/tests/bugs/distribute/bug-860663.t b/tests/bugs/distribute/bug-860663.t new file mode 100644 index 00000000000..59b8223ef3f --- /dev/null +++ b/tests/bugs/distribute/bug-860663.t @@ -0,0 +1,56 @@ +#!/bin/bash + +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../include.rc + +cleanup; + +function file_count() +{ + val=1 + + if [ "$1" == "$2" ] + then + val=0 + fi + echo $val +} + +BRICK_COUNT=3 + +build_tester $(dirname $0)/bug-860663.c + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 +TEST $CLI volume start $V0 + +## Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST $(dirname $0)/bug-860663 $M0/files 1000 + +ORIG_FILE_COUNT=`ls -l $M0 | wc -l`; +TEST [ $ORIG_FILE_COUNT -ge 1000 ] + +# Kill a brick process +kill_brick $V0 $H0 $B0/${V0}1 + +TEST $CLI volume rebalance $V0 fix-layout start + +EXPECT_WITHIN $REBALANCE_TIMEOUT "fix-layout failed" fix-layout_status_field $V0; + +TEST $CLI volume start $V0 force +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/${V0}1 + +# Unmount and remount to make sure we're doing fresh lookups. +TEST umount $M0 +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +NEW_FILE_COUNT=`ls -l $M0 | wc -l`; + +EXPECT "0" file_count $ORIG_FILE_COUNT $NEW_FILE_COUNT + +rm -f $(dirname $0)/bug-860663 +cleanup; diff --git a/tests/bugs/distribute/bug-862967.t b/tests/bugs/distribute/bug-862967.t new file mode 100644 index 00000000000..2fb0848bd7c --- /dev/null +++ b/tests/bugs/distribute/bug-862967.t @@ -0,0 +1,59 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +function uid_gid_compare() +{ + val=1 + + if [ "$1" == "$3" ] + then + if [ "$2" == "$4" ] + then + val=0 + fi + fi + echo "$val" +} + +BRICK_COUNT=3 + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 +TEST $CLI volume set $V0 stat-prefetch off +TEST $CLI volume start $V0 + +## Mount FUSE +TEST glusterfs --attribute-timeout=0 --entry-timeout=0 --gid-timeout=-1 -s $H0 --volfile-id $V0 $M0; + +# change dir permissions +mkdir $M0/dir; +chown 1:1 $M0/dir; + +# Kill a brick process + +kill_brick $V0 $H0 $B0/${V0}2 +# change dir ownership +NEW_UID=36; +NEW_GID=36; +chown $NEW_UID:$NEW_GID $M0/dir; + +# bring the brick back up +TEST $CLI volume start $V0 force + +sleep 10; + +ls -l $M0/dir; + +# check if uid/gid is healed on backend brick which was taken down +BACKEND_UID=`stat -c %u $B0/${V0}2/dir`; +BACKEND_GID=`stat -c %g $B0/${V0}2/dir`; + +EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID + +cleanup; diff --git a/tests/bugs/distribute/bug-882278.t b/tests/bugs/distribute/bug-882278.t new file mode 100755 index 00000000000..8cb51474720 --- /dev/null +++ b/tests/bugs/distribute/bug-882278.t @@ -0,0 +1,73 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +cleanup + +# Is there a good reason to require --fqdn elsewhere? It's worse than useless +# here. +H0=$(hostname -s) + +function recreate { + # The rm is necessary so we don't get fooled by leftovers from old runs. + rm -rf $1 && mkdir -p $1 +} + +function count_lines { + grep "$1" $2/* | wc -l +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +## Start and create a volume +TEST recreate ${B0}/${V0}-0 +TEST recreate ${B0}/${V0}-1 +TEST $CLI volume create $V0 $H0:$B0/${V0}-{0,1} +TEST $CLI volume set $V0 cluster.nufa on + +function volinfo_field() +{ + local vol=$1; + local field=$2; + + $CLI volume info $vol | grep "^$field: " | sed 's/.*: //'; +} + + +## Verify volume is created +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +## Start volume and verify +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount native +special_option="--xlator-option ${V0}-dht.local-volume-name=${V0}-client-1" +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $special_option $M0 + +## Create a bunch of test files. +for i in $(seq 0 99); do + echo hello > $(printf $M0/file%02d $i) +done + +## Make sure the files went to the right place. There might be link files in +## the other brick, but they won't have any contents. +EXPECT "0" count_lines hello ${B0}/${V0}-0 +EXPECT "100" count_lines hello ${B0}/${V0}-1 + +if [ "$EXIT_EARLY" = "1" ]; then + exit 0; +fi + +## Finish up +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST $CLI volume stop $V0; +EXPECT 'Stopped' volinfo_field $V0 'Status'; + +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/distribute/bug-884455.t b/tests/bugs/distribute/bug-884455.t new file mode 100755 index 00000000000..59413cd5408 --- /dev/null +++ b/tests/bugs/distribute/bug-884455.t @@ -0,0 +1,84 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../dht.rc + +cleanup; + +function layout_compare() +{ + res=0 + + if [ "$1" == "$2" ] + then + res=1 + fi + if [ "$1" == "$3" ] + then + res=1 + fi + if [ "$2" == "$3" ] + then + res=1 + fi + + echo $res +} + +function get_layout() +{ + layout1=`getfattr -n trusted.glusterfs.dht -e hex $1 2>&1|grep dht |cut -d = -f2` + layout2=`getfattr -n trusted.glusterfs.dht -e hex $2 2>&1|grep dht |cut -d = -f2` + layout3=`getfattr -n trusted.glusterfs.dht -e hex $3 2>&1|grep dht |cut -d = -f2` + + ret=$(layout_compare $layout1 $layout2 $layout3) + + if [ $ret -ne 0 ] + then + echo 1 + else + echo 0 + fi + +} + +BRICK_COUNT=3 + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +## set subvols-per-dir option +TEST $CLI volume set $V0 subvols-per-directory 2 +TEST $CLI volume start $V0 + +## Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/dir{1..10} 2>/dev/null; + +## Add-brick n run rebalance to force re-write of layout +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}2 +sleep 5; + +## trigger dir self heal on client +TEST ls -l $M0 2>/dev/null; + +TEST $CLI volume rebalance $V0 start force + +EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed + +## check for layout overlaps. +EXPECT "0" get_layout $B0/${V0}0 $B0/${V0}1 $B0/${V0}2 +EXPECT "0" get_layout $B0/${V0}0/dir1 $B0/${V0}1/dir1 $B0/${V0}2/dir1 +EXPECT "0" get_layout $B0/${V0}0/dir2 $B0/${V0}1/dir2 $B0/${V0}2/dir2 +EXPECT "0" get_layout $B0/${V0}0/dir3 $B0/${V0}1/dir3 $B0/${V0}2/dir3 +EXPECT "0" get_layout $B0/${V0}0/dir4 $B0/${V0}1/dir4 $B0/${V0}2/dir4 +EXPECT "0" get_layout $B0/${V0}0/dir5 $B0/${V0}1/dir5 $B0/${V0}2/dir5 +EXPECT "0" get_layout $B0/${V0}0/dir6 $B0/${V0}1/dir6 $B0/${V0}2/dir6 +EXPECT "0" get_layout $B0/${V0}0/dir7 $B0/${V0}1/dir7 $B0/${V0}2/dir7 +EXPECT "0" get_layout $B0/${V0}0/dir8 $B0/${V0}1/dir8 $B0/${V0}2/dir8 +EXPECT "0" get_layout $B0/${V0}0/dir9 $B0/${V0}1/dir9 $B0/${V0}2/dir9 +EXPECT "0" get_layout $B0/${V0}0/dir10 $B0/${V0}1/dir10 $B0/${V0}2/dir10 + +cleanup; diff --git a/tests/bugs/distribute/bug-884597.t b/tests/bugs/distribute/bug-884597.t new file mode 100755 index 00000000000..d6a2c65f370 --- /dev/null +++ b/tests/bugs/distribute/bug-884597.t @@ -0,0 +1,173 @@ +#!/bin/bash +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../dht.rc +. $(dirname $0)/../../volume.rc + +cleanup; +BRICK_COUNT=3 +function uid_gid_compare() +{ + val=1 + + if [ "$1" == "$3" ] + then + if [ "$2" == "$4" ] + then + val=0 + fi + fi + echo "$val" +} + + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 +TEST $CLI volume start $V0 + +## Mount FUSE +TEST glusterfs --attribute-timeout=0 --entry-timeout=0 -s $H0 --volfile-id $V0 $M0; + +i=1 +NEW_UID=36 +NEW_GID=36 + +TEST touch $M0/$i + +chown $NEW_UID:$NEW_GID $M0/$i +## rename till file gets a linkfile + +has_link=0 +while [ $i -lt 100 ] +do + mv $M0/$i $M0/$(( $i+1 )) + if [ $? -ne 0 ] + then + break + fi + let i++ + file_has_linkfile $i + has_link=$? + if [ $has_link -eq 2 ] + then + break; + fi +done + +TEST [ $has_link -eq 2 ] + +get_hashed_brick $i +cached=$? + +# check if uid/gid on linkfile is created with correct uid/gid +BACKEND_UID=`stat -c %u $B0/${V0}$cached/$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/$i`; + +EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID + +# remove linkfile from backend, and trigger a lookup heal. uid/gid should match +rm -rf $B0/${V0}$cached/$i + +# without a unmount, we are not able to trigger a lookup based heal + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 + +## Mount FUSE +TEST glusterfs --attribute-timeout=0 --entry-timeout=0 -s $H0 --volfile-id $V0 $M0; + +lookup=`ls -l $M0/$i 2>/dev/null` + +# check if uid/gid on linkfile is created with correct uid/gid +BACKEND_UID=`stat -c %u $B0/${V0}$cached/$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/$i`; + +EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID +# create hardlinks. Make sure a linkfile gets created + +i=1 +NEW_UID=36 +NEW_GID=36 + +TEST touch $M0/file +chown $NEW_UID:$NEW_GID $M0/file; + +## ln till file gets a linkfile + +has_link=0 +while [ $i -lt 100 ] +do + ln $M0/file $M0/link$i + if [ $? -ne 0 ] + then + break + fi + file_has_linkfile link$i + has_link=$? + if [ $has_link -eq 2 ] + then + break; + fi + let i++ +done + +TEST [ $has_link -eq 2 ] + +get_hashed_brick link$i +cached=$? + +# check if uid/gid on linkfile is created with correct uid/gid +BACKEND_UID=`stat -c %u $B0/${V0}$cached/link$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/link$i`; + +EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID + +## UID/GID creation as different user +i=1 +NEW_UID=36 +NEW_GID=36 + +TEST touch $M0/user_file1 +TEST chown $NEW_UID:$NEW_GID $M0/user_file1; + +## Give permission on volume, so that different users can perform rename + +TEST chmod 0777 $M0 + +## Add a user known as ABC and perform renames +TEST `useradd -M ABC 2>/dev/null` + +TEST cd $M0 +## rename as different user till file gets a linkfile + +has_link=0 +while [ $i -lt 100 ] +do + su -m ABC -c "mv $M0/user_file$i $M0/user_file$(( $i+1 ))" + if [ $? -ne 0 ] + then + break + fi + let i++ + file_has_linkfile user_file$i + has_link=$? + if [ $has_link -eq 2 ] + then + break; + fi +done + +TEST [ $has_link -eq 2 ] + +## del user ABC +TEST userdel ABC + +get_hashed_brick user_file$i +cached=$? + +# check if uid/gid on linkfile is created with correct uid/gid +BACKEND_UID=`stat -c %u $B0/${V0}$cached/user_file$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/user_file$i`; + +EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID +cleanup; diff --git a/tests/bugs/distribute/bug-907072.t b/tests/bugs/distribute/bug-907072.t new file mode 100755 index 00000000000..a4d98831380 --- /dev/null +++ b/tests/bugs/distribute/bug-907072.t @@ -0,0 +1,49 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../fileio.rc +. $(dirname $0)/../../dht.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd; +TEST pidof glusterd; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1,2,3}; +TEST $CLI volume start $V0; + +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/test; + +# Extract the layout sans the commit hash +OLD_LAYOUT0=`get_layout $B0/${V0}0/test | cut -c11-34`; +OLD_LAYOUT1=`get_layout $B0/${V0}1/test | cut -c11-34`; +OLD_LAYOUT2=`get_layout $B0/${V0}2/test | cut -c11-34`; +OLD_LAYOUT3=`get_layout $B0/${V0}3/test | cut -c11-34`; + +TEST killall glusterfsd; + +# Delete directory on one brick +TEST rm -rf $B0/${V}1/test; + +# And only layout xattr on another brick +TEST setfattr -x trusted.glusterfs.dht $B0/${V0}2/test; + +TEST $CLI volume start $V0 force; + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST glusterfs -s $H0 --volfile-id $V0 $M0; +TEST stat $M0/test; + +# Extract the layout sans the commit hash +NEW_LAYOUT0=`get_layout $B0/${V0}0/test | cut -c11-34`; +NEW_LAYOUT1=`get_layout $B0/${V0}1/test | cut -c11-34`; +NEW_LAYOUT2=`get_layout $B0/${V0}2/test | cut -c11-34`; +NEW_LAYOUT3=`get_layout $B0/${V0}3/test | cut -c11-34`; + +EXPECT $OLD_LAYOUT0 echo $NEW_LAYOUT0; +EXPECT $OLD_LAYOUT1 echo $NEW_LAYOUT1; +EXPECT $OLD_LAYOUT2 echo $NEW_LAYOUT2; +EXPECT $OLD_LAYOUT3 echo $NEW_LAYOUT3; diff --git a/tests/bugs/distribute/bug-912564.t b/tests/bugs/distribute/bug-912564.t new file mode 100755 index 00000000000..d437728f83b --- /dev/null +++ b/tests/bugs/distribute/bug-912564.t @@ -0,0 +1,92 @@ +#!/bin/bash + +# Test that the rsync and "extra" regexes cause rename-in-place without +# creating linkfiles, when they're supposed to. Without the regex we'd have a +# 1/4 chance of each file being assigned to the right place, so with 16 files +# we have a 1/2^32 chance of getting the correct result by accident. + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +function count_linkfiles { + local i + local count=0 + for i in $(seq $2 $3); do + x=$(find $1$i -perm -1000 | wc -l) + # Divide by two because of the .glusterfs links. + count=$((count+x/2)) + done + echo $count +} + +# This function only exists to get around quoting difficulties in TEST. +function set_regex { + $CLI volume set $1 cluster.extra-hash-regex '^foo(.+)bar$' +} + +cleanup; + +TEST glusterd +TEST pidof glusterd + +mkdir -p $H0:$B0/${V0}0 +mkdir -p $H0:$B0/${V0}1 +mkdir -p $H0:$B0/${V0}2 +mkdir -p $H0:$B0/${V0}3 + +# Create and start a volume. +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 \ + $H0:$B0/${V0}2 $H0:$B0/${V0}3 +TEST $CLI volume start $V0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status'; + +# Mount it. +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 + +# Make sure the rsync regex works, by verifying that no linkfiles are +# created. +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf .%s.%d $fn $RANDOM) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -eq "0" ] + +# Make sure that linkfiles *are* created for normal files. +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf foo%sbar $fn) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -ne "0" ] + +# Make sure that setting an extra regex suppresses the linkfiles. +TEST set_regex $V0 +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf foo%sbar $fn) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -eq "0" ] + +# Re-test the rsync regex, to make sure the extra one didn't break it. +rm -f $M0/file* +for i in $(seq 0 15); do + fn=$(printf file%x $i) + tmp_fn=$(printf .%s.%d $fn $RANDOM) + echo testing > $M0/$tmp_fn + mv $M0/$tmp_fn $M0/$fn +done +lf=$(count_linkfiles $B0/$V0 0 3) +TEST [ "$lf" -eq "0" ] + +cleanup diff --git a/tests/bugs/distribute/bug-915554.t b/tests/bugs/distribute/bug-915554.t new file mode 100755 index 00000000000..1f59008c56f --- /dev/null +++ b/tests/bugs/distribute/bug-915554.t @@ -0,0 +1,76 @@ +#!/bin/bash +# +# Bug <915554> +# +# This test checks for a condition where a rebalance migrates a file and does +# not preserve the original file size. This can occur due to hole preservation +# logic in the file migration code. If a file size is aligned to a disk sector +# boundary (512b) and the tail portion of the file is zero-filled, the file +# may end up truncated to the end of the last data region in the file. +# +### + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../dht.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +BRICK_COUNT=3 +# create, start and mount a two brick DHT volume +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 +TEST $CLI volume start $V0 + +TEST glusterfs --attribute-timeout=0 --entry-timeout=0 --gid-timeout=-1 -s $H0 --volfile-id $V0 $M0; + +i=1 +# Write some data to a file and extend such that the file is sparse to a sector +# aligned boundary. +echo test > $M0/$i +TEST truncate -s 1M $M0/$i + +# cache the original size +SIZE1=`stat -c %s $M0/$i` + +# rename till file gets a linkfile + +while [ $i -ne 0 ] +do + test=`mv $M0/$i $M0/$(( $i+1 )) 2>/dev/null` + if [ $? -ne 0 ] + then + echo "rename failed" + break + fi + let i++ + file_has_linkfile $i + has_link=$? + if [ $has_link -eq 2 ] + then + break; + fi +done + +# start a rebalance (force option to overide checks) to trigger migration of +# file + +TEST $CLI volume rebalance $V0 start force + +# check if rebalance has completed for up to 15 secs + +EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed + +# validate the file size after the migration +SIZE2=`stat -c %s $M0/$i` + +TEST [ $SIZE1 -eq $SIZE2 ] + +TEST rm -f $M0/$i +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup; diff --git a/tests/bugs/distribute/bug-921408.t b/tests/bugs/distribute/bug-921408.t new file mode 100755 index 00000000000..559114bb85a --- /dev/null +++ b/tests/bugs/distribute/bug-921408.t @@ -0,0 +1,90 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../fileio.rc +. $(dirname $0)/../../dht.rc +. $(dirname $0)/../../volume.rc + +cleanup; +wait_check_status () +{ + n=0 + while [ $n -lt $1 ] + do + ret=$(rebalance_completed) + if [ $ret == "0" ] + then + return 0; + else + sleep 1 + n=`expr $n + 1`; + fi + done + return 1; +} + +addbr_rebal_till_layout_change() +{ + val=1 + l=$1 + i=1 + while [ $i -lt 5 ] + do + $CLI volume add-brick $V0 $H0:$B0/${V0}$l &>/dev/null + $CLI volume rebalance $V0 fix-layout start &>/dev/null + wait_check_status $REBALANCE_TIMEOUT + if [ $? -eq 1 ] + then + break + fi + NEW_LAYOUT=`get_layout $B0/${V0}0 | cut -c11-34` + if [ $OLD_LAYOUT == $NEW_LAYOUT ] + then + i=`expr $i + 1`; + l=`expr $l + 1`; + else + val=0 + break + fi + done + return $val +} +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 +TEST $CLI volume set $V0 subvols-per-directory 1 +TEST $CLI volume start $V0 + +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/test +TEST touch $M0/test/test + +fd=`fd_available` +TEST fd_open $fd "rw" $M0/test/test + +OLD_LAYOUT=`get_layout $B0/${V0}0 | cut -c11-34` + +addbr_rebal_till_layout_change 1 + +TEST [ $? -eq 0 ] + +for i in $(seq 1 1000) +do + ls -l $M0/ >/dev/null + ret=$? + if [ $ret != 0 ] + then + break + fi +done + +TEST [ $ret == 0 ]; +TEST fd_close $fd; + +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup diff --git a/tests/bugs/distribute/bug-924265.t b/tests/bugs/distribute/bug-924265.t new file mode 100755 index 00000000000..67c21de97cb --- /dev/null +++ b/tests/bugs/distribute/bug-924265.t @@ -0,0 +1,35 @@ +#!/bin/bash + +# Test that setting cluster.dht-xattr-name works, and that DHT consistently +# uses the specified name instead of the default. + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +# We only care about the exit code, so keep it quiet. +function silent_getfattr { + getfattr $* &> /dev/null +} + +cleanup + +TEST glusterd +TEST pidof glusterd + +mkdir -p $H0:$B0/${V0}0 + +# Create a volume and set the option. +TEST $CLI volume create $V0 $H0:$B0/${V0}0 +TEST $CLI volume set $V0 cluster.dht-xattr-name trusted.foo.bar + +# Start and mount the volume. +TEST $CLI volume start $V0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status'; +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 + +# Create a directory and make sure it has the right xattr. +mkdir $M0/test +TEST ! silent_getfattr -n trusted.glusterfs.dht $B0/${V0}0/test +TEST silent_getfattr -n trusted.foo.bar $B0/${V0}0/test + +cleanup diff --git a/tests/bugs/distribute/bug-961615.t b/tests/bugs/distribute/bug-961615.t new file mode 100644 index 00000000000..00938e8fa9b --- /dev/null +++ b/tests/bugs/distribute/bug-961615.t @@ -0,0 +1,34 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +#This test tests that an extra fd_unref does not happen in rebalance +#migration completion check code path in dht + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume set $V0 performance.quick-read off +TEST $CLI volume set $V0 performance.io-cache off +TEST $CLI volume set $V0 performance.write-behind off +TEST $CLI volume set $V0 performance.stat-prefetch off +TEST $CLI volume set $V0 performance.read-ahead off +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 +TEST touch $M0/1 +#This rename creates a link file for 10 in the other volume. +TEST mv $M0/1 $M0/10 +#Lets keep writing to the file which will trigger rebalance completion check +dd if=/dev/zero of=$M0/10 bs=1k & +bg_pid=$! +#Now rebalance force will migrate file '10' +TEST $CLI volume rebalance $V0 start force +EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0 +#If the bug exists mount would have crashed by now +TEST ls $M0 +kill -9 $bg_pid > /dev/null 2>&1 +wait > /dev/null 2>&1 +cleanup diff --git a/tests/bugs/distribute/bug-973073.t b/tests/bugs/distribute/bug-973073.t new file mode 100755 index 00000000000..cdb785abac0 --- /dev/null +++ b/tests/bugs/distribute/bug-973073.t @@ -0,0 +1,48 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../dht.rc + +## Steps followed are one described in bugzilla + +cleanup; + +function get_layout() +{ + layout1=`getfattr -n trusted.glusterfs.dht -e hex $1 2>&1` + + if [ $? -ne 0 ] + then + echo 1 + else + echo 0 + fi + +} + +BRICK_COUNT=3 + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 +TEST $CLI volume start $V0 + +## Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 start + +## remove-brick status == rebalance_status +EXPECT_WITHIN $REBALANCE_TIMEOUT "0" remove_brick_completed + +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 stop + +TEST $CLI volume rebalance $V0 fix-layout start + +EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed + +TEST mkdir $M0/dir 2>/dev/null; + +EXPECT "0" get_layout $B0/${V0}2/dir +cleanup; diff --git a/tests/bugs/distribute/issue-1327.t b/tests/bugs/distribute/issue-1327.t new file mode 100755 index 00000000000..acd8c8c6614 --- /dev/null +++ b/tests/bugs/distribute/issue-1327.t @@ -0,0 +1,33 @@ +#!/bin/bash + +SCRIPT_TIMEOUT=250 + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../dht.rc + +cleanup + +TEST glusterd +TEST pidof glusterd + +BRICK1=$B0/${V0}-0 +BRICK2=$B0/${V0}-1 + +TEST $CLI volume create $V0 $H0:$BRICK1 $H0:$BRICK2 +TEST $CLI volume start $V0 + +TEST glusterfs -s $H0 --volfile-id $V0 $M0 +TEST mkdir $M0/dir + +#remove dir from one of the brick +TEST rmdir $BRICK2/dir + +#safe cache timeout for lookup to be triggered +sleep 2 + +TEST ls $M0/dir + +TEST stat $BRICK2/dir + +cleanup diff --git a/tests/bugs/distribute/overlap.py b/tests/bugs/distribute/overlap.py new file mode 100755 index 00000000000..2813979787b --- /dev/null +++ b/tests/bugs/distribute/overlap.py @@ -0,0 +1,59 @@ + +from __future__ import print_function +import sys + +def calculate_one (ov, nv): + old_start = int(ov[18:26], 16) + old_end = int(ov[26:34], 16) + new_start = int(nv[18:26], 16) + new_end = int(nv[26:34], 16) + if (new_end < old_start) or (new_start > old_end): + #print '%s, %s -> ZERO' % (ov, nv) + return 0 + all_start = max(old_start, new_start) + all_end = min(old_end, new_end) + #print '%s, %s -> %08x' % (ov, nv, all_end - all_start + 1) + return all_end - all_start + 1 + +def calculate_all (values): + total = 0 + nv_index = len(values) // 2 + for old_val in values[:nv_index]: + new_val = values[nv_index] + nv_index += 1 + total += calculate_one(old_val, new_val) + return total + +""" +test1_vals = [ + '0x0000000000000000000000003fffffff', # first quarter + '0x0000000000000000400000007fffffff', # second quarter + '0x000000000000000080000000ffffffff', # second half + '0x00000000000000000000000055555554', # first third + '0x000000000000000055555555aaaaaaa9', # second third + '0x0000000000000000aaaaaaaaffffffff', # last third +] + +test2_vals = [ + '0x0000000000000000000000003fffffff', # first quarter + '0x0000000000000000400000007fffffff', # second quarter + '0x000000000000000080000000ffffffff', # second half + '0x00000000000000000000000055555554', # first third + # Next two are (incorrectly) swapped. + '0x0000000000000000aaaaaaaaffffffff', # last third + '0x000000000000000055555555aaaaaaa9', # second third +] + +print '%08x' % calculate_one(test1_vals[0], test1_vals[3]) +print '%08x' % calculate_one(test1_vals[1], test1_vals[4]) +print '%08x' % calculate_one(test1_vals[2], test1_vals[5]) +print '= %08x' % calculate_all(test1_vals) +print '%08x' % calculate_one(test2_vals[0], test2_vals[3]) +print '%08x' % calculate_one(test2_vals[1], test2_vals[4]) +print '%08x' % calculate_one(test2_vals[2], test2_vals[5]) +print '= %08x' % calculate_all(test2_vals) +""" + +if __name__ == '__main__': + # Return decimal so bash can reason about it. + print('%d' % calculate_all(sys.argv[1:])) |
