diff options
Diffstat (limited to 'tests')
113 files changed, 3730 insertions, 322 deletions
diff --git a/tests/README b/tests/README.md index 857230acb..2b5ed8dcd 100644 --- a/tests/README +++ b/tests/README.md @@ -1,26 +1,27 @@ -How to use test script framework. -================================= +Regression tests framework for GlusterFS +======================================== +## Prereq - Build and install the version of glusterfs with your changes. Make sure the installed version is accessible from $PATH. +## How-To - To mount glusterfs, NEVER use 'mount -t glusterfs', instead use 'glusterfs -s ' method. This is because with the patch build setup doesnot install the /sbin/mount.glusterfs necessary, where as the glusterfs binary will be accessible with $PATH, and will pick the right version. - - (optional) Set environment variables to specify location of export directories and mount points. Unless you have special requirements, the defaults should just work. The variables themselves can be found at the top of tests/include.rc. All of them can be overriden with environment variables. -- Execute run-tests.sh in the top level directory as root. +## Usage +- Execute `/usr/share/glusterfs/run-tests.sh` as root. -- If some test cases fail, you can execute the failed test case script - directly bypassing run-tests.sh. At this time it might be - useful to set the envrionment variable DEBUG=1 before running - the individual test script directly by hand. +- If some test cases fail, report to GlusterFS community at + `gluster-devel@nongnu.org`. -- BE WARNED THAT THE TEST CASES DELETE /var/lib/glusterd/* !!! +## Reminder +- BE WARNED THAT THE TEST CASES DELETE /var/lib/glusterd/* !!!
\ No newline at end of file diff --git a/tests/afr.rc b/tests/afr.rc new file mode 100644 index 000000000..60ea1b7f1 --- /dev/null +++ b/tests/afr.rc @@ -0,0 +1,15 @@ +#!/bin/bash + +#count the number of entries marked for self-heal +#in brick $1's index + +function count_sh_entries() +{ + val1=0 + for g in `ls $1/.glusterfs/indices/xattrop` + do + val1=$(( val1 + 1 )) + done + + echo $val1; +} diff --git a/tests/basic/bd.t b/tests/basic/bd.t index 3201b7460..eb6305414 100755 --- a/tests/basic/bd.t +++ b/tests/basic/bd.t @@ -2,9 +2,6 @@ . $(dirname $0)/../include.rc -cleanup; - - function execute() { cmd=$1 @@ -14,11 +11,10 @@ function execute() function bd_cleanup() { - execute vgremove -f ${VG} + execute vgremove -f ${V0} execute pvremove ${ld} execute losetup -d ${ld} execute rm ${BD_DISK} - execute $CLI volume delete ${V0} cleanup } @@ -31,9 +27,10 @@ function check() fi } -VG=__bd_vg SIZE=256 #in MB +bd_cleanup; + ## Configure environment needed for BD backend volumes ## Create a file with configured size and ## set it as a temporary loop device to create @@ -56,23 +53,28 @@ function configure() check losetup ${BD_DISK} execute pvcreate -f ${ld} check pvcreate ${ld} - execute vgcreate ${VG} ${ld} - check vgcreate ${VG} + execute vgcreate ${V0} ${ld} + check vgcreate ${V0} + execute lvcreate --thin ${V0}/pool --size 128M } function volinfo_field() { local vol=$1; local field=$2; - $CLI volume info $vol | grep "^$field: " | sed 's/.*: //'; } +function volume_type() +{ + getfattr -n volume.type $M0/. --only-values --absolute-names -e text +} + TEST glusterd TEST pidof glusterd configure -TEST $CLI volume create $V0 device vg ${H0}:/${VG} +TEST $CLI volume create $V0 ${H0}:/$B0/$V0?${V0} EXPECT "$V0" volinfo_field $V0 'Volume Name'; EXPECT 'Created' volinfo_field $V0 'Status'; @@ -80,38 +82,50 @@ EXPECT 'Created' volinfo_field $V0 'Status'; TEST $CLI volume start $V0; EXPECT 'Started' volinfo_field $V0 'Status' -TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 +EXPECT '1' volume_type -## Create file (LV) -TEST touch $M0/$VG/lv1 -TEST stat /dev/$VG/lv1 +## Create posix file +TEST touch $M0/posix -TEST rm $M0/$VG/lv1; -TEST ! stat $M0/$VG/lv1; +TEST touch $M0/lv +gfid=`getfattr -n glusterfs.gfid.string $M0/lv --only-values --absolute-names` +TEST setfattr -n user.glusterfs.bd -v "lv:4MB" $M0/lv +# Check if LV is created +TEST stat /dev/$V0/${gfid} -TEST touch $M0/$VG/lv1 -TEST truncate -s64M $M0/$VG/lv1 +## Create filesystem +sleep 1 +TEST mkfs.ext4 -qF $M0/lv +# Cloning +TEST touch $M0/lv_clone +gfid=`getfattr -n glusterfs.gfid.string $M0/lv_clone --only-values --absolute-names` +TEST setfattr -n clone -v ${gfid} $M0/lv +TEST stat /dev/$V0/${gfid} -TEST ln $M0/$VG/lv1 $M0/$VG/lv2 -TEST stat /dev/$VG/lv2 +sleep 1 +## Check mounting +TEST mount -o loop $M0/lv $M1 +umount $M1 -rm $M0/$VG/lv1 -rm $M0/$VG/lv2 +# Snapshot +TEST touch $M0/lv_sn +gfid=`getfattr -n glusterfs.gfid.string $M0/lv_sn --only-values --absolute-names` +TEST setfattr -n snapshot -v ${gfid} $M0/lv +TEST stat /dev/$V0/${gfid} -TEST $CLI bd create $V0:/$VG/lv1 4MB -TEST stat /dev/$VG/lv1 +# Merge +sleep 1 +TEST setfattr -n merge -v "$M0/lv_sn" $M0/lv_sn +TEST ! stat $M0/lv_sn +TEST ! stat /dev/$V0/${gfid} -TEST $CLI bd clone $V0:/$VG/lv1 lv2 -TEST stat /dev/$VG/lv2 -TEST $CLI bd delete $V0:/$VG/lv2 -TEST $CLI bd snapshot $V0:/$VG/lv1 lv2 1 -TEST stat /dev/$VG/lv2 -rm $M0/$VG/lv2 -rm $M0/$VG/lv1 +rm $M0/* -f TEST umount $M0 TEST $CLI volume stop ${V0} +EXPECT 'Stopped' volinfo_field $V0 'Status'; TEST $CLI volume delete ${V0} bd_cleanup diff --git a/tests/basic/cdc.t b/tests/basic/cdc.t new file mode 100755 index 000000000..4cd915aa9 --- /dev/null +++ b/tests/basic/cdc.t @@ -0,0 +1,135 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +## Create a volume with one brick +TEST $CLI volume create $V0 $H0:$B0/${V0}1; +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '1' brick_count $V0 + +## Turn off performance translators +## This is required for testing readv calls +TEST $CLI volume set $V0 performance.io-cache off +EXPECT 'off' volinfo_field $V0 'performance.io-cache' +TEST $CLI volume set $V0 performance.quick-read off +EXPECT 'off' volinfo_field $V0 'performance.quick-read' + +TEST $CLI volume set $V0 strict-write-ordering on +EXPECT 'on' volinfo_field $V0 'performance.strict-write-ordering' + +## Turn on cdc xlator by setting features.compress to on +TEST $CLI volume set $V0 compress on +EXPECT 'on' volinfo_field $V0 'features.compress' +EXPECT 'server' volinfo_field $V0 'compress.mode' + +## Make sure that user cannot change compress.mode +## This would break the cdc xlator if allowed! +TEST $CLI volume set $V0 compress.mode client +EXPECT 'server' volinfo_field $V0 'compress.mode' + +## Turn on compress.debug option +## This will dump compressed data onto disk as gzip file +## This is used to check if compression actually happened +TEST $CLI volume set $V0 compress.debug on +EXPECT 'on' volinfo_field $V0 'compress.debug' + +## Start the volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount FUSE with caching disabled +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; + +#################### +## Testing writev ## +#################### + +## Create a 1K file locally and find the md5sum +TEST dd if=/dev/zero of=/tmp/cdc-orig count=1 bs=1K 2>/dev/null +checksum[original-file]=`md5sum /tmp/cdc-orig | cut -d' ' -f1` + +## Copy the file to mountpoint and find its md5sum on brick +TEST dd if=/tmp/cdc-orig of=$M0/cdc-server count=1 bs=1K 2>/dev/null +checksum[brick-file]=`md5sum $B0/${V0}1/cdc-server | cut -d' ' -f1` + +## Uncompress the gzip dump file and find its md5sum +EXPECT '/tmp/cdcdump.gz: application/x-gzip; charset=binary' file -i /tmp/cdcdump.gz +TEST gunzip -f /tmp/cdcdump.gz +checksum[dump-file-writev]=`md5sum /tmp/cdcdump | cut -d' ' -f1` + +## Check if all 3 checksums are same +TEST test ${checksum[original-file]} = ${checksum[brick-file]} +TEST test ${checksum[brick-file]} = ${checksum[dump-file-writev]} + +## Cleanup files +TEST rm -f /tmp/cdcdump.gz + +################### +## Testing readv ## +################### + +## Copy file from mount point to client and find checksum +TEST dd if=$M0/cdc-server of=/tmp/cdc-client count=1 bs=1K 2>/dev/null +checksum[client-file]=`md5sum /tmp/cdc-client | cut -d' ' -f1` + +## Uncompress the gzip dump file and find its md5sum +EXPECT '/tmp/cdcdump.gz: application/x-gzip; charset=binary' file -i /tmp/cdcdump.gz +TEST gunzip -f /tmp/cdcdump.gz +checksum[dump-file-readv]=`md5sum /tmp/cdcdump | cut -d' ' -f1` + +## Check if all 3 checksums are same +TEST test ${checksum[brick-file]} = ${checksum[client-file]} +TEST test ${checksum[client-file]} = ${checksum[dump-file-readv]} + +## Cleanup files and unmount +TEST rm -f /tmp/cdc* $M0/cdc* +TEST umount $M0 + +## Stop the volume +TEST $CLI volume stop $V0; +EXPECT 'Stopped' volinfo_field $V0 'Status'; + +## Turn on compress.min-size and set it to 100 bytes +## Compression should not take place if file size +## is less than 100 bytes +TEST $CLI volume set $V0 compress.min-size 100 +EXPECT '100' volinfo_field $V0 'compress.min-size' + +## Start the volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount FUSE with caching disabled +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; + +## Create a file of size 99 bytes on mountpoint +## This is should not be compressed +TEST dd if=/dev/zero of=$M0/cdc-small count=1 bs=99 2>/dev/null +TEST ! test -e /tmp/cdcdump.gz + +## Cleanup files and unmount +TEST rm -f /tmp/cdc* $M0/cdc* +TEST umount $M0 + +## Reset the compress options +TEST $CLI volume reset $V0 compress.debug +TEST $CLI volume reset $V0 compress.min-size +TEST $CLI volume reset $V0 compress.mode +TEST $CLI volume reset $V0 features.compress + +## Stop the volume +TEST $CLI volume stop $V0; +EXPECT 'Stopped' volinfo_field $V0 'Status'; + +## Delete the volume +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/basic/file-snapshot.t b/tests/basic/file-snapshot.t new file mode 100755 index 000000000..36908192b --- /dev/null +++ b/tests/basic/file-snapshot.t @@ -0,0 +1,56 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/$V0; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +TEST $CLI volume set $V0 features.file-snapshot on; + +TEST $CLI volume set $V0 performance.quick-read off; +TEST $CLI volume set $V0 performance.io-cache off; +TEST glusterfs -s $H0 --volfile-id $V0 $M0 --attribute-timeout=0; + +TEST touch $M0/big-file; + +TEST setfattr -n trusted.glusterfs.block-format -v qcow2:10GB $M0/big-file; + +TEST ls -al $M0 # test readdirplus +TEST [ `stat -c '%s' $M0/big-file` = 10737418240 ] + +echo 'ABCDEFGHIJ' > $M0/data-file1 +TEST dd if=$M0/data-file1 of=$M0/big-file conv=notrunc; +TEST setfattr -n trusted.glusterfs.block-snapshot-create -v image1 $M0/big-file; + +echo '1234567890' > $M0/data-file2 +TEST dd if=$M0/data-file2 of=$M0/big-file conv=notrunc; +TEST setfattr -n trusted.glusterfs.block-snapshot-create -v image2 $M0/big-file; + +TEST setfattr -n trusted.glusterfs.block-snapshot-goto -v image1 $M0/big-file; +TEST dd if=$M0/big-file of=$M0/out-file1 bs=11 count=1; + +TEST setfattr -n trusted.glusterfs.block-snapshot-goto -v image2 $M0/big-file; +TEST dd if=$M0/big-file of=$M0/out-file2 bs=11 count=1; + +TEST cmp $M0/data-file1 $M0/out-file1; +TEST cmp $M0/data-file2 $M0/out-file2; + +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/basic/mgmt_v3-locks.t b/tests/basic/mgmt_v3-locks.t new file mode 100755 index 000000000..22ca27b9f --- /dev/null +++ b/tests/basic/mgmt_v3-locks.t @@ -0,0 +1,121 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../cluster.rc + +function check_peers { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} + +function volume_count { + local cli=$1; + if [ $cli -eq '1' ] ; then + $CLI_1 volume info | grep 'Volume Name' | wc -l; + else + $CLI_2 volume info | grep 'Volume Name' | wc -l; + fi +} + +function volinfo_field() +{ + local vol=$1; + local field=$2; + + $CLI_1 volume info $vol | grep "^$field: " | sed 's/.*: //'; +} + +function two_diff_vols_create { + # Both volume creates should be successful + $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 $H3:$B3/$V0 & + PID_1=$! + + $CLI_2 volume create $V1 $H1:$B1/$V1 $H2:$B2/$V1 $H3:$B3/$V1 & + PID_2=$! + + wait $PID_1 $PID_2 +} + +function two_diff_vols_start { + # Both volume starts should be successful + $CLI_1 volume start $V0 & + PID_1=$! + + $CLI_2 volume start $V1 & + PID_2=$! + + wait $PID_1 $PID_2 +} + +function two_diff_vols_stop_force { + # Force stop, so that if rebalance from the + # remove bricks is in progress, stop can + # still go ahead. Both volume stops should + # be successful + $CLI_1 volume stop $V0 force & + PID_1=$! + + $CLI_2 volume stop $V1 force & + PID_2=$! + + wait $PID_1 $PID_2 +} + +function same_vol_remove_brick { + + # Running two same vol commands at the same time can result in + # two success', two failures, or one success and one failure, all + # of which are valid. The only thing that shouldn't happen is a + # glusterd crash. + + local vol=$1 + local brick=$2 + $CLI_1 volume remove-brick $1 $2 start & + $CLI_2 volume remove-brick $1 $2 start +} + +cleanup; + +TEST launch_cluster 3; +TEST $CLI_1 peer probe $H2; +TEST $CLI_1 peer probe $H3; + +EXPECT_WITHIN 20 2 check_peers + +two_diff_vols_create +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT 'Created' volinfo_field $V1 'Status'; + +two_diff_vols_start +EXPECT 'Started' volinfo_field $V0 'Status'; +EXPECT 'Started' volinfo_field $V1 'Status'; + +same_vol_remove_brick $V0 $H2:$B2/$V0 +# Checking glusterd crashed or not after same volume remove brick +# on both nodes. +EXPECT_WITHIN 20 2 check_peers + +same_vol_remove_brick $V1 $H2:$B2/$V1 +# Checking glusterd crashed or not after same volume remove brick +# on both nodes. +EXPECT_WITHIN 20 2 check_peers + +$CLI_1 volume set $V0 diagnostics.client-log-level DEBUG & +$CLI_1 volume set $V1 diagnostics.client-log-level DEBUG +kill_glusterd 3 +$CLI_1 volume status $V0 +$CLI_2 volume status $V1 +$CLI_1 peer status +EXPECT_WITHIN 20 1 check_peers +EXPECT 'Started' volinfo_field $V0 'Status'; +EXPECT 'Started' volinfo_field $V1 'Status'; + +TEST $glusterd_3 +$CLI_1 volume status $V0 +$CLI_2 volume status $V1 +$CLI_1 peer status +#EXPECT_WITHIN 20 2 check_peers +#EXPECT 'Started' volinfo_field $V0 'Status'; +#EXPECT 'Started' volinfo_field $V1 'Status'; +#two_diff_vols_stop_force +#EXPECT_WITHIN 20 2 check_peers +cleanup; diff --git a/tests/basic/mount.t b/tests/basic/mount.t index 7b2769643..90e522c5e 100755 --- a/tests/basic/mount.t +++ b/tests/basic/mount.t @@ -52,7 +52,7 @@ TEST 'grep -E "^$H0:$V0 .+ ,?ro,.+" /proc/mounts'; sleep 5; ## Mount NFS -TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0 $N0; +TEST mount -t nfs -o nolock,soft,intr $H0:/$V0 $N0; ## Test for consistent views between NFS and FUSE mounts diff --git a/tests/basic/nufa.t b/tests/basic/nufa.t new file mode 100644 index 000000000..0d4c229a0 --- /dev/null +++ b/tests/basic/nufa.t @@ -0,0 +1,32 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '8' brick_count $V0 + +TEST $CLI volume set $V0 nufa on; + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount FUSE with caching disabled (read-only) +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 --read-only -s $H0 --volfile-id $V0 $M1; + +## Wait for volume to register with rpc.mountd +sleep 5; + +## Mount NFS +TEST mount -t nfs -o nolock,soft,intr $H0:/$V0 $N0; + +cleanup; diff --git a/tests/basic/rpm.t b/tests/basic/rpm.t index 560d9f8b8..a577726a8 100755 --- a/tests/basic/rpm.t +++ b/tests/basic/rpm.t @@ -1,14 +1,29 @@ #!/bin/bash +# +# This test will run mock and rebuild the srpm for the latest two EPEL version. +# By default, the results and the chroots are deleted. +# +# When debugging is needed, make sure to set DEBUG=1 in the environment or this +# script. When debugging is enabled, the resulting log files and chroots are +# kept. With debugging enabled, this test will fail the regression test, and +# all output is saved to rpmbuild-mock.log. Tests are run in parallel, so the +# logfile may be difficult to read. +# +# chroots are configured in /etc/mock/*.cfg, with site-defaults.cfg as main +# configuration file. The default for chroots is /var/lib/mock, but this +# depends on the 'basedir' configuration option set in the mentioned files. +# . $(dirname $0)/../include.rc -RESULT_DIR=$(mktemp -d -p /var/tmp rpm-tests.XXXXXXXX) - # enable some extra debugging if [ -n "${DEBUG}" -a "${DEBUG}" != "0" ] then - exec &> ${RESULT_DIR}/log + exec &> rpmbuild-mock.log set -x + MOCK_CLEANUP='--no-cleanup-after' +else + MOCK_CLEANUP='--cleanup-after' fi # detect the branch we're based off @@ -20,18 +35,13 @@ else GIT_PARENT=$(git describe --abbrev=0) fi -# check for changed files -CHANGED_FILES=$(git diff --name-only ${GIT_PARENT}) -# filter out any files not affecting the build itself -CHANGED_FILES=$(grep -E -v \ - -e '\.c$' \ - -e '\.h$' \ - -e '\.py$' \ - -e '^tests/' \ - <<< "${CHANGED_FILES}") -if [ -z "${CHANGED_FILES}" ] +# Filter out everything and what remains needs to be built +BUILD_FILES=$(git diff --name-status ${GIT_PARENT} | grep -Ev '^M.*\.(c|h|py)' | awk {'print $2'}) +SELFTEST=$(grep -e 'tests/basic/rpm.t' <<< "${BUILD_FILES}") +BUILD_FILES=$(grep -Ev '^tests/' <<< "${BUILD_FILES}") +if [ -z "${BUILD_FILES}" -a -z "${SELFTEST}" ] then - # only contents of files were changed, no need to retest rpmbuild + # nothing affecting packaging changed, no need to retest rpmbuild SKIP_TESTS cleanup exit 0 @@ -40,12 +50,12 @@ fi # checkout the sources to a new directory to execute ./configure and all REPO=${PWD} COMMIT=$(git describe) -mkdir ${RESULT_DIR}/sources -cd ${RESULT_DIR}/sources +mkdir rpmbuild-mock.d +pushd rpmbuild-mock.d 2>/dev/null git clone -q -s file://${REPO} . git checkout -q -b rpm-test ${COMMIT} -# build the glusterfs-*.tar.gz and gluster-swift-ufo-*.tar.gz +# build the glusterfs-*.tar.gz [ -e configure ] || ./autogen.sh 2>&1 > /dev/null TEST ./configure --enable-fusermount TEST make dist @@ -54,47 +64,46 @@ TEST make dist ls extras TEST make -C extras/LinuxRPM testsrpm -chmod g=rwx ${RESULT_DIR} -chown :mock ${RESULT_DIR} - # build for the last two Fedora EPEL releases (x86_64 only) for MOCK_CONF in $(ls -x1 /etc/mock/*.cfg | egrep -e 'epel-[0-9]+-x86_64.cfg$' | tail -n2) do EPEL_RELEASE=$(basename ${MOCK_CONF} .cfg) - mkdir ${RESULT_DIR}/${EPEL_RELEASE} - chmod g=rwx ${RESULT_DIR}/${EPEL_RELEASE} - chown :mock ${RESULT_DIR}/${EPEL_RELEASE} # expand the mock command line - MOCK_CMD=$(echo /usr/bin/mock --cleanup-after \ - --resultdir=${RESULT_DIR}/${EPEL_RELEASE} \ - -r ${EPEL_RELEASE} --rebuild ${PWD}/*.src.rpm) + MOCK_CMD="/usr/bin/mock ${MOCK_CLEANUP} \ + -r ${EPEL_RELEASE} --rebuild ${PWD}/*.src.rpm" # write the mock command to a file, so that its easier to execute - cat << EOF > ${RESULT_DIR}/${EPEL_RELEASE}/mock.sh + cat << EOF > mock-${EPEL_RELEASE}.sh #!/bin/sh ${MOCK_CMD} EOF - chmod +x ${RESULT_DIR}/${EPEL_RELEASE}/mock.sh + chmod +x mock-${EPEL_RELEASE}.sh # root can not run 'mock', it needs to drop priviledges if (groups | grep -q mock) then # the current user is in group 'mock' - TEST ${RESULT_DIR}/${EPEL_RELEASE}/mock.sh + ${PWD}/mock-${EPEL_RELEASE}.sh & else - # switch to the user called 'mock' - chown mock:mock ${RESULT_DIR}/${EPEL_RELEASE} # "su" might not work, using sudo instead - TEST sudo -u mock -E ${RESULT_DIR}/${EPEL_RELEASE}/mock.sh + sudo -u mock -E ${PWD}/mock-${EPEL_RELEASE}.sh & fi + sleep 5 +done + +# TAP and Prove aren't smart about loops +TESTS_EXPECTED_IN_LOOP=2 +for mockjob in $(jobs -p) +do + TEST_IN_LOOP wait ${mockjob} done # we could build for the last two Fedora releases too, but that is not # possible on EPEL-5/6 installations, Fedora 17 and newer have unmet # dependencies on the build-server :-/ -# only remove ${RESULT_DIR} if we're not debugging -[ "${DEBUG}" = "0" ] && rm -rf ${RESULT_DIR} +popd 2>/dev/null +# only remove rpmbuild-mock.d if we're not debugging +[ "${DEBUG}" = "0" ] && rm -rf rpmbuild-mock.d cleanup - diff --git a/tests/basic/volume-snapshot.t b/tests/basic/volume-snapshot.t new file mode 100755 index 000000000..35c748372 --- /dev/null +++ b/tests/basic/volume-snapshot.t @@ -0,0 +1,83 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../cluster.rc +. $(dirname $0)/../snapshot.rc + +V1="patchy2" + +function create_volumes() { + $CLI_1 volume create $V0 $H1:$L1 & + PID_1=$! + + $CLI_2 volume create $V1 $H2:$L2 $H3:$L3 & + PID_2=$! + + wait $PID_1 $PID_2 +} + +function create_snapshots() { + $CLI_1 snapshot create ${V0}_snap ${V0}& + PID_1=$! + + $CLI_1 snapshot create ${V1}_snap ${V1}& + PID_2=$! + + wait $PID_1 $PID_2 +} + +function delete_snapshots() { + $CLI_1 snapshot delete ${V0}_snap & + PID_1=$! + + $CLI_1 snapshot delete ${V1}_snap & + PID_2=$! + + wait $PID_1 $PID_2 +} +cleanup; + +#Create cluster with 3 nodes +TEST launch_cluster 3; +TEST setup_lvm 3 + +TEST $CLI_1 peer probe $H2; +TEST $CLI_1 peer probe $H3; +EXPECT_WITHIN 20 2 peer_count; + +create_volumes +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT 'Created' volinfo_field $V1 'Status'; + +start_volumes 2 +EXPECT 'Started' volinfo_field $V0 'Status'; +EXPECT 'Started' volinfo_field $V1 'Status'; + +#Snapshot Operations +create_snapshots +TEST snapshot_exists $V0 ${V0}_snap +TEST snapshot_exists $V1 ${V1}_snap + +TEST $CLI_1 snapshot config $V0 snap-max-hard-limit 100 +TEST $CLI_1 snapshot config $V1 snap-max-hard-limit 100 + +TEST mount -t glusterfs $H1:/snaps/${V0}_snap/${V0} $M0 +TEST umount -f $M0 +TEST mount -t glusterfs $H2:/snaps/${V1}_snap/${V1} $M0 +TEST umount -f $M0 + +#Clean up +delete_snapshots +TEST ! snapshot_exists $V0 ${V0}_snap +TEST ! snapshot_exists $V1 ${V1}_snap + +stop_force_volumes 2 +EXPECT 'Stopped' volinfo_field $V0 'Status'; +EXPECT 'Stopped' volinfo_field $V1 'Status'; + +delete_volumes 2 +TEST ! volume_exists $V0 +TEST ! volume_exists $V1 + +cleanup; diff --git a/tests/basic/volume-status.t b/tests/basic/volume-status.t index a7a9b233f..f4196ac30 100644 --- a/tests/basic/volume-status.t +++ b/tests/basic/volume-status.t @@ -1,6 +1,7 @@ #!/bin/bash . $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc cleanup; @@ -23,6 +24,8 @@ TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0 $N0; TEST $CLI volume status all TEST $CLI volume status $V0 +EXPECT_WITHIN 10 'Y' nfs_up_status +EXPECT_WITHIN 10 'Y' glustershd_up_status function test_nfs_cmds () { local ret=0 declare -a nfs_cmds=("clients" "mem" "inode" "callpool") @@ -30,17 +33,17 @@ function test_nfs_cmds () { $CLI volume status $V0 nfs $cmd (( ret += $? )) done - echo ret + return $ret } function test_shd_cmds () { local ret=0 declare -a shd_cmds=("mem" "inode" "callpool") - for scmd in ${shd_cmds[@]}; do + for cmd in ${shd_cmds[@]}; do $CLI volume status $V0 shd $cmd (( ret += $? )) done - echo ret + return $ret } function test_brick_cmds () { @@ -52,7 +55,7 @@ function test_brick_cmds () { (( ret += $? )) done done - echo ret + return $ret } TEST test_shd_cmds; diff --git a/tests/bugs/949327.t b/tests/bugs/949327.t new file mode 100644 index 000000000..7b0c5c51a --- /dev/null +++ b/tests/bugs/949327.t @@ -0,0 +1,23 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +function tmp_file_count() +{ +echo $(ls -lh /tmp/tmp.* | wc -l) +} + + +old_count=$(tmp_file_count); +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 +new_count=$(tmp_file_count); + +TEST [ "$old_count" -eq "$new_count" ] + +cleanup diff --git a/tests/bugs/bug-1002207.t b/tests/bugs/bug-1002207.t new file mode 100644 index 000000000..50b8c7d31 --- /dev/null +++ b/tests/bugs/bug-1002207.t @@ -0,0 +1,54 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +## Start and create a volume +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume create $V0 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; + +## Verify volume is 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'; + +dd if=/dev/zero of=$M0/file$i.data bs=1024 count=1024 1>/dev/null 2>&1 + +function xattr_query_check() +{ + local path=$1 + local xa_name=$2 + + local ret=`getfattr -m . -n $xa_name $path 2>&1 | grep -o "$xa_name: No such attribute" | wc -l` + echo $ret +} + +function set_xattr() +{ + local path=$1 + local xa_name=$2 + local xa_val=$3 + + setfattr -n $xa_name -v $xa_val $path + echo $? +} + +EXPECT 0 set_xattr $M0/file$i.data "trusted.name" "testofafairlylongxattrstringthatbutnotlongenoughtofailmemoryallocation" + +EXPECT 0 xattr_query_check $M0/file$i.data "trusted.name" + +## Finish up +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/bug-1002556.t b/tests/bugs/bug-1002556.t new file mode 100755 index 000000000..a57f455d4 --- /dev/null +++ b/tests/bugs/bug-1002556.t @@ -0,0 +1,25 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume start $V0 +EXPECT '1 x 2 = 2' volinfo_field $V0 'Number of Bricks'; + +TEST $CLI volume add-brick $V0 replica 3 $H0:$B0/${V0}2 +EXPECT '1 x 3 = 3' volinfo_field $V0 'Number of Bricks'; + +TEST $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}1 force +EXPECT '1 x 2 = 2' volinfo_field $V0 'Number of Bricks'; + +TEST killall glusterd +TEST glusterd + +EXPECT '1 x 2 = 2' volinfo_field $V0 'Number of Bricks'; +cleanup diff --git a/tests/bugs/bug-1004218.t b/tests/bugs/bug-1004218.t new file mode 100644 index 000000000..17eb3c65b --- /dev/null +++ b/tests/bugs/bug-1004218.t @@ -0,0 +1,26 @@ +#!/bin/bash + +# Test if only a single xml document is generated by 'status all' +# when a volume is not started + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create ${V0}1 $H0:$B0/${V0}1{1,2} +TEST $CLI volume create ${V0}2 $H0:$B0/${V0}2{1,2} + +TEST $CLI volume start ${V0}1 + +function test_status_all () +{ + $CLI volume status all --xml | xmllint -format - +} + +TEST test_status_all + +TEST $CLI volume stop ${V0}1 + +cleanup diff --git a/tests/bugs/bug-1004744.t b/tests/bugs/bug-1004744.t new file mode 100644 index 000000000..0290119ef --- /dev/null +++ b/tests/bugs/bug-1004744.t @@ -0,0 +1,48 @@ +#!/bin/bash + +#Test case: After a rebalance fix-layout, check if the rebalance status command +#displays the appropriate message at the CLI. + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a 2x1 distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; +TEST $CLI volume start $V0 + +# Mount FUSE and create file/directory +TEST glusterfs -s $H0 --volfile-id $V0 $M0 +for i in `seq 1 10`; +do + mkdir $M0/dir_$i + echo file>$M0/dir_$i/file_$i + for j in `seq 1 100`; + do + mkdir $M0/dir_$i/dir_$j + echo file>$M0/dir_$i/dir_$j/file_$j + done +done + +#add 2 bricks +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}{3,4}; + +#perform rebalance fix-layout +TEST $CLI volume rebalance $V0 fix-layout start + +EXPECT_WITHIN 1 "fix-layout in progress" rebalance_status_field $V0; + +EXPECT_WITHIN 20 "fix-layout completed" rebalance_status_field $V0; + +TEST umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/bug-1015990-rep.t b/tests/bugs/bug-1015990-rep.t new file mode 100755 index 000000000..f59bb2f75 --- /dev/null +++ b/tests/bugs/bug-1015990-rep.t @@ -0,0 +1,81 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../afr.rc +cleanup; + +## Start and create a volume +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4}; + +## Verify volume is 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 --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + + + +TEST kill_brick $V0 $H0 $B0/$V0"1" +sleep 5 +TEST kill_brick $V0 $H0 $B0/$V0"3" +sleep 5 + +for i in {1..100}; do echo "STRING" > $M0/File$i; done + +brick_2_sh_entries=$(count_sh_entries $B0/$V0"2") +brick_4_sh_entries=$(count_sh_entries $B0/$V0"4") + + +command_output=$(gluster volume heal $V0 statistics heal-count replica $H0:$B0/$V0"1") + + +substring="Number of entries:" +count=0 +while read -r line; +do + if [[ "$line" == *$substring* ]] + then + value=$(echo $line | cut -f 2 -d :) + count=$(($count + $value)) + fi + +done <<< "$command_output" + +brick_2_entries_count=$(($count-$value)) + +EXPECT "0" echo $brick_2_entries_count + +brick_2_entries_count=$count + + +xattrop_count_brick_2=$(count_sh_entries $B0/$V0"2") +##Remove the count of the xattrop-gfid entry count as it does not contribute +##to the number of files to be healed + +sub_val=1 +xattrop_count_brick_2=$(($xattrop_count_brick_2-$sub_val)) + +ret=0 +if [ "$xattrop_count_brick_2" -eq "$brick_2_entries_count" ] + then + ret=$(($ret + $sub_val)) +fi + +EXPECT "1" echo $ret +## Finish up +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/bug-1015990.t b/tests/bugs/bug-1015990.t new file mode 100755 index 000000000..165af5168 --- /dev/null +++ b/tests/bugs/bug-1015990.t @@ -0,0 +1,95 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../afr.rc +cleanup; + +## Start and create a volume +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4}; + +## Verify volume is 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 --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + + + +TEST kill_brick $V0 $H0 $B0/$V0"1" +sleep 5 +TEST kill_brick $V0 $H0 $B0/$V0"3" +sleep 5 + +for i in {1..100}; do echo "STRING" > $M0/File$i; done + +brick_2_sh_entries=$(count_sh_entries $B0/$V0"2") +brick_4_sh_entries=$(count_sh_entries $B0/$V0"4") + + +command_output=$(gluster volume heal $V0 statistics heal-count) + + +substring="Number of entries:" +count=0 +while read -r line; +do + if [[ "$line" == *$substring* ]] + then + value=$(echo $line | cut -f 2 -d :) + count=$(($count + $value)) + fi + +done <<< "$command_output" + +brick_2_entries_count=$(($count-$value)) +brick_4_entries_count=$value + + +xattrop_count_brick_2=$(count_sh_entries $B0/$V0"2") +##Remove the count of the xattrop-gfid entry count as it does not contribute +##to the number of files to be healed + +sub_val=1 +xattrop_count_brick_2=$(($xattrop_count_brick_2-$sub_val)) + +xattrop_count_brick_4=$(count_sh_entries $B0/$V0"4") +##Remove xattrop-gfid entry count + +xattrop_count_brick_4=$(($xattrop_count_brick_4-$sub_val)) + + +ret=0 +if [ "$xattrop_count_brick_2" -eq "$brick_2_entries_count" ] + then + ret=$(($ret + $sub_val)) +fi + +EXPECT "1" echo $ret + + +ret=0 +if [ "$xattrop_count_brick_4" -eq "$brick_4_entries_count" ] + then + ret=$(($ret + $sub_val)) +fi + +EXPECT "1" echo $ret + +## Finish up +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/bug-1022055.t b/tests/bugs/bug-1022055.t new file mode 100755 index 000000000..c2f4218bb --- /dev/null +++ b/tests/bugs/bug-1022055.t @@ -0,0 +1,26 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../cluster.rc + +function check_peers { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} + +cleanup; + +TEST launch_cluster 2; + +TEST $CLI_1 peer probe $H2; + +EXPECT_WITHIN 20 1 check_peers; + +TEST $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0; + +TEST $CLI_1 volume start $V0; + +TEST $CLI_1 volume log rotate $V0; + +TEST $CLI_1 volume status; + +cleanup; diff --git a/tests/bugs/bug-1022905.t b/tests/bugs/bug-1022905.t new file mode 100644 index 000000000..aef3395dd --- /dev/null +++ b/tests/bugs/bug-1022905.t @@ -0,0 +1,39 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +## Create a volume +TEST glusterd; +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1}; +EXPECT 'Created' volinfo_field $V0 'Status'; + +## Volume start +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Enable a protected and a resettable/unprotected option +TEST $CLI volume quota $V0 enable +TEST $CLI volume set $V0 diagnostics.client-log-level DEBUG + +## Reset cmd resets only unprotected option(s), succeeds. +TEST $CLI volume reset $V0; + +## Reset should fail +TEST ! $CLI volume reset $V0; + +## Set an unprotected option +TEST $CLI volume set $V0 diagnostics.client-log-level DEBUG + +## Now 1 protected and 1 unprotected options are set +## Reset force should succeed +TEST $CLI volume reset $V0 force; + +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup; diff --git a/tests/bugs/bug-1030208.t b/tests/bugs/bug-1030208.t new file mode 100644 index 000000000..866999692 --- /dev/null +++ b/tests/bugs/bug-1030208.t @@ -0,0 +1,35 @@ +#!/bin/bash + +#Test case: Hardlink test + +. $(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 a file and perform fop on a DIR +TEST touch $M0/foo +TEST ls $M0/ + +#Create hardlink +TEST ln $M0/foo $M0/bar + + +TEST umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/bug-1040934.t b/tests/bugs/bug-1040934.t new file mode 100644 index 000000000..3089d7ce1 --- /dev/null +++ b/tests/bugs/bug-1040934.t @@ -0,0 +1,37 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../cluster.rc +. $(dirname $0)/../snapshot.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST launch_cluster 2 +TEST setup_lvm 2 + +TEST $CLI_1 peer probe $H2 +EXPECT_WITHIN 20 1 peer_count + +TEST $CLI_1 volume create $V0 replica 2 $H1:$L1 $H2:$L2 +EXPECT 'Created' volinfo_field $V0 'Status' + +TEST $CLI_1 volume start $V0 +EXPECT 'Started' volinfo_field $V0 'Status' + +TEST $CLI_1 snapshot create ${V0}_snap ${V0} +PID_1=$! +wait $PID_1 + +TEST snapshot_exists ${V0}_snap +TEST mount -t glusterfs $H1:/snaps/${V0}_snap/$V0 $M0 +cd $M0 +TEST ! touch a + +TEST $CLI_1 snapshot delete ${V0}_snap +PID_1=$! +wait $PID_1 + +TEST ! snapshot_exists ${V0}_snap + +cleanup; diff --git a/tests/bugs/bug-1045333.t b/tests/bugs/bug-1045333.t new file mode 100644 index 000000000..d1f8069e8 --- /dev/null +++ b/tests/bugs/bug-1045333.t @@ -0,0 +1,48 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../snapshot.rc + +cleanup; +TEST glusterd; +TEST pidof glusterd; + +TEST setup_lvm 1 + +TEST $CLI volume create $V0 $H0:$L1 +TEST $CLI volume start $V0 + + +S1="${V0}-snap1" #Create snapshot with name contains hyphen(-) +S2="-${V0}-snap2" #Create snapshot with name starts with hyphen(-) +#Create snapshot with a long name +S3="${V0}_single_gluster_volume_is_accessible_by_multiple_clients_offline_snapshot_is_a_long_name" + +TEST $CLI snapshot create $S1 $V0 +TEST snapshot_exists $S1 + +TEST $CLI snapshot create $S2 $V0 +TEST snapshot_exists $S2 + +TEST $CLI snapshot create $S3 $V0 +TEST snapshot_exists $S3 + + +TEST mount -t glusterfs $H0:/snaps/$S1/$V0 $M0 +TEST umount -f $M0 + +TEST mount -t glusterfs $H0:/snaps/$S2/$V0 $M0 +TEST umount -f $M0 + +TEST mount -t glusterfs $H0:/snaps/$S3/$V0 $M0 +TEST umount -f $M0 + +#Clean up +TEST $CLI snapshot delete $S1 +TEST $CLI snapshot delete $S2 +TEST $CLI snapshot delete $S3 + +TEST $CLI volume stop $V0 force +TEST $CLI volume delete $V0 + +cleanup; diff --git a/tests/bugs/bug-1049834.t b/tests/bugs/bug-1049834.t new file mode 100755 index 000000000..6019a561c --- /dev/null +++ b/tests/bugs/bug-1049834.t @@ -0,0 +1,40 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../cluster.rc +. $(dirname $0)/../snapshot.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST launch_cluster 2 +TEST setup_lvm 2 + +TEST $CLI_1 peer probe $H2 +EXPECT_WITHIN 20 1 peer_count + +TEST $CLI_1 volume create $V0 $H1:$L1 $H2:$L2 +EXPECT 'Created' volinfo_field $V0 'Status' + +TEST $CLI_1 volume start $V0 +EXPECT 'Started' volinfo_field $V0 'Status' + +#Setting the snap-max-hard-limit to 4 +TEST $CLI_1 snapshot config $V0 snap-max-hard-limit 4 +PID_1=$! +wait $PID_1 + +#Creating 4 snapshots on the volume +TEST create_n_snapshots $V0 4 $V0_snap +TEST snapshot_n_exists $V0 4 $V0_snap + +#Creating the 5th snapshots on the volume and expecting it not to be created. +TEST ! $CLI_1 snapshot create ${V0}_snap5 ${V0} +TEST ! snapshot_exists ${V0}_snap5 +TEST ! $CLI_1 snapshot delete ${V0}_snap5 + +#Deleting the 4 snaps +TEST delete_n_snapshots $V0 4 $V0_snap +TEST ! snapshot_n_exists $V0 4 $V0_snap + +cleanup; diff --git a/tests/bugs/bug-1064768.t b/tests/bugs/bug-1064768.t new file mode 100755 index 000000000..b87168150 --- /dev/null +++ b/tests/bugs/bug-1064768.t @@ -0,0 +1,20 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/brick0 $H0:$B0/brick1 +TEST $CLI volume start $V0 +EXPECT_WITHIN 15 'Started' volinfo_field $V0 'Status'; + +TEST $CLI volume profile $V0 start +TEST $CLI volume profile $V0 info +TEST $CLI volume profile $V0 stop + +TEST $CLI volume status +TEST $CLI volume stop $V0 +EXPECT_WITHIN 15 'Stopped' volinfo_field $V0 'Status'; +cleanup; diff --git a/tests/bugs/bug-764638.t b/tests/bugs/bug-764638.t new file mode 100644 index 000000000..816546524 --- /dev/null +++ b/tests/bugs/bug-764638.t @@ -0,0 +1,13 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +TEST $CLI pool list; +TEST $CLI pool list --xml; + +cleanup; diff --git a/tests/bugs/bug-765380.t b/tests/bugs/bug-765380.t new file mode 100644 index 000000000..a9784b93d --- /dev/null +++ b/tests/bugs/bug-765380.t @@ -0,0 +1,39 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +REPLICA=2 + +TEST $CLI volume create $V0 replica $REPLICA $H0:$B0/${V0}00 $H0:$B0/${V0}01 $H0:$B0/${V0}10 $H0:$B0/${V0}11 +TEST $CLI volume start $V0 + +## Mount FUSE with caching disabled +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; + +function count_hostname_or_uuid_from_pathinfo() +{ + pathinfo=`getfattr -m . -n trusted.glusterfs.pathinfo $M0/f00f` + echo $pathinfo | grep -o $1 | wc -l +} + +touch $M0/f00f + +EXPECT $REPLICA count_hostname_or_uuid_from_pathinfo $H0 + +# turn on node-uuid-pathinfo option +TEST $CLI volume set $V0 node-uuid-pathinfo on + +# do not expext hostname as part of the pathinfo string +EXPECT 0 count_hostname_or_uuid_from_pathinfo $H0 + +uuid=`grep UUID /var/lib/glusterd/glusterd.info | cut -f2 -d=` + +# ... but expect the uuid $REPLICA times +EXPECT $REPLICA count_hostname_or_uuid_from_pathinfo $uuid + +cleanup; diff --git a/tests/bugs/bug-767585-gfid.t b/tests/bugs/bug-767585-gfid.t new file mode 100755 index 000000000..49cf7423f --- /dev/null +++ b/tests/bugs/bug-767585-gfid.t @@ -0,0 +1,43 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#Test cases to perform gfid-self-heal +#file 'a' should be assigned a fresh gfid +#file 'b' should be healed with gfid1 from brick1 +#file 'c' should be healed with gfid2 from brick2 + +gfid1="0x8428b7193a764bf8be8046fb860b8993" +gfid2="0x85ad91afa2f74694bf52c3326d048209" + +cleanup; +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --direct-io-mode=enable +touch $B0/${V0}0/a $B0/${V0}1/a +touch $B0/${V0}0/b $B0/${V0}1/b +touch $B0/${V0}0/c $B0/${V0}1/c + +TEST setfattr -n trusted.gfid -v $gfid1 $B0/${V0}0/b +TEST setfattr -n trusted.gfid -v $gfid2 $B0/${V0}1/c + +sleep 2 + +cd $M0 +TEST ls -l a +TEST ls -l b +TEST ls -l c + +TEST gf_get_gfid_xattr $B0/${V0}0/a +TEST gf_get_gfid_xattr $B0/${V0}1/a + +EXPECT "$gfid1" gf_get_gfid_xattr $B0/${V0}0/b +EXPECT "$gfid1" gf_get_gfid_xattr $B0/${V0}1/b + +EXPECT "$gfid2" gf_get_gfid_xattr $B0/${V0}0/c +EXPECT "$gfid2" gf_get_gfid_xattr $B0/${V0}1/c + +cleanup; diff --git a/tests/bugs/bug-808400-fcntl.c b/tests/bugs/bug-808400-fcntl.c index 36e6cf035..4deef34a5 100644 --- a/tests/bugs/bug-808400-fcntl.c +++ b/tests/bugs/bug-808400-fcntl.c @@ -84,9 +84,9 @@ main (int argc, char *argv[]) system (cmd); /* wait till graph switch completes */ - ret = fstat (fd, &stbuf); + ret = fstat64 (fd, &stbuf); if (ret < 0) { - fprintf (stderr, "fstat failure (%s)\n", strerror (errno)); + fprintf (stderr, "fstat64 failure (%s)\n", strerror (errno)); goto out; } diff --git a/tests/bugs/bug-808400-flock.c b/tests/bugs/bug-808400-flock.c index 3a30a1d4b..4770c81dc 100644 --- a/tests/bugs/bug-808400-flock.c +++ b/tests/bugs/bug-808400-flock.c @@ -63,9 +63,9 @@ main (int argc, char *argv[]) system (cmd); /* wait till graph switch completes */ - ret = fstat (fd, &stbuf); + ret = fstat64 (fd, &stbuf); if (ret < 0) { - fprintf (stderr, "fstat failure (%s)\n", strerror (errno)); + fprintf (stderr, "fstat64 failure (%s)\n", strerror (errno)); goto out; } diff --git a/tests/bugs/bug-821056.t b/tests/bugs/bug-821056.t index 9265ba7a4..5e81541ac 100644 --- a/tests/bugs/bug-821056.t +++ b/tests/bugs/bug-821056.t @@ -8,11 +8,12 @@ TEST glusterd TEST pidof glusterd TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 eager-lock off TEST $CLI volume set $V0 cluster.self-heal-daemon off TEST $CLI volume set $V0 performance.quick-read off TEST $CLI volume set $V0 performance.open-behind 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.write-behind on TEST $CLI volume set $V0 performance.stat-prefetch off TEST $CLI volume set $V0 performance.read-ahead off TEST $CLI volume set $V0 cluster.background-self-heal-count 0 @@ -46,4 +47,6 @@ EXPECT_WITHIN 20 "Y" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 $B0/${V0}0 #close the fd exec 5>&- +#Check that anon-fd based file is not leaking. +EXPECT_WITHIN 20 "N" gf_check_file_opened_in_brick $V0 $H0 $B0/${V0}0 "$realpath" cleanup; diff --git a/tests/bugs/bug-823081.t b/tests/bugs/bug-823081.t index ce7d2e509..760d9e2b6 100755 --- a/tests/bugs/bug-823081.t +++ b/tests/bugs/bug-823081.t @@ -14,6 +14,8 @@ function set_tail () vol=$1; tail_success="volume create $vol $H0:$B0/${vol}1 $H0:$B0/${vol}2 : SUCCESS" tail_failure="volume create $vol $H0:$B0/${vol}1 $H0:$B0/${vol}2 : FAILED : Volume $vol already exists" + tail_success_force="volume create $vol $H0:$B0/${vol}1 $H0:$B0/${vol}2 force : SUCCESS" + tail_failure_force="volume create $vol $H0:$B0/${vol}1 $H0:$B0/${vol}2 force : FAILED : Volume $vol already exists" } set_tail $V0; @@ -27,12 +29,12 @@ tail=`tail --lines=1 $logdir/.cmd_log_history | cut -d " " -f 5-` TEST [[ \"$tail\" == \"$tail_failure\" ]] set_tail $V1; -TEST gluster volume create $V1 $H0:$B0/${V1}{1,2}; +TEST gluster volume create $V1 $H0:$B0/${V1}{1,2} force; tail=`tail --lines=1 $logdir/.cmd_log_history | cut -d " " -f 5-` -TEST [[ \"$tail\" == \"$tail_success\" ]] +TEST [[ \"$tail\" == \"$tail_success_force\" ]] -TEST ! gluster volume create $V1 $H0:$B0/${V1}{1,2}; +TEST ! gluster volume create $V1 $H0:$B0/${V1}{1,2} force; tail=`tail --lines=1 $logdir/.cmd_log_history | cut -d " " -f 5-` -TEST [[ \"$tail\" == \"$tail_failure\" ]] +TEST [[ \"$tail\" == \"$tail_failure_force\" ]] cleanup; diff --git a/tests/bugs/bug-830665.t b/tests/bugs/bug-830665.t index 0373ec6d7..0073ff1d9 100755 --- a/tests/bugs/bug-830665.t +++ b/tests/bugs/bug-830665.t @@ -35,6 +35,7 @@ TEST $CLI volume set $V0 performance.stat-prefetch off; ## Make sure automatic self-heal doesn't perturb our results. TEST $CLI volume set $V0 cluster.self-heal-daemon off +TEST $CLI volume set $V0 cluster.background-self-heal-count 0 ## Start volume and verify TEST $CLI volume start $V0; diff --git a/tests/bugs/bug-847624.t b/tests/bugs/bug-847624.t new file mode 100755 index 000000000..f4e9942e9 --- /dev/null +++ b/tests/bugs/bug-847624.t @@ -0,0 +1,23 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +cleanup + +#1 +TEST glusterd +TEST pidof glusterd +#3 +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume set $V0 nfs.drc on +TEST $CLI volume start $V0 +sleep 5 +TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0 $N0 +cd $N0 +#7 +TEST dbench -t 10 10 +TEST rm -rf $N0/* +cd +TEST umount $N0 +#10 +TEST $CLI volume set $V0 nfs.drc-size 10000 +cleanup diff --git a/tests/bugs/bug-853258.t b/tests/bugs/bug-853258.t index c702e6f30..faa9d4465 100755 --- a/tests/bugs/bug-853258.t +++ b/tests/bugs/bug-853258.t @@ -20,7 +20,7 @@ EXPECT_WITHIN 15 'Started' volinfo_field $V0 'Status'; # Force assignment of initial ranges. TEST $CLI volume rebalance $V0 fix-layout start -EXPECT_WITHIN 15 "success:" rebalance_status_field $V0 +EXPECT_WITHIN 15 "fix-layout completed" rebalance_status_field $V0 # Get the original values. xattrs="" @@ -32,13 +32,13 @@ done TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3 # Force assignment of initial ranges. TEST $CLI volume rebalance $V0 fix-layout start -EXPECT_WITHIN 15 "success:" rebalance_status_field $V0 +EXPECT_WITHIN 15 "fix-layout completed" rebalance_status_field $V0 for i in $(seq 0 3); do xattrs="$xattrs $(dht_get_layout $B0/${V0}$i)" done -overlap=$($(dirname $0)/overlap.py $xattrs) +overlap=$(python2 $(dirname $0)/overlap.py $xattrs) # 2863311531 = 0xaaaaaaab = 2/3 overlap TEST [ "$overlap" -ge 2863311531 ] diff --git a/tests/bugs/bug-856455.t b/tests/bugs/bug-856455.t index 1b2438b04..becb20222 100644 --- a/tests/bugs/bug-856455.t +++ b/tests/bugs/bug-856455.t @@ -38,3 +38,5 @@ EXPECT $BRICK_COUNT query_pathinfo $M0/f00d; kill -9 `cat /var/lib/glusterd/vols/$V0/run/$H0-d-backends-${V0}1.pid`; EXPECT `expr $BRICK_COUNT - 1` query_pathinfo $M0/f00d; + +cleanup; diff --git a/tests/bugs/bug-857330/common.rc b/tests/bugs/bug-857330/common.rc index 4e5a73a0b..e5a7cd79a 100644 --- a/tests/bugs/bug-857330/common.rc +++ b/tests/bugs/bug-857330/common.rc @@ -22,7 +22,7 @@ function check-and-store-task-id() function get-task-id() { - $CLI $COMMAND | grep $PATTERN | grep -o -E "$UUID_REGEX" + $CLI $COMMAND | grep $PATTERN | grep -o -E "$UUID_REGEX" | tail -n1 } diff --git a/tests/bugs/bug-857330/normal.t b/tests/bugs/bug-857330/normal.t index 4455d1620..24dfe52c4 100755 --- a/tests/bugs/bug-857330/normal.t +++ b/tests/bugs/bug-857330/normal.t @@ -28,7 +28,7 @@ PATTERN="ID:" TEST check-and-store-task-id COMMAND="volume status $V0" -PATTERN="Rebalance" +PATTERN="ID" EXPECT $TASK_ID get-task-id COMMAND="volume rebalance $V0 status" @@ -45,7 +45,7 @@ PATTERN="ID:" TEST check-and-store-task-id COMMAND="volume status $V0" -PATTERN="Replace" +PATTERN="ID" EXPECT $TASK_ID get-task-id COMMAND="volume replace-brick $V0 $REP_BRICK_PAIR status" @@ -62,7 +62,7 @@ PATTERN="ID:" TEST check-and-store-task-id COMMAND="volume status $V0" -PATTERN="Remove" +PATTERN="ID" EXPECT $TASK_ID get-task-id COMMAND="volume remove-brick $V0 $H0:$B0/${V0}3 status" diff --git a/tests/bugs/bug-858242.c b/tests/bugs/bug-858242.c index a42262e22..00a3a2d5f 100644 --- a/tests/bugs/bug-858242.c +++ b/tests/bugs/bug-858242.c @@ -43,9 +43,9 @@ main (int argc, char *argv[]) goto out; } - ret = fstat (fd, &statbuf); + ret = fstat64 (fd, &statbuf); if (ret < 0) { - fprintf (stderr, "fstat failed (%s)", strerror (errno)); + fprintf (stderr, "fstat64 failed (%s)", strerror (errno)); goto out; } diff --git a/tests/bugs/bug-858488-min-free-disk.t b/tests/bugs/bug-858488-min-free-disk.t index 43ef1496b..ae5ac3bde 100644 --- a/tests/bugs/bug-858488-min-free-disk.t +++ b/tests/bugs/bug-858488-min-free-disk.t @@ -7,7 +7,7 @@ cleanup; function pidgrep() { - ps ax | grep "$1" | awk '{print $1}' | head -1 + ps ax | grep "$1" | grep -v grep | awk '{print $1}' | head -1 } ## Start glusterd diff --git a/tests/bugs/bug-860663.t b/tests/bugs/bug-860663.t index 28d1f8fcd..05dea5fbc 100644 --- a/tests/bugs/bug-860663.t +++ b/tests/bugs/bug-860663.t @@ -47,3 +47,5 @@ sleep 5; NEW_FILE_COUNT=`ls -l $M0 | wc -l`; EXPECT "0" file_count $ORIG_FILE_COUNT $NEW_FILE_COUNT + +cleanup; diff --git a/tests/bugs/bug-861015-index.t b/tests/bugs/bug-861015-index.t index 15758badf..4b148e6cc 100644 --- a/tests/bugs/bug-861015-index.t +++ b/tests/bugs/bug-861015-index.t @@ -8,6 +8,7 @@ cleanup; TEST glusterd TEST pidof glusterd TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1,2,3,4,5} +TEST $CLI volume set $V0 ensure-durability off TEST $CLI volume start $V0 EXPECT_WITHIN 20 "Y" glustershd_up_status TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 diff --git a/tests/bugs/bug-861945.t b/tests/bugs/bug-861945.t deleted file mode 100755 index 29ccb33c8..000000000 --- a/tests/bugs/bug-861945.t +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -. $(dirname $0)/../include.rc - -cleanup; - -function georep_start_and_check() -{ - local master=$1 - local slave=$2 - - $CLI volume geo-replication $master $slave start -} - -function georep_stop() -{ - local master=$1 - local slave=$2 - - $CLI volume geo-replication $master $slave stop -} - -TEST glusterd -TEST pidof glusterd -TEST $CLI volume create $V0 $H0:$B0/brick0 $H0:$B0/brick1 -TEST $CLI volume start $V0 - -sleep 5 - -slave=`mktemp -d` -mkdir -p $slave - -# check normal functionality of geo-replication -EXPECT_KEYWORD "successful" georep_start_and_check $V0 $slave -TEST georep_stop $V0 $slave - -# now invoke replace brick -TEST $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick2 start - -# check if CLI refuses to start geo replication -EXPECT_KEYWORD "failed" georep_start_and_check $V0 $slave - -# commit replace brick operation -TEST $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick2 commit - -# geo replication should work as usual -EXPECT_KEYWORD "successful" georep_start_and_check $V0 $slave -TEST georep_stop $V0 $slave - -rm -rf $slave -cleanup diff --git a/tests/bugs/bug-862967.t b/tests/bugs/bug-862967.t index 73f5826fa..00fa88440 100644 --- a/tests/bugs/bug-862967.t +++ b/tests/bugs/bug-862967.t @@ -55,3 +55,5 @@ BACKEND_GID=`stat --printf=%g $B0/${V0}1/dir`; EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID + +cleanup; diff --git a/tests/bugs/bug-864499.t b/tests/bugs/bug-864499.t deleted file mode 100644 index 03c7bbe13..000000000 --- a/tests/bugs/bug-864499.t +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -. $(dirname $0)/../include.rc - -cleanup; - - -TEST glusterd -TEST pidof glusterd -TEST $CLI volume create $V0 $H0:$B0/brick0 -TEST $CLI volume start $V0 - -TEST "$CLI volume geo-replication $V0 $B0/slave start --xml | xmllint --format -" - -TEST "$CLI volume geo-replication $V0 $B0/slave stop --xml | xmllint --format -" - -TEST $CLI volume stop $V0 - -cleanup; - diff --git a/tests/bugs/bug-864506.t b/tests/bugs/bug-864506.t deleted file mode 100755 index c281f3811..000000000 --- a/tests/bugs/bug-864506.t +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -. $(dirname $0)/../include.rc - -cleanup; - - -TEST glusterd -TEST pidof glusterd -TEST $CLI volume create $V0 $H0:$B0/brick0 -TEST $CLI volume start $V0 - -TEST "mkdir $B0/slave" - -TEST "$CLI volume geo-replication $V0 $B0/slave start --xml | xmllint --format -" - -TEST "$CLI volume geo-replication $V0 $B0/slave2 start --xml | xmllint --format -" - -TEST "$CLI volume geo-replication status --xml | xmllint --format -" - -TEST "$CLI volume geo-replication $V0 $B0/slave status --xml | xmllint --format -" - -TEST "$CLI volume geo-replication $V0 $B0/slave2 status --xml | xmllint --format -" - -TEST "$CLI volume geo-replication $V0 $B0/slave stop --xml | xmllint --format -" - -TEST "$CLI volume geo-replication $V0 $B0/slave2 stop --xml | xmllint --format -" - -TEST $CLI volume stop $V0 - -TEST "rmdir $B0/slave" - -cleanup; diff --git a/tests/bugs/bug-873962.t b/tests/bugs/bug-873962.t index 6a85cee0c..b245cc3da 100755 --- a/tests/bugs/bug-873962.t +++ b/tests/bugs/bug-873962.t @@ -13,6 +13,26 @@ TEST $CLI volume info; B0_hiphenated=`echo $B0 | tr '/' '-'` TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2} +# If we allow self-heal to happen in the background, we'll get spurious +# failures - especially at the point labeled "FAIL HERE" but +# occasionally elsewhere. This behavior is very timing-dependent. It +# doesn't show up in Jenkins, but it does on JD's and KP's machines, and +# it got sharply worse because of an unrelated fsync change (6ae6f3d) +# which changed timing. Putting anything at the FAIL HERE marker tends +# to make it go away most of the time on affected machines, even if the +# "anything" is unrelated. +# +# What's going on is that the I/O on the first mountpoint is allowed to +# complete even though self-heal is still in progress and the state on +# disk does not reflect its result. In fact, the state changes during +# self-heal create the appearance of split brain when the second I/O +# comes in, so that fails even though we haven't actually been in split +# brain since the manual xattr operations. By disallowing background +# self-heal, we ensure that the second I/O can't happen before self-heal +# is complete, because it has to follow the first I/O which now has to +# follow self-heal. +TEST $CLI volume set $V0 cluster.background-self-heal-count 0 + #Make sure self-heal is not triggered when the bricks are re-started TEST $CLI volume set $V0 cluster.self-heal-daemon off TEST $CLI volume set $V0 performance.stat-prefetch off @@ -53,6 +73,7 @@ TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000000 $B0/${V0 #The operations should do self-heal and give correct output EXPECT "2" cat $M0/a; +# FAIL HERE - see comment about cluster.self-heal-background-count above. EXPECT "2" cat $M1/a; EXPECT "def" getfattr -n trusted.mdata --only-values $M0/b 2>/dev/null EXPECT "def" getfattr -n trusted.mdata --only-values $M1/b 2>/dev/null diff --git a/tests/bugs/bug-874272.t b/tests/bugs/bug-874272.t deleted file mode 100755 index 01793a368..000000000 --- a/tests/bugs/bug-874272.t +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -. $(dirname $0)/../include.rc - -cleanup; - -TEST glusterd -TEST pidof glusterd -TEST $CLI volume info; - -function volinfo_field() -{ - local vol=$1; - local field=$2; - - $CLI volume info $vol | grep "^$field: " | sed 's/.*: //'; -} - -TEST $CLI volume create $V0 $H0:$B0/brick1; -EXPECT 'Created' volinfo_field $V0 'Status'; - -TEST $CLI volume start $V0; -EXPECT 'Started' volinfo_field $V0 'Status'; - -## Wait for volume to register with rpc.mountd -sleep 5; - -#mount on a random dir -TEST MOUNTDIR="/tmp/$RANDOM" -TEST mkdir $MOUNTDIR -TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0 $MOUNTDIR; -flag=0 - -TEST touch $MOUNTDIR/testfile - -TEST GEOREPDIR="/tmp/$RANDOM" -TEST mkdir $GEOREPDIR - -TEST $CLI volume geo-replication $V0 file:///$GEOREPDIR start - -for i in {1..500}; do cat /etc/passwd >> $MOUNTDIR/testfile; if [ $? -ne 0 ]; then flag=1; break; fi; done -TEST [ $flag -eq 0 ] -TEST rm -rf $GEOREPDIR - -TEST umount $MOUNTDIR -TEST rm -rf $MOUNTDIR - -cleanup; diff --git a/tests/bugs/bug-874498.t b/tests/bugs/bug-874498.t index 35430f1ad..0b5991011 100644 --- a/tests/bugs/bug-874498.t +++ b/tests/bugs/bug-874498.t @@ -1,5 +1,7 @@ #!/bin/bash . $(dirname $0)/../include.rc +. $(dirname $0)/../afr.rc + cleanup; TEST glusterd @@ -13,11 +15,11 @@ TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0; B0_hiphenated=`echo $B0 | tr '/' '-'` kill -9 `cat /var/lib/glusterd/vols/$V0/run/$H0$B0_hiphenated-brick1.pid` ; - echo "GLUSTER FILE SYSTEM" > $M0/FILE1 echo "GLUSTER FILE SYSTEM" > $M0/FILE2 -FILEN=$B0"/brick2/.glusterfs/indices/xattrop/" +FILEN=$B0"/brick2" +XATTROP=$FILEN/.glusterfs/indices/xattrop function get_gfid() { @@ -34,7 +36,7 @@ GFID_FILE2=`get_gfid $B0/brick2/FILE2` count=0 -for i in `ls $FILEN` +for i in `ls $XATTROP` do if [ "$i" == "$GFID_ROOT" ] || [ "$i" == "$GFID_FILE1" ] || [ "$i" == "$GFID_FILE2" ] then @@ -47,18 +49,12 @@ EXPECT "3" echo $count TEST $CLI volume start $V0 force sleep 5 -TEST $CLI volume heal $V0 full -sleep 2 +TEST $CLI volume heal $V0 -val1=0 -##count the number of entries after self heal -for g in `ls $FILEN` -do -val1=$(( val1 + 1 )) -done ##Expected number of entries are 0 in the .glusterfs/indices/xattrop directory -EXPECT '0' echo $val1 +EXPECT_WITHIN 60 '0' count_sh_entries $FILEN; + TEST $CLI volume stop $V0; TEST $CLI volume delete $V0; diff --git a/tests/bugs/bug-877293.t b/tests/bugs/bug-877293.t new file mode 100755 index 000000000..774c2a0cc --- /dev/null +++ b/tests/bugs/bug-877293.t @@ -0,0 +1,41 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +TEST glusterd +TEST pidof glusterd + +## Start and create a replicated volume +mkdir -p ${B0}/${V0}-0 +mkdir -p ${B0}/${V0}-1 +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}-{0,1} + +TEST $CLI volume set $V0 indexing on + +TEST $CLI volume start $V0; + +## Mount native +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 + +## Mount client-pid=-1 +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 --client-pid=-1 $M1 + +TEST touch $M0 + +vol_uuid=`getfattr -n trusted.glusterfs.volume-mark -ehex $M1 | sed -n 's/^trusted.glusterfs.volume-mark=0x//p' | cut -b5-36 | sed 's/\([a-f0-9]\{8\}\)\([a-f0-9]\{4\}\)\([a-f0-9]\{4\}\)\([a-f0-9]\{4\}\)/\1-\2-\3-\4-/'` +xtime=trusted.glusterfs.$vol_uuid.xtime + +TEST "getfattr -n $xtime $M1 | grep -q ${xtime}=" + +TEST kill_brick $V0 $H0 $B0/${V0}-0 + +TEST "getfattr -n $xtime $M1 | grep -q ${xtime}=" + +TEST umount $M0 +TEST umount $M1 + +TEST $CLI volume stop $V0; +TEST $CLI volume delete $V0; + +cleanup diff --git a/tests/bugs/bug-878873.t b/tests/bugs/bug-878004.t index efdcaca89..5bee4c62f 100644 --- a/tests/bugs/bug-878873.t +++ b/tests/bugs/bug-878004.t @@ -19,11 +19,11 @@ function brick_count() TEST $CLI volume start $V0 -TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 start; -TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 commit; +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2; EXPECT '2' brick_count $V0 TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}3; EXPECT '1' brick_count $V0 +cleanup; diff --git a/tests/bugs/bug-884455.t b/tests/bugs/bug-884455.t index c193cd8aa..3b3a2241e 100755 --- a/tests/bugs/bug-884455.t +++ b/tests/bugs/bug-884455.t @@ -66,7 +66,7 @@ TEST ls -l $M0 2>/dev/null; TEST $CLI volume rebalance $V0 start force -EXPECT_WITHIN 15 "0" rebalance_completed +EXPECT_WITHIN 30 "0" rebalance_completed ## check for layout overlaps. EXPECT "0" get_layout $B0/${V0}0 $B0/${V0}1 $B0/${V0}2 @@ -80,3 +80,5 @@ 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/bug-884597.t b/tests/bugs/bug-884597.t index 0d3495a65..8eb1f330b 100755 --- a/tests/bugs/bug-884597.t +++ b/tests/bugs/bug-884597.t @@ -107,3 +107,46 @@ BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/link$i`; BACKEND_GID=`stat --printf=%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 + +while [ $i -ne 0 ] +do + su -c "mv $M0/user_file$i $M0/user_file$(( $i+1 ))" ABC + let i++ + file_has_linkfile user_file$i + has_link=$? + if [ $has_link -eq 2 ] + then + break; + fi +done + +## 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 --printf=%u $B0/${V0}$cached/user_file$i`; +BACKEND_GID=`stat --printf=%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/bug-886998.t b/tests/bugs/bug-886998.t new file mode 100644 index 000000000..7a905a113 --- /dev/null +++ b/tests/bugs/bug-886998.t @@ -0,0 +1,52 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +# This tests that the replicate trash directory(.landfill) has following +# properties. +# Note: This is to have backward compatibility with 3.3 glusterfs +# In the latest releases this dir is present inside .glusterfs of brick. +# 1) lookup of trash dir fails +# 2) readdir does not show this directory +# 3) Self-heal does not do any self-heal of these directories. +gfid1="0xc2e75dde97f346e7842d1076a8e699f8" +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --direct-io-mode=enable + +TEST mkdir $B0/${V0}1/.landfill +TEST setfattr -n trusted.gfid -v $gfid1 $B0/${V0}1/.landfill +TEST mkdir $B0/${V0}0/.landfill +TEST setfattr -n trusted.gfid -v $gfid1 $B0/${V0}0/.landfill + +TEST ! stat $M0/.landfill +EXPECT "" echo $(ls -a $M0 | grep ".landfill") + +TEST rmdir $B0/${V0}0/.landfill +#Force a conservative merge and it should not create .landfill +TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000000 $B0/${V0}0/ +TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/${V0}0/ + +TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/${V0}1/ +TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000000 $B0/${V0}1/ + +EXPECT "" echo $(ls -a $M0 | grep ".landfill") +TEST ! stat $B0/${V0}0/.landfill +TEST stat $B0/${V0}1/.landfill + +#TEST that the dir is not deleted even when xattrs suggest to delete +TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000000 $B0/${V0}0/ +TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000001 $B0/${V0}0/ + +TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000000 $B0/${V0}1/ +TEST setfattr -n trusted.afr.$V0-client-1 -v 0x000000000000000000000000 $B0/${V0}1/ + +EXPECT "" echo $(ls -a $M0 | grep ".landfill") +TEST ! stat $B0/${V0}0/.landfill +TEST stat $B0/${V0}1/.landfill +cleanup; diff --git a/tests/bugs/bug-887098-gmount-crash.t b/tests/bugs/bug-887098-gmount-crash.t index 54e52d4dc..1998b4062 100644 --- a/tests/bugs/bug-887098-gmount-crash.t +++ b/tests/bugs/bug-887098-gmount-crash.t @@ -18,7 +18,7 @@ EXPECT 'Created' volinfo_field $V0 'Status'; function pidgrep() { - ps ax | grep "$1" | awk '{print $1}' | head -1 + ps ax | grep "$1" | grep -v grep | awk '{print $1}' | head -1 } @@ -27,7 +27,7 @@ TEST $CLI volume start $V0; EXPECT 'Started' volinfo_field $V0 'Status'; TEST glusterfs -s $H0 --volfile-id=$V0 --acl $M0 -MOUNT_PID=`ps ax |grep "glusterfs -s $H0 --volfile-id=$V0 --acl $M0" | awk '{print $1}' | head -1` +MOUNT_PID=`ps ax |grep "glusterfs -s $H0 --volfile-id=$V0 --acl $M0" | grep -v grep | awk '{print $1}' | head -1` for i in {1..25}; do diff --git a/tests/bugs/bug-887145.t b/tests/bugs/bug-887145.t index 8e5f03900..e2013e50b 100755 --- a/tests/bugs/bug-887145.t +++ b/tests/bugs/bug-887145.t @@ -1,6 +1,7 @@ #!/bin/bash . $(dirname $0)/../include.rc +. $(dirname $0)/../nfs.rc cleanup; @@ -14,9 +15,8 @@ sleep 2; ## Mount FUSE with caching disabled TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; -sleep 2; +EXPECT_WITHIN 20 "1" is_nfs_export_available; -TEST mount -t nfs -o vers=3,nolock $H0:/$V0 $N0; useradd tmp_user 2>/dev/null 1>/dev/null; mkdir $M0/dir; @@ -25,6 +25,8 @@ cp /etc/passwd $M0/; cp $M0/passwd $M0/file; chmod 600 $M0/file; +TEST mount -t nfs -o vers=3,nolock $H0:/$V0 $N0; + chown -R nfsnobody:nfsnobody $M0/dir; chown -R tmp_user:tmp_user $M0/other; @@ -32,6 +34,8 @@ TEST $CLI volume set $V0 server.root-squash on; sleep 2; +EXPECT_WITHIN 20 "1" is_nfs_export_available; + # create files and directories in the root of the glusterfs and nfs mount # which is owned by root and hence the right behavior is getting EACCESS # as the fops are executed as nfsnobody. diff --git a/tests/bugs/bug-888752.t b/tests/bugs/bug-888752.t new file mode 100644 index 000000000..56d3f9ffb --- /dev/null +++ b/tests/bugs/bug-888752.t @@ -0,0 +1,24 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../cluster.rc + +# Check if xml output is generated correctly for volume status for a single brick +# present on another peer and no async tasks are running. + +function get_peer_count { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} +cleanup + +TEST launch_cluster 2; +TEST $CLI_1 peer probe $H2; +EXPECT_WITHIN 5 1 get_peer_count +TEST $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 +TEST $CLI_1 volume start $V0 + +TEST $CLI_1 volume status $V0 $H2:$B2/$V0 --xml + +TEST $CLI_1 volume stop $V0 + +cleanup diff --git a/tests/bugs/bug-893378.t b/tests/bugs/bug-893378.t index 470589f53..fd8b9a7ce 100755 --- a/tests/bugs/bug-893378.t +++ b/tests/bugs/bug-893378.t @@ -69,3 +69,5 @@ ls -l $M0/2 2>/dev/null dd if=/dev/zero of=$M0/2 bs=1 count=1 conv=excl 2>/dev/null EXPECT "1" echo $? + +cleanup; diff --git a/tests/bugs/bug-895235.t b/tests/bugs/bug-895235.t index b0a92c92f..0764b50d4 100644 --- a/tests/bugs/bug-895235.t +++ b/tests/bugs/bug-895235.t @@ -8,6 +8,7 @@ TEST glusterd TEST pidof glusterd TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 ensure-durability off TEST $CLI volume set $V0 performance.write-behind off TEST $CLI volume set $V0 cluster.eager-lock off TEST $CLI volume start $V0 diff --git a/tests/bugs/bug-902610.t b/tests/bugs/bug-902610.t index f5eb6be02..00ba03adf 100755 --- a/tests/bugs/bug-902610.t +++ b/tests/bugs/bug-902610.t @@ -56,3 +56,4 @@ mkdir $M0/dir1 2>/dev/null get_layout $B0/${V0}0/dir1 $B0/${V0}1/dir1 EXPECT "0" echo $? +cleanup; diff --git a/tests/bugs/bug-904065.t b/tests/bugs/bug-904065.t new file mode 100755 index 000000000..505854d9b --- /dev/null +++ b/tests/bugs/bug-904065.t @@ -0,0 +1,90 @@ +#!/bin/bash +# +# This test does not use 'showmount' from the nfs-utils package, it would +# require setting up a portmapper (either rpcbind or portmap, depending on the +# Linux distribution used for testing). The persistancy of the rmtab should not +# affect the current showmount outputs, so existing regression tests should be +# sufficient. +# + +# count the lines of a file, return 0 if the file does not exist +function count_lines() +{ + if [ -e "$1" ] + then + wc -l < $1 + else + echo 0 + fi +} + + +. $(dirname $0)/../include.rc +. $(dirname $0)/../nfs.rc + +cleanup + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/brick1 +EXPECT 'Created' volinfo_field $V0 'Status' + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status' + +# glusterfs/nfs needs some time to start up in the background +EXPECT_WITHIN 20 1 is_nfs_export_available + +# before mounting the rmtab should be empty +EXPECT '0' count_lines /var/lib/glusterd/nfs/rmtab + +TEST mount -t nfs -o vers=3,nolock $H0:/$V0 $N0 +# the output would looks similar to: +# +# hostname-0=172.31.122.104 +# mountpoint-0=/ufo +# +EXPECT '2' count_lines /var/lib/glusterd/nfs/rmtab + +# duplicate mounts should not be recorded (client could have crashed) +TEST mount -t nfs -o vers=3,nolock $H0:/$V0 $N1 +EXPECT '2' count_lines /var/lib/glusterd/nfs/rmtab + +# removing a mount should (even if there are two) should remove the entry +TEST umount $N1 +EXPECT '0' count_lines /var/lib/glusterd/nfs/rmtab + +# unmounting the other mount should work flawlessly +TEST umount $N0 +EXPECT '0' count_lines /var/lib/glusterd/nfs/rmtab + +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 --volfile-server=$H0 --volfile-id=$V0 $M0 + +# we'll create a fake rmtab here, similar to how an other storage server would do +# using an invalid IP address to prevent (unlikely) collisions on the test-machine +cat << EOF > $M0/rmtab +hostname-0=127.0.0.256 +mountpoint-0=/ufo +EOF +EXPECT '2' count_lines $M0/rmtab + +# reconfigure merges the rmtab with the one on the volume +TEST gluster volume set $V0 nfs.mount-rmtab $M0/rmtab + +# glusterfs/nfs needs some time to restart +EXPECT_WITHIN 20 1 is_nfs_export_available + +# a new mount should be added to the rmtab, not overwrite exiting ones +TEST mount -t nfs -o vers=3,nolock $H0:/$V0 $N0 +EXPECT '4' count_lines $M0/rmtab + +TEST umount $N0 +EXPECT '2' count_lines $M0/rmtab + +# TODO: nfs/reconfigure() is never called and is therefor disabled. When the +# NFS-server supports reloading and does not get restarted anymore, we should +# add a test that includes the merging of entries in the old rmtab with the new +# rmtab. + +cleanup diff --git a/tests/bugs/bug-904300.t b/tests/bugs/bug-904300.t new file mode 100755 index 000000000..4276ee229 --- /dev/null +++ b/tests/bugs/bug-904300.t @@ -0,0 +1,61 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../nfs.rc + +cleanup; + +# 1-8 +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0; +TEST $CLI volume start $V0 +EXPECT_WITHIN 20 1 is_nfs_export_available + +TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0 $N0 +TEST mkdir $N0/dir1 +TEST umount $N0 + +# +# Case 1: Allow "dir1" to be mounted only from 127.0.0.1 +# 9-12 +TEST $CLI volume set $V0 export-dir \""/dir1(127.0.0.1)"\" +EXPECT_WITHIN 20 2 is_nfs_export_available + +TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0/dir1 $N0 +TEST umount $N0 + +# +# Case 2: Allow "dir1" to be mounted only from 8.8.8.8. This is +# a negative test case therefore the mount should fail. +# 13-16 +TEST $CLI volume set $V0 export-dir \""/dir1(8.8.8.8)"\" +EXPECT_WITHIN 20 2 is_nfs_export_available + +TEST ! mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0/dir1 $N0 +TEST ! umount $N0 + + +# Case 3: Variation of test case1. Here we are checking with hostname +# instead of ip address. +# 17-20 +TEST $CLI volume set $V0 export-dir \""/dir1($H0)"\" +EXPECT_WITHIN 20 2 is_nfs_export_available + +TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0/dir1 $N0 +TEST umount $N0 + +# Case 4: Variation of test case1. Here we are checking with IP range +# 21-24 +TEST $CLI volume set $V0 export-dir \""/dir1(127.0.0.0/24)"\" +EXPECT_WITHIN 20 2 is_nfs_export_available + +TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0/dir1 $N0 +TEST umount $N0 + +## Finish up +TEST $CLI volume stop $V0; +TEST $CLI volume delete $V0; + +cleanup; diff --git a/tests/bugs/bug-905864.t b/tests/bugs/bug-905864.t index 688723e14..44bb469f2 100644 --- a/tests/bugs/bug-905864.t +++ b/tests/bugs/bug-905864.t @@ -10,7 +10,7 @@ TEST glusterd; TEST pidof glusterd; TEST $CLI volume info; -TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4}; TEST $CLI volume start $V0; TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; diff --git a/tests/bugs/bug-907072.t b/tests/bugs/bug-907072.t new file mode 100755 index 000000000..49b477767 --- /dev/null +++ b/tests/bugs/bug-907072.t @@ -0,0 +1,46 @@ +#!/bin/bash + +. $(dirname $0)/../include.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,2,3}; +TEST $CLI volume start $V0; + +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/test; + +OLD_LAYOUT0=`get_layout $B0/${V0}0/test`; +OLD_LAYOUT1=`get_layout $B0/${V0}1/test`; +OLD_LAYOUT2=`get_layout $B0/${V0}2/test`; +OLD_LAYOUT3=`get_layout $B0/${V0}3/test`; + +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; + +TEST umount $M0; +TEST glusterfs -s $H0 --volfile-id $V0 $M0; +TEST stat $M0/test; + +NEW_LAYOUT0=`get_layout $B0/${V0}0/test`; +NEW_LAYOUT1=`get_layout $B0/${V0}1/test`; +NEW_LAYOUT2=`get_layout $B0/${V0}2/test`; +NEW_LAYOUT3=`get_layout $B0/${V0}3/test`; + +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/bug-908146.t b/tests/bugs/bug-908146.t index 6ec0334ea..87b456e6e 100755 --- a/tests/bugs/bug-908146.t +++ b/tests/bugs/bug-908146.t @@ -34,6 +34,6 @@ exec 4>&- EXPECT "1" get_fd_count $V0 $H0 $B0/${V0}0 a exec 5>&- -EXPECT "" get_fd_count $V0 $H0 $B0/${V0}0 a +EXPECT "0" get_fd_count $V0 $H0 $B0/${V0}0 a cleanup diff --git a/tests/bugs/bug-915554.t b/tests/bugs/bug-915554.t index a811c18f6..beb669f8c 100755 --- a/tests/bugs/bug-915554.t +++ b/tests/bugs/bug-915554.t @@ -60,7 +60,7 @@ TEST $CLI volume rebalance $V0 start force # check if rebalance has completed for upto 15 secs -EXPECT_WITHIN 15 "0" rebalance_completed +EXPECT_WITHIN 30 "0" rebalance_completed # validate the file size after the migration SIZE2=`stat -c %s $M0/$i` diff --git a/tests/bugs/bug-916226.t b/tests/bugs/bug-916226.t index 1a4870f2e..2abfa1fc6 100644 --- a/tests/bugs/bug-916226.t +++ b/tests/bugs/bug-916226.t @@ -21,6 +21,6 @@ TEST touch $M0/dir{1..10}/files{1..10}; TEST $CLI volume add-brick $V0 $H0:$B0/${V0}4 $H0:/$B0/${V0}5 TEST $CLI volume rebalance $V0 start force -EXPECT_WITHIN 60 "success:" rebalance_status_field $V0 +EXPECT_WITHIN 60 "completed" rebalance_status_field $V0 cleanup; diff --git a/tests/bugs/bug-921072.t b/tests/bugs/bug-921072.t index c7fff75f1..e101d5b46 100755 --- a/tests/bugs/bug-921072.t +++ b/tests/bugs/bug-921072.t @@ -1,60 +1,43 @@ #!/bin/bash . $(dirname $0)/../include.rc +. $(dirname $0)/../nfs.rc cleanup; -# sleeps till the portmap registration of nfs services is done -# NOTE: may take some time for nfs to export all volumes, hence, -# showmount -e succeeding does NOT mean all volumes are available -# for mount. In this case, its a single single-brick volume, -# so no problem. -sleep_till_nfs_awakens () -{ - while true - do - showmount -e 0 > /dev/null 2>&1; - if [ $? -eq 0 ]; then - return; - else - sleep 1; - fi - done -} - #1 TEST glusterd TEST pidof glusterd TEST $CLI volume create $V0 $H0:$B0/$V0 TEST $CLI volume start $V0 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST mount -t nfs -o vers=3,nolock,soft,intr $H0:/$V0 $N0 TEST umount $N0 # based on ip addresses (1-4) # case 1: allow only localhost ip TEST $CLI volume set $V0 nfs.rpc-auth-allow 127.0.0.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST umount $N0 # case 2: allow only non-localhost ip TEST $CLI volume set $V0 nfs.rpc-auth-allow 192.168.1.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available #11 TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST $CLI volume reset --mode=script $V0 # case 3: reject only localhost ip TEST $CLI volume set $V0 nfs.rpc-auth-reject 127.0.0.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 # case 4: reject only non-localhost ip TEST $CLI volume set $V0 nfs.rpc-auth-reject 192.168.1.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST umount $N0 @@ -65,21 +48,21 @@ TEST umount $N0 # CASES WITH NFS.ADDR-NAMELOOKUP ON (5-12) TEST $CLI volume reset --mode=script $V0 TEST $CLI volume set $V0 nfs.addr-namelookup on -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available #20 TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST umount $N0 # case 5: allow only localhost TEST $CLI volume set $V0 nfs.rpc-auth-allow localhost -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST umount $N0 # case 6: allow only somehost TEST $CLI volume set $V0 nfs.rpc-auth-allow somehost -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 @@ -87,13 +70,13 @@ TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST $CLI volume reset --mode=script $V0 TEST $CLI volume set $V0 nfs.addr-namelookup on TEST $CLI volume set $V0 nfs.rpc-auth-reject localhost -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available #30 TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 # case 8: reject only somehost TEST $CLI volume set $V0 nfs.rpc-auth-reject somehost -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST umount $N0 @@ -103,14 +86,14 @@ TEST umount $N0 TEST $CLI volume reset --mode=script $V0 TEST $CLI volume set $V0 nfs.addr-namelookup on TEST $CLI volume set $V0 nfs.rpc-auth-allow 127.0.0.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST umount $N0 # case 10: allow a non-localhost ip TEST $CLI volume set $V0 nfs.rpc-auth-allow 192.168.1.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available #40 TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 @@ -118,13 +101,13 @@ TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST $CLI volume reset --mode=script $V0 TEST $CLI volume set $V0 nfs.addr-namelookup on TEST $CLI volume set $V0 nfs.rpc-auth-reject 127.0.0.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST ! mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 # case 12: reject only non-localhost ip TEST $CLI volume set $V0 nfs.rpc-auth-reject 192.168.1.1 -sleep_till_nfs_awakens +EXPECT_WITHIN 20 1 is_nfs_export_available TEST mount -t nfs -o vers=3,nolock,soft,intr localhost:/$V0 $N0 TEST umount $N0 diff --git a/tests/bugs/bug-921231.t b/tests/bugs/bug-921231.t new file mode 100644 index 000000000..db9cf3b6f --- /dev/null +++ b/tests/bugs/bug-921231.t @@ -0,0 +1,31 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +# This test writes to same file with 2 fds and tests that eager-lock is not +# causing extra delay because of post-op-delay-secs +cleanup; + +function write_to_file { + dd of=$M0/1 if=/dev/zero bs=1M count=128 oflag=append 2>&1 >/dev/null +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume set $V0 eager-lock on +TEST $CLI volume set $V0 post-op-delay-secs 3 +TEST $CLI volume set $V0 client-log-level DEBUG +TEST $CLI volume start $V0 +TEST $CLI volume profile $V0 start +TEST $CLI volume set $V0 ensure-durability off +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 +write_to_file & +write_to_file & +wait +#Test if the MAX [F]INODELK fop latency is of the order of seconds. +inodelk_max_latency=$($CLI volume profile $V0 info | grep INODELK | awk 'BEGIN {max = 0} {if ($6 > max) max=$6;} END {print max}' | cut -d. -f 1 | egrep "[0-9]{7,}") +TEST [ -z $inodelk_max_latency ] + +cleanup; diff --git a/tests/bugs/bug-921408.t b/tests/bugs/bug-921408.t new file mode 100755 index 000000000..ef2b4fb21 --- /dev/null +++ b/tests/bugs/bug-921408.t @@ -0,0 +1,89 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../fileio.rc +. $(dirname $0)/../dht.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 15 + if [ $? -eq 1 ] + then + break + fi + NEW_LAYOUT=`get_layout $B0/${V0}0` + 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` + +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; + +TEST umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup diff --git a/tests/bugs/bug-948686.t b/tests/bugs/bug-948686.t new file mode 100644 index 000000000..db9c198a9 --- /dev/null +++ b/tests/bugs/bug-948686.t @@ -0,0 +1,46 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../cluster.rc + +function check_peers { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} +cleanup; +#setup cluster and test volume +TEST launch_cluster 3; # start 3-node virtual cluster +TEST $CLI_1 peer probe $H2; # peer probe server 2 from server 1 cli +TEST $CLI_1 peer probe $H3; # peer probe server 3 from server 1 cli + +EXPECT_WITHIN 20 2 check_peers; + +TEST $CLI_1 volume create $V0 replica 2 $H1:$B1/$V0 $H1:$B1/${V0}_1 $H2:$B2/$V0 $H3:$B3/$V0 +TEST $CLI_1 volume start $V0 +TEST glusterfs --volfile-server=$H1 --volfile-id=$V0 $M0 + +#kill a node +TEST kill_node 3 + +#modify volume config to see change in volume-sync +TEST $CLI_1 volume set $V0 write-behind off +#add some files to the volume to see effect of volume-heal cmd +TEST touch $M0/{1..100}; +TEST $CLI_1 volume stop $V0; +TEST $glusterd_3; +sleep 3; +TEST $CLI_3 volume start $V0; +TEST $CLI_2 volume stop $V0; +TEST $CLI_2 volume delete $V0; + +cleanup; + +TEST glusterd; +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume start $V0 +pkill glusterd; +pkill glusterfsd; +TEST glusterd +TEST $CLI volume status $V0 + +cleanup; diff --git a/tests/bugs/bug-948729/bug-948729-force.t b/tests/bugs/bug-948729/bug-948729-force.t new file mode 100644 index 000000000..d14e94061 --- /dev/null +++ b/tests/bugs/bug-948729/bug-948729-force.t @@ -0,0 +1,84 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../cluster.rc + +function check_peers { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} + +cleanup; +uuid1=`uuidgen`; +uuid2=`uuidgen`; +uuid3=`uuidgen`; + +V1=patchy1 +V2=patchy2 + +TEST launch_cluster 2; + +TEST $CLI_1 peer probe $H2; + +EXPECT_WITHIN 20 1 check_peers; + +B3=/d/backends/3 +B4=/d/backends/4 +B5=/d/backends/5 +B6=/d/backends/6 + +mkdir -p $B3 $B4 $B5 $B6 + +TEST truncate -s 16M $B1/brick1 +TEST truncate -s 16M $B2/brick2 +TEST truncate -s 16M $B3/brick3 +TEST truncate -s 16M $B4/brick4 +TEST truncate -s 16M $B5/brick5 +TEST truncate -s 16M $B6/brick6 + +TEST LD1=`losetup --find --show $B1/brick1` +TEST mkfs.xfs $LD1 +TEST LD2=`losetup --find --show $B2/brick2` +TEST mkfs.xfs $LD2 +TEST LD3=`losetup --find --show $B3/brick3` +TEST mkfs.xfs $LD3 +TEST LD4=`losetup --find --show $B4/brick4` +TEST mkfs.xfs $LD4 +TEST LD5=`losetup --find --show $B5/brick5` +TEST mkfs.xfs $LD5 +TEST LD6=`losetup --find --show $B6/brick6` +TEST mkfs.xfs $LD6 + +mkdir -p $B1/$V0 $B2/$V0 $B3/$V0 $B4/$V0 $B5/$V0 $B6/$V0 + +TEST mount -t xfs $LD1 $B1/$V0 +TEST mount -t xfs $LD2 $B2/$V0 +TEST mount -t xfs $LD3 $B3/$V0 +TEST mount -t xfs $LD4 $B4/$V0 +TEST mount -t xfs $LD5 $B5/$V0 +TEST mount -t xfs $LD6 $B6/$V0 + +#Case 0: Parent directory of the brick is absent +TEST ! $CLI1 volume create $V0 $H1:$B1/$V0/nonexistent/b1 $H2:$B2/$V0/nonexistent/b2 force + +#Case 1: File system root is being used as brick directory +TEST $CLI1 volume create $V0 $H1:$B5/$V0 $H2:$B6/$V0 force + +#Case 2: Brick directory contains only one component +TEST $CLI1 volume create $V1 $H1:/$uuid1 $H2:/$uuid2 force + +#Case 3: Sub-directories of the backend FS being used as brick directory +TEST $CLI1 volume create $V2 $H1:$B1/$V0/brick1 $H2:$B2/$V0/brick2 force + +#add-brick tests +TEST ! $CLI1 volume add-brick $V0 $H1:$B3/$V0/nonexistent/brick3 force +TEST $CLI1 volume add-brick $V0 $H1:$B3/$V0 force +TEST $CLI1 volume add-brick $V1 $H1:/$uuid3 force +TEST $CLI1 volume add-brick $V2 $H1:$B4/$V0/brick3 force + +#####replace-brick tests +#FIX-ME: replace-brick does not work with the newly introduced cluster test +#####framework + +rmdir /$uuid1 /$uuid2 /$uuid3; + +cleanup; diff --git a/tests/bugs/bug-948729/bug-948729-mode-script.t b/tests/bugs/bug-948729/bug-948729-mode-script.t new file mode 100644 index 000000000..541ca897d --- /dev/null +++ b/tests/bugs/bug-948729/bug-948729-mode-script.t @@ -0,0 +1,85 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../cluster.rc + +function check_peers { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} + +cleanup; + +uuid1=`uuidgen`; +uuid2=`uuidgen`; +uuid3=`uuidgen`; + +V1=patchy1 +V2=patchy2 +V3=patchy3 + +TEST launch_cluster 2; + +TEST $CLI_1 peer probe $H2; + +EXPECT_WITHIN 20 1 check_peers; + +B3=/d/backends/3 +B4=/d/backends/4 +B5=/d/backends/5 +B6=/d/backends/6 +mkdir -p $B3 $B4 $B5 $B6 + +TEST truncate -s 16M $B1/brick1 +TEST truncate -s 16M $B2/brick2 +TEST truncate -s 16M $B3/brick3 +TEST truncate -s 16M $B4/brick4 +TEST truncate -s 16M $B5/brick5 +TEST truncate -s 16M $B6/brick6 + +TEST LD1=`losetup --find --show $B1/brick1` +TEST mkfs.xfs $LD1 +TEST LD2=`losetup --find --show $B2/brick2` +TEST mkfs.xfs $LD2 +TEST LD3=`losetup --find --show $B3/brick3` +TEST mkfs.xfs $LD3 +TEST LD4=`losetup --find --show $B4/brick4` +TEST mkfs.xfs $LD4 +TEST LD5=`losetup --find --show $B5/brick5` +TEST mkfs.xfs $LD5 +TEST LD6=`losetup --find --show $B6/brick6` +TEST mkfs.xfs $LD6 + +mkdir -p $B1/$V0 $B2/$V0 $B3/$V0 $B4/$V0 $B5/$V0 $B6/$V0 + +TEST mount -t xfs $LD1 $B1/$V0 +TEST mount -t xfs $LD2 $B2/$V0 +TEST mount -t xfs $LD3 $B3/$V0 +TEST mount -t xfs $LD4 $B4/$V0 +TEST mount -t xfs $LD5 $B5/$V0 +TEST mount -t xfs $LD6 $B6/$V0 + +#Case 0: Parent directory of the brick is absent +TEST ! $CLI_1 volume create $V0 $H1:$B1/$V0/nonexistent/b1 $H2:$B2/$V0/nonexistent/b2 + +#Case 1: File system root being used as brick directory +TEST $CLI_1 volume create $V0 $H1:$B5/$V0 $H2:$B6/$V0 + +#Case 2: Brick directory contains only one component +TEST $CLI_1 volume create $V1 $H1:/$uuid1 $H2:/$uuid2 + +#Case 3: Sub-directories of the backend FS being used as brick directory +TEST $CLI_1 volume create $V2 $H1:$B1/$V0/brick1 $H2:$B2/$V0/brick2 + +#add-brick tests +TEST ! $CLI_1 volume add-brick $V0 $H1:$B3/$V0/nonexistent/brick3 +TEST $CLI_1 volume add-brick $V0 $H1:$B3/$V0 +TEST $CLI_1 volume add-brick $V1 $H1:/$uuid3 +TEST $CLI_1 volume add-brick $V2 $H1:$B4/$V0/brick3 + +#####replace-brick tests +#FIX-ME : replace-brick does not currently work in the newly introduced +#####cluster test framework + +rmdir /$uuid1 /$uuid2 /$uuid3 + +cleanup; diff --git a/tests/bugs/bug-948729/bug-948729.t b/tests/bugs/bug-948729/bug-948729.t new file mode 100644 index 000000000..f94db1ea0 --- /dev/null +++ b/tests/bugs/bug-948729/bug-948729.t @@ -0,0 +1,67 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../cluster.rc + +function check_peers { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} + +cleanup; + +uuid1=`uuidgen`; +uuid2=`uuidgen`; +uuid3=`uuidgen`; + +TEST launch_cluster 2; + +TEST $CLI_1 peer probe $H2; + +EXPECT_WITHIN 20 1 check_peers; + +B3=/d/backends/3 + +mkdir -p $B3 + +TEST truncate -s 16M $B1/brick1 +TEST truncate -s 16M $B2/brick2 +TEST truncate -s 16M $B3/brick3 + +TEST LD1=`losetup --find --show $B1/brick1` +TEST mkfs.xfs $LD1 +TEST LD2=`losetup --find --show $B2/brick2` +TEST mkfs.xfs $LD2 +TEST LD3=`losetup --find --show $B3/brick3` +TEST mkfs.xfs $LD3 + +mkdir -p $B1/$V0 $B2/$V0 $B3/$V0 + +TEST mount -t xfs $LD1 $B1/$V0 +TEST mount -t xfs $LD2 $B2/$V0 +TEST mount -t xfs $LD3 $B3/$V0 + +#Tests without --mode=script option +cli1=$(echo $CLI1 | sed 's/ --mode=script//') +#Case 0: Parent directory of the brick is absent +TEST ! $cli1 volume create $V0 $H1:$B1/$V0/nonexistent/b1 $H2:$B2/$V0/nonexistent/b2 + +#Case 1: File system root being used as brick directory +TEST ! $cli1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 + +#Case 2: Brick directory contains only one component +TEST ! $cli1 volume create $V0 $H1:/$uuid1 $H2:/$uuid2 + +#Case 3: Sub-directories of the backend FS being used as brick directory +TEST $cli1 volume create $V0 $H1:$B1/$V0/brick1 $H2:$B2/$V0/brick2 + +#add-brick tests +TEST ! $cli1 volume add-brick $V0 $H1:$B3/$V0/nonexistent/b3 +TEST ! $cli1 volume add-brick $V0 $H1:$B3/$V0 +TEST ! $cli1 volume add-brick $V0 $H1:/$uuid3 +TEST $cli1 volume add-brick $V0 $H1:$B3/$V0/brick3 + +#####replace-brick tests +#FIX-ME: Replace-brick does not work currently in the newly introduced cluster +#####test framework. + +cleanup; diff --git a/tests/bugs/bug-949242.t b/tests/bugs/bug-949242.t new file mode 100644 index 000000000..717084673 --- /dev/null +++ b/tests/bugs/bug-949242.t @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Bug 949242 - Test basic fallocate functionality. +# +# Run several commands to verify basic fallocate functionality. We verify that +# fallocate creates and allocates blocks to a file. We also verify that the keep +# size option does not modify the file size. +### + +. $(dirname $0)/../include.rc +. $(dirname $0)/../fallocate.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2,3,4} +TEST $CLI volume start $V0 + +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + +# check for fallocate support before continuing the test +require_fallocate -l 1m -n $M0/file && rm -f $M0/file + +# fallocate a file and verify blocks are allocated +TEST fallocate -l 1m $M0/file +blksz=`stat --printf=%b $M0/file` +nblks=`stat --printf=%B $M0/file` +TEST [ $(($blksz * $nblks)) -eq 1048576 ] + +TEST unlink $M0/file + +# truncate a file to a fixed size, fallocate and verify that the size does not +# change +TEST truncate --size=1m $M0/file +TEST fallocate -l 2m -n $M0/file +blksz=`stat --printf=%b $M0/file` +nblks=`stat --printf=%B $M0/file` +sz=`stat --printf=%s $M0/file` +TEST [ $sz -eq 1048576 ] +# Note that gluster currently incorporates a hack to limit the number of blocks +# reported as allocated to the file by the file size. We have allocated beyond the +# file size here. Just check for non-zero allocation to avoid setting a land mine +# for if/when that behavior might change. +TEST [ ! $(($blksz * $nblks)) -eq 0 ] + +TEST unlink $M0/file + +TEST umount $M0 + +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup; diff --git a/tests/bugs/bug-949298.t b/tests/bugs/bug-949298.t new file mode 100644 index 000000000..1394127ec --- /dev/null +++ b/tests/bugs/bug-949298.t @@ -0,0 +1,12 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; +TEST glusterd +TEST pidof glusterd + +TEST $CLI --xml volume info $V0 + +cleanup; diff --git a/tests/bugs/bug-949930.t b/tests/bugs/bug-949930.t new file mode 100644 index 000000000..4a738befa --- /dev/null +++ b/tests/bugs/bug-949930.t @@ -0,0 +1,27 @@ +#!/bin/bash +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +V1=patchy2 + +cleanup; + +TEST glusterd; +TEST pidof glusterd; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; +TEST $CLI volume start $V0; + +TEST $CLI volume create $V1 $H0:$B0/${V1}{1,2}; +TEST $CLI volume start $V1; + +TEST ! $CLI volume set $V0 performance.nfs.read-ahead blah +EXPECT '' volume_option $V0 performance.nfs.read-ahead + +TEST $CLI volume set $V0 performance.nfs.read-ahead on +EXPECT "on" volume_option $V0 performance.nfs.read-ahead + +EXPECT '' volume_option $V1 performance.nfs.read-ahead + +cleanup; + diff --git a/tests/bugs/bug-955588.t b/tests/bugs/bug-955588.t new file mode 100755 index 000000000..3f0361167 --- /dev/null +++ b/tests/bugs/bug-955588.t @@ -0,0 +1,27 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; +TEST glusterd +TEST pidof glusterd + +function get_brick_host_uuid() +{ + local vol=$1; + local uuid_regex='[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}' + local host_uuid_list=$($CLI volume info $vol --xml | grep "brick.uuid" | grep -o -E "$uuid_regex"); + + echo $host_uuid_list | awk '{print $1}' +} + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} + +uuid=`grep UUID /var/lib/glusterd/glusterd.info | cut -f2 -d=` +EXPECT $uuid get_brick_host_uuid $V0 + +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/bug-957877.t b/tests/bugs/bug-957877.t new file mode 100644 index 000000000..23aefea25 --- /dev/null +++ b/tests/bugs/bug-957877.t @@ -0,0 +1,31 @@ +#!/bin/bash +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../afr.rc +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume start $V0; + +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0; +kill_brick $V0 $H0 $B0/${V0}0 +TEST touch $M0/f1 +TEST setfattr -n "user.foo" -v "test" $M0/f1 + +BRICK=$B0"/${V0}1" + +TEST $CLI volume start $V0 force +sleep 5 +TEST $CLI volume heal $V0 + +# Wait for self-heal to complete +EXPECT_WITHIN 30 '0' count_sh_entries $BRICK; + +TEST getfattr -n "user.foo" $B0/${V0}0/f1; + +TEST $CLI volume stop $V0; +TEST $CLI volume delete $V0; + +cleanup; diff --git a/tests/bugs/bug-958691.t b/tests/bugs/bug-958691.t new file mode 100644 index 000000000..a5ac406c9 --- /dev/null +++ b/tests/bugs/bug-958691.t @@ -0,0 +1,50 @@ +#!/bin/bash +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/${V0}{0,1} +TEST $CLI volume start $V0; + +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0; +sleep 1; +TEST mount -t nfs -o vers=3,nolock $H0:/$V0 $N0; + +sleep 2; + +# Tests for the fuse mount +TEST mkdir $M0/dir; +TEST chmod 1777 $M0/dir; +TEST touch $M0/dir/file{1,2}; + +TEST $CLI volume set $V0 server.root-squash enable; + +mv $M0/dir/file1 $M0/dir/file11 2>/dev/null; +TEST [ $? -ne 0 ]; + +TEST $CLI volume set $V0 server.root-squash disable; +TEST rm -rf $M0/dir; + +sleep 1; + +# tests for nfs mount +TEST mkdir $N0/dir; +TEST chmod 1777 $N0/dir; +TEST touch $N0/dir/file{1,2}; + +TEST $CLI volume set $V0 server.root-squash enable; + +mv $N0/dir/file1 $N0/dir/file11 2>/dev/null; +TEST [ $? -ne 0 ]; + +TEST $CLI volume set $V0 server.root-squash disable; +TEST rm -rf $N0/dir; +TEST umount $N0; + +TEST $CLI volume stop $V0; +TEST $CLI volume delete $V0; + +cleanup; diff --git a/tests/bugs/bug-958790.t b/tests/bugs/bug-958790.t new file mode 100644 index 000000000..6cc799c25 --- /dev/null +++ b/tests/bugs/bug-958790.t @@ -0,0 +1,21 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +touch /var/lib/glusterd/groups/test +echo "read-ahead=off" > /var/lib/glusterd/groups/test +echo "open-behind=off" >> /var/lib/glusterd/groups/test + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; +TEST $CLI volume set $V0 group test +EXPECT "off" volume_option $V0 performance.read-ahead +EXPECT "off" volume_option $V0 performance.open-behind + +cleanup; diff --git a/tests/bugs/bug-961307.t b/tests/bugs/bug-961307.t new file mode 100644 index 000000000..96e93a56f --- /dev/null +++ b/tests/bugs/bug-961307.t @@ -0,0 +1,32 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +REPLICA=2 + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 replica $REPLICA $H0:$B0/${V0}-00 $H0:$B0/${V0}-01 $H0:$B0/${V0}-10 $H0:$B0/${V0}-11 +TEST $CLI volume start $V0 + +var1=$(gluster volume remove-brick $H0:$B0/${V0}-00 $H0:$B0/${V0}-01 start 2>&1) +var2="volume remove-brick start: failed: Volume $H0:$B0/${V0}-00 does not exist" + + +function compare_string() +{ + val="-1" + if [ "$1" == "$2" ]; then + val="0" + else + val="1" + fi + echo $val +} + +EXPECT 0 compare_string "$var1" "$var2" +cleanup; diff --git a/tests/bugs/bug-961615.t b/tests/bugs/bug-961615.t new file mode 100644 index 000000000..d183e6c52 --- /dev/null +++ b/tests/bugs/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 60 "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/bug-961669.t b/tests/bugs/bug-961669.t new file mode 100644 index 000000000..751a63df2 --- /dev/null +++ b/tests/bugs/bug-961669.t @@ -0,0 +1,48 @@ +#!/bin/bash + +#Test case: Fail remove-brick 'start' variant when reducing the replica count of a volume. + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a 3x3 dist-rep volume +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2,3,4,5,6,7,8}; +TEST $CLI volume start $V0 + +# Mount FUSE and create file/directory +TEST glusterfs -s $H0 --volfile-id $V0 $M0 +TEST touch $M0/zerobytefile.txt +TEST mkdir $M0/test_dir +TEST dd if=/dev/zero of=$M0/file bs=1024 count=1024 + +function remove_brick_start { + $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}{1,4,7} start 2>&1|grep -oE 'success|failed' +} + +function remove_brick { + $CLI volume remove-brick $V0 replica 2 $H0:$B0/${V0}{1,4,7} 2>&1|grep -oE 'success|failed' +} + +#remove-brick start variant +#Actual message displayed at cli is: +#"volume remove-brick start: failed: Rebalancing not needed when reducing replica count. Try without the 'start' option" +EXPECT "failed" remove_brick_start; + +#remove-brick commit-force +#Actual message displayed at cli is: +#"volume remove-brick commit force: success" +EXPECT "success" remove_brick + +TEST umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/bug-963541.t b/tests/bugs/bug-963541.t new file mode 100755 index 000000000..950c7db54 --- /dev/null +++ b/tests/bugs/bug-963541.t @@ -0,0 +1,33 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..3}; +TEST $CLI volume start $V0; + +# Start a remove-brick and try to start a rebalance/remove-brick without committing +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}1 start + +TEST ! $CLI volume rebalance $V0 start +TEST ! $CLI volume remove-brick $V0 $H0:$B0/${V0}2 start + +#Try to start rebalance/remove-brick again after commit +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}1 commit + +gluster volume status + +TEST $CLI volume rebalance $V0 start +TEST $CLI volume rebalance $V0 stop + +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 start +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 stop + +TEST $CLI volume stop $V0 + +cleanup; + diff --git a/tests/bugs/bug-963678.t b/tests/bugs/bug-963678.t new file mode 100644 index 000000000..14d566579 --- /dev/null +++ b/tests/bugs/bug-963678.t @@ -0,0 +1,56 @@ +#!/bin/bash +# +# Bug 963678 - Test discard functionality +# +# Test that basic discard (hole punch) functionality works via the fallocate +# command line tool. Hole punch deallocates a region of a file, creating a hole +# and a zero-filled data region. We verify that hole punch works, frees blocks +# and that subsequent reads do not read stale data (caches are invalidated). +# +# NOTE: fuse fallocate is known to be broken with regard to cache invalidation +# up to 3.9.0 kernels. Therefore, FOPEN_KEEP_CACHE is not used in this +# test (opens will invalidate the fuse cache). +### + +. $(dirname $0)/../include.rc +. $(dirname $0)/../fallocate.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2} +TEST $CLI volume start $V0 + +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + +# check for fallocate and hole punch support +require_fallocate -l 1m $M0/file +require_fallocate -p -l 512k $M0/file && rm -f $M0/file + +# allocate some blocks, punch a hole and verify block allocation +TEST fallocate -l 1m $M0/file +blksz=`stat --printf=%B $M0/file` +nblks=`stat --printf=%b $M0/file` +TEST [ $(($blksz * $nblks)) -ge 1048576 ] +TEST fallocate -p -o 512k -l 128k $M0/file + +nblks=`stat --printf=%b $M0/file` +# allow some room for xattr blocks +TEST [ $(($blksz * $nblks)) -lt $((917504 + 16384)) ] +TEST unlink $M0/file + +# write some data, punch a hole and verify the file content changes +TEST dd if=/dev/urandom of=$M0/file bs=1M count=1 +TEST cp $M0/file $M0/file.copy.pre +TEST fallocate -p -o 512k -l 128k $M0/file +TEST cp $M0/file $M0/file.copy.post +TEST ! cmp $M0/file.copy.pre $M0/file.copy.post +TEST unlink $M0/file + +TEST umount $M0 + +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup; diff --git a/tests/bugs/bug-964059.t b/tests/bugs/bug-964059.t new file mode 100755 index 000000000..df07f95ee --- /dev/null +++ b/tests/bugs/bug-964059.t @@ -0,0 +1,30 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../cluster.rc + +function check_peers { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} + +function volume_count { + local cli=$1; + if [ $cli -eq '1' ] ; then + $CLI_1 volume info | grep 'Volume Name' | wc -l; + else + $CLI_2 volume info | grep 'Volume Name' | wc -l; + fi +} + +cleanup; + +TEST launch_cluster 2; +TEST $CLI_1 peer probe $H2; + +EXPECT_WITHIN 20 1 check_peers + +TEST $CLI_1 volume create $V0 $H1:$B1/$V0 $H2:$B2/$V0 +TEST $CLI_1 volume start $V0 +TEST $CLI_1 volume remove-brick $V0 $H2:$B2/$V0 start +TEST $CLI_1 volume status +cleanup; diff --git a/tests/bugs/bug-966018.t b/tests/bugs/bug-966018.t new file mode 100644 index 000000000..2a4697241 --- /dev/null +++ b/tests/bugs/bug-966018.t @@ -0,0 +1,34 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#This tests if eager-lock blocks metadata operations on nfs/fuse mounts. +#If it is not woken up, INODELK from the next command waits +#for post-op-delay secs. + +cleanup; +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 replica 2 $H0:$B0/r2_0 $H0:$B0/r2_1 +TEST $CLI volume set $V0 ensure-durability off +TEST $CLI volume set $V0 cluster.eager-lock on +TEST $CLI volume set $V0 cluster.post-op-delay-secs 3 + +TEST $CLI volume start $V0 +TEST $CLI volume profile $V0 start +sleep 5 +TEST mount -t nfs -o vers=3,nolock $H0:/$V0 $N0; +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id=$V0 $M0 +echo 1 > $N0/1 && chmod +x $N0/1 +echo 1 > $M0/1 && chmod +x $M0/1 + +#Check that INODELK MAX latency is not in the order of seconds +#Test if the MAX INODELK fop latency is of the order of seconds. +inodelk_max_latency=$($CLI volume profile $V0 info | grep INODELK | awk 'BEGIN {max = 0} {if ($6 > max) max=$6;} END {print max}' | cut -d. -f 1 | egrep "[0-9]{7,}") + +TEST [ -z $inodelk_max_latency ] +TEST umount $N0 + +cleanup; diff --git a/tests/bugs/bug-969193.t b/tests/bugs/bug-969193.t new file mode 100755 index 000000000..e78a2980e --- /dev/null +++ b/tests/bugs/bug-969193.t @@ -0,0 +1,13 @@ +#!/bin/bash + +# Test that "system getspec" works without op_version problems. + +. $(dirname $0)/../include.rc +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info +TEST $CLI volume create $V0 $H0:$B0/brick1 +TEST $CLI system getspec $V0 +cleanup; diff --git a/tests/bugs/bug-970070.t b/tests/bugs/bug-970070.t new file mode 100755 index 000000000..da28b1ed7 --- /dev/null +++ b/tests/bugs/bug-970070.t @@ -0,0 +1,14 @@ +#!/bin/bash +# TEST the nfs.acl option +. $(dirname $0)/../include.rc + +cleanup +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume start $V0 +sleep 5 +TEST $CLI volume set $V0 nfs.acl off +TEST $CLI volume set $V0 nfs.acl on +cleanup diff --git a/tests/bugs/bug-973073.t b/tests/bugs/bug-973073.t new file mode 100755 index 000000000..83e2839c6 --- /dev/null +++ b/tests/bugs/bug-973073.t @@ -0,0 +1,48 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../dht.rc + +## Steps followed are one descibed 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 30 "0" rebalance_completed + +TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 stop + +TEST $CLI volume rebalance $V0 fix-layout start + +EXPECT_WITHIN 30 "0" rebalance_completed + +TEST mkdir $M0/dir 2>/dev/null; + +EXPECT "0" get_layout $B0/${V0}2/dir +cleanup; diff --git a/tests/bugs/bug-974007.t b/tests/bugs/bug-974007.t new file mode 100644 index 000000000..c8c1c862b --- /dev/null +++ b/tests/bugs/bug-974007.t @@ -0,0 +1,52 @@ +#!/bin/bash + +#Test case: Create a distributed replicate volume, and remove multiple +#replica pairs in a single remove-brick command. + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a 3X2 distributed-replicate volume +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1..6}; +TEST $CLI volume start $V0 + +# Mount FUSE and create files +TEST glusterfs -s $H0 --volfile-id $V0 $M0 +TEST touch $M0/file{1..10} + +# Remove bricks from two sub-volumes to make it a 1x2 vol. +# Bricks in question are given in a random order but from the same subvols. +function remove_brick_start_status { + $CLI volume remove-brick $V0 \ + $H0:$B0/${V0}6 $H0:$B0/${V0}1 \ + $H0:$B0/${V0}2 $H0:$B0/${V0}5 start 2>&1 |grep -oE "success|failed" +} +EXPECT "success" remove_brick_start_status; + +# Wait for rebalance to complete +EXPECT_WITHIN 10 "completed" remove_brick_status_completed_field "$V0" "$H0:$B0/${V0}6 $H0:$B0/${V0}1 $H0:$B0/${V0}2 $H0:$B0/${V0}5" + +# Check commit status +function remove_brick_commit_status { + $CLI volume remove-brick $V0 \ + $H0:$B0/${V0}6 $H0:$B0/${V0}1 \ + $H0:$B0/${V0}2 $H0:$B0/${V0}5 commit 2>&1 |grep -oE "success|failed" +} +EXPECT "success" remove_brick_commit_status; + +# Check the volume type +EXPECT "Replicate" echo `$CLI volume info |grep Type |awk '{print $2}'` + +TEST umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/bug-974972.t b/tests/bugs/bug-974972.t new file mode 100755 index 000000000..15deac090 --- /dev/null +++ b/tests/bugs/bug-974972.t @@ -0,0 +1,36 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#This script checks that nfs mount does not fail lookup on files with split-brain +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 self-heal-daemon off +TEST $CLI volume start $V0 +sleep 5 +TEST mount -t nfs -o vers=3 $H0:/$V0 $N0 +TEST touch $N0/1 +TEST kill_brick ${V0} ${H0} ${B0}/${V0}1 +echo abc > $N0/1 +TEST $CLI volume start $V0 force +EXPECT_WITHIN 20 "Y" nfs_up_status +EXPECT_WITHIN 20 "1" afr_child_up_status_in_nfs $V0 0 +EXPECT_WITHIN 20 "1" afr_child_up_status_in_nfs $V0 1 + +TEST kill_brick ${V0} ${H0} ${B0}/${V0}0 +echo def > $N0/1 +TEST $CLI volume start $V0 force +EXPECT_WITHIN 20 "Y" nfs_up_status +EXPECT_WITHIN 20 "1" afr_child_up_status_in_nfs $V0 0 +EXPECT_WITHIN 20 "1" afr_child_up_status_in_nfs $V0 1 + +#Lookup should not fail +TEST ls $N0/1 +TEST ! cat $N0/1 + +TEST umount $N0 +cleanup diff --git a/tests/bugs/bug-976800.t b/tests/bugs/bug-976800.t new file mode 100644 index 000000000..2aee8cc11 --- /dev/null +++ b/tests/bugs/bug-976800.t @@ -0,0 +1,28 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +# This test checks if there are any open fds on the brick +# even after the file is closed on the mount. This particular +# test tests dd with "fsync" to check afr's fsync codepath +cleanup; + +function is_fd_open { + local v=$1 + local h=$2 + local b=$3 + local bpid=$(get_brick_pid $v $h $b) + ls -l /proc/$bpid/fd | grep -w "\-> $b/1" +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 ensure-durability off +TEST $CLI volume set $V0 eager-lock off +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 +TEST dd of=$M0/1 if=/dev/zero bs=1k count=1 conv=fsync +TEST ! is_fd_open $V0 $H0 $B0/${V0}0 +cleanup; diff --git a/tests/bugs/bug-977246.t b/tests/bugs/bug-977246.t new file mode 100644 index 000000000..e07ee1919 --- /dev/null +++ b/tests/bugs/bug-977246.t @@ -0,0 +1,21 @@ +#! /bin/bash + +# This test checks if address validation, correctly catches hostnames +# with consective dots, such as 'example..org', as invalid + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}1 +TEST $CLI volume info $V0 +TEST $CLI volume start $V0 + +TEST ! $CLI volume set $V0 auth.allow example..org + +TEST $CLI volume stop $V0 + +cleanup; diff --git a/tests/bugs/bug-977797.t b/tests/bugs/bug-977797.t new file mode 100755 index 000000000..08cdbe8f1 --- /dev/null +++ b/tests/bugs/bug-977797.t @@ -0,0 +1,114 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +## Start and create a volume +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2}; + +## Verify volume is 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 $CLI volume set $V0 self-heal-daemon off +TEST $CLI volume set $V0 open-behind off +TEST $CLI volume set $V0 quick-read off +TEST $CLI volume set $V0 read-ahead off +TEST $CLI volume set $V0 write-behind off +TEST $CLI volume set $V0 io-cache off +TEST $CLI volume set $V0 background-self-heal-count 0 + +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 + + +TEST mkdir -p $M0/a +TEST `echo "GLUSTERFS" > $M0/a/file` + +TEST kill_brick $V0 $H0 $B0/$V0"1" + +TEST chown root $M0/a +TEST chown root $M0/a/file +TEST `echo "GLUSTER-FILE-SYSTEM" > $M0/a/file` +TEST mkdir $M0/a/b + +TEST $CLI volume start $V0 force +EXPECT_WITHIN 20 "1" afr_child_up_status $V0 0; + + + +TEST kill_brick $V0 $H0 $B0/$V0"2" + +TEST chmod 757 $M0/a +TEST chmod 757 $M0/a/file + +TEST $CLI volume start $V0 force +EXPECT_WITHIN 20 "1" afr_child_up_status $V0 1; + +TEST ls -l $M0/a/file + +b1c0dir=$(afr_get_specific_changelog_xattr $B0/$V0"1"/a \ + trusted.afr.$V0-client-0 "entry") +b1c1dir=$(afr_get_specific_changelog_xattr $B0/$V0"1"/a \ + trusted.afr.$V0-client-1 "entry") +b2c0dir=$(afr_get_specific_changelog_xattr \ + $B0/$V0"2"/a trusted.afr.$V0-client-0 "entry") +b2c1dir=$(afr_get_specific_changelog_xattr \ + $B0/$V0"2"/a trusted.afr.$V0-client-1 "entry") + + +b1c0f=$(afr_get_specific_changelog_xattr $B0/$V0"1"/a/file \ + trusted.afr.$V0-client-0 "data") +b1c1f=$(afr_get_specific_changelog_xattr $B0/$V0"1"/a/file \ + trusted.afr.$V0-client-1 "data") +b2c0f=$(afr_get_specific_changelog_xattr $B0/$V0"2"/a/file \ + trusted.afr.$V0-client-0 "data") +b2c1f=$(afr_get_specific_changelog_xattr $B0/$V0"2"/a/file \ + trusted.afr.$V0-client-1 "data") + +EXPECT "00000000" echo $b1c0f +EXPECT "00000000" echo $b1c1f +EXPECT "00000000" echo $b2c0f +EXPECT "00000000" echo $b2c1f + +EXPECT "00000000" echo $b1c0dir +EXPECT "00000000" echo $b1c1dir +EXPECT "00000000" echo $b2c0dir +EXPECT "00000000" echo $b2c1dir + +contains() { + string="$1" + substring="$2" + var="-1" + if test "${string#*$substring}" != "$string" + then + var="0" # $substring is in $string + else + var="1" # $substring is not in $string + fi + echo $var +} + +var1=$(cat $M0/a/file 2>&1) +var2="Input/output error" + + +EXPECT "0" contains "$var1" "$var2" + +## Finish up +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/bug-978794.t b/tests/bugs/bug-978794.t new file mode 100644 index 000000000..d22d3cde3 --- /dev/null +++ b/tests/bugs/bug-978794.t @@ -0,0 +1,29 @@ +#!/bin/bash +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../fileio.rc + + +# This test opens 100 fds and triggers graph switches to check if fsync +# as part of graph-switch causes crash or not. + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 +TEST touch $M0/{1..100} +for i in {1..100}; do fd[$i]=`fd_available`; fd_open ${fd[$i]} 'w' $M0/$i; done +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}{2,3} +TEST $CLI volume rebalance $V0 start force +EXPECT_WITHIN 120 "completed" rebalance_status_field $V0 +TEST cat $M0/{1..100} +for i in {1..100}; do fd_write ${fd[$i]} 'abc'; done +TEST $CLI volume add-brick $V0 $H0:$B0/${V0}{4,5} +TEST $CLI volume rebalance $V0 start force +EXPECT_WITHIN 120 "completed" rebalance_status_field $V0 +for i in {1..100}; do fd_write ${fd[$i]} 'abc'; done +TEST cat $M0/{1..100} +cleanup diff --git a/tests/bugs/bug-979365.t b/tests/bugs/bug-979365.t new file mode 100755 index 000000000..e94dc9aa8 --- /dev/null +++ b/tests/bugs/bug-979365.t @@ -0,0 +1,47 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#This script checks that ensure-durability option enables/disables afr +#sending fsyncs +cleanup; + +function num_fsyncs { + $CLI volume profile $V0 info | grep -w FSYNC | wc -l +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume set $V0 ensure-durability on +TEST $CLI volume set $V0 eager-lock off +TEST $CLI volume start $V0 +TEST $CLI volume profile $V0 start +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 +TEST kill_brick $V0 $H0 $B0/${V0}0 +TEST dd of=$M0/a if=/dev/zero bs=1M count=10 +#fsyncs take a while to complete. +sleep 5 + +# There can be zero or more fsyncs, depending on the order +# in which the writes reached the server, in turn deciding +# whether they were treated as "appending" writes or not. + +TEST [[ $(num_fsyncs) -ge 0 ]] +#Stop the volume to erase the profile info of old operations +TEST $CLI volume profile $V0 stop +TEST $CLI volume stop $V0 +umount $M0 +#Disable ensure-durability now to disable fsyncs in afr. +TEST $CLI volume set $V0 ensure-durability off +TEST $CLI volume start $V0 +TEST kill_brick $V0 $H0 $B0/${V0}0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 +TEST $CLI volume profile $V0 start +TEST dd of=$M0/a if=/dev/zero bs=1M count=10 +#fsyncs take a while to complete. +sleep 5 +TEST [[ $(num_fsyncs) -eq 0 ]] + +cleanup diff --git a/tests/bugs/bug-982174.t b/tests/bugs/bug-982174.t new file mode 100644 index 000000000..460af7511 --- /dev/null +++ b/tests/bugs/bug-982174.t @@ -0,0 +1,36 @@ +#!/bin/bash +# Test to check +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#Check if incorrect log-level keywords does not crash the CLI +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/brick1 $H0:$B0/brick2 +TEST $CLI volume start $V0 + +function set_log_level_status { + local level=$1 + $CLI volume set $V0 diagnostics.client-log-level $level 2>&1 |grep -oE 'success|failed' +} + + +LOG_LEVEL="trace" +EXPECT "failed" set_log_level_status $LOG_LEVEL + + +LOG_LEVEL="error-gen" +EXPECT "failed" set_log_level_status $LOG_LEVEL + + +LOG_LEVEL="TRACE" +EXPECT "success" set_log_level_status $LOG_LEVEL + +EXPECT "$LOG_LEVEL" echo `$CLI volume info | grep diagnostics | awk '{print $2}'` + +TEST $CLI volume stop $V0; +TEST $CLI volume delete $V0; + +cleanup; diff --git a/tests/bugs/bug-983477.t b/tests/bugs/bug-983477.t new file mode 100755 index 000000000..c19fa96c8 --- /dev/null +++ b/tests/bugs/bug-983477.t @@ -0,0 +1,52 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#This script checks if use-readdirp option works as accepted in mount options + +function get_use_readdirp_value { + local vol=$1 + local statedump=$(generate_mount_statedump $vol) + local val=$(grep "use_readdirp=" $statedump | cut -f2 -d'=' | tail -1) + rm -f $statedump + echo $val +} +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/${V0} +TEST $CLI volume start $V0 +#If readdirp is enabled statedump should reflect it +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --use-readdirp=yes +TEST cd $M0 +EXPECT_WITHIN 20 "1" get_use_readdirp_value $V0 +TEST cd - +TEST umount $M0 + +#If readdirp is enabled statedump should reflect it +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --use-readdirp=no +TEST cd $M0 +EXPECT_WITHIN 20 "0" get_use_readdirp_value $V0 +TEST cd - +TEST umount $M0 + +#Since args are optional on this argument just specifying "--use-readdirp" should also turn it `on` not `off` +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --use-readdirp +TEST cd $M0 +EXPECT_WITHIN 20 "1" get_use_readdirp_value $V0 +TEST cd - +TEST umount $M0 + +#By default it is enabled. +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 +TEST cd $M0 +EXPECT_WITHIN 20 "1" get_use_readdirp_value $V0 +TEST cd - +TEST umount $M0 + +#Invalid values for use-readdirp should not be accepted +TEST ! glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 --use-readdirp=please-fail + +cleanup diff --git a/tests/bugs/bug-985074.t b/tests/bugs/bug-985074.t new file mode 100644 index 000000000..80052129e --- /dev/null +++ b/tests/bugs/bug-985074.t @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Bug 985074 - Verify stale inode/dentry mappings are cleaned out. +# +# This test verifies that an inode/dentry mapping for a file removed via a +# separate mount point is cleaned up appropriately. We create a file and hard +# link from client 1. Next we remove the link via client 2. Finally, from client +# 1 we attempt to rename the original filename to the name of the just removed +# hard link. +# +# If the inode is not unlinked properly, the removed directory entry can resolve +# to an inode (on the client that never saw the rm) that ends up passed down +# through the lookup call. If md-cache holds valid metadata on the inode (due to +# a large timeout value or recent lookup on the valid name), it is tricked into +# returning a successful lookup that should have returned ENOENT. This manifests +# as an error from the mv command in the following test sequence because file +# and file.link resolve to the same file: +# +# # mv /mnt/glusterfs/0/file /mnt/glusterfs/0/file.link +# mv: `/mnt/glusterfs/0/file' and `/mnt/glusterfs/0/file.link' are the same file +# +### + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume start $V0 +TEST $CLI volume set $V0 md-cache-timeout 3 + +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 --entry-timeout=0 --attribute-timeout=0 +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M1 --entry-timeout=0 --attribute-timeout=0 + +TEST touch $M0/file +TEST ln $M0/file $M0/file.link +TEST ls -ali $M0 $M1 +TEST rm -f $M1/file.link +TEST ls -ali $M0 $M1 +# expire the md-cache timeout +sleep 3 +TEST mv $M0/file $M0/file.link +TEST stat $M0/file.link +TEST ! stat $M0/file + +TEST umount $M1 +TEST umount $M0 + +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup; diff --git a/tests/bugs/bug-986429.t b/tests/bugs/bug-986429.t new file mode 100644 index 000000000..6e43f72b7 --- /dev/null +++ b/tests/bugs/bug-986429.t @@ -0,0 +1,19 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +## This tests failover achieved by providing multiple +## servers from the trusted pool for fetching volume +## specification + +cleanup; + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume start $V0 +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s non-existent -s $H0 --volfile-id=/$V0 $M0 + +cleanup; diff --git a/tests/bugs/bug-986905.t b/tests/bugs/bug-986905.t new file mode 100755 index 000000000..0fac40fb4 --- /dev/null +++ b/tests/bugs/bug-986905.t @@ -0,0 +1,27 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#This script checks if hardlinks that are created while a brick is down are +#healed properly. + +cleanup; +function get_inum { + ls -i $1 | awk '{print $1}' +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 +TEST kill_brick $V0 $H0 $B0/${V0}0 +TEST touch $M0/a +TEST ln $M0/a $M0/link_a +TEST $CLI volume start $V0 force +EXPECT_WITHIN 20 "1" afr_child_up_status $V0 0 +TEST ls -l $M0 +inum=$(get_inum $B0/${V0}0/a) +EXPECT "$inum" get_inum $B0/${V0}0/link_a +cleanup diff --git a/tests/bugs/bug-991622.t b/tests/bugs/bug-991622.t new file mode 100644 index 000000000..5c3243465 --- /dev/null +++ b/tests/bugs/bug-991622.t @@ -0,0 +1,35 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../fileio.rc + +#This tests that no fd leaks are observed in unlink/rename in open-behind +function leaked_fds { + ls -l /proc/$(get_brick_pid $V0 $H0 $B0/$V0)/fd | grep deleted +} + +cleanup; +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume set $V0 open-behind on +TEST $CLI volume start $V0 +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id=$V0 $M0 --direct-io-mode=enable + +TEST fd1=`fd_available` +TEST fd_open $fd1 'w' "$M0/testfile1" +TEST fd_write $fd1 "content" + +TEST fd2=`fd_available` +TEST fd_open $fd2 'w' "$M0/testfile2" +TEST fd_write $fd2 "content" + +TEST touch $M0/a +TEST rm $M0/testfile1 +TEST mv $M0/a $M0/testfile2 +TEST fd_close $fd1 +TEST fd_close $fd2 +TEST ! leaked_fds +cleanup; diff --git a/tests/cluster.rc b/tests/cluster.rc index 1c06bca47..3b10d19f7 100755 --- a/tests/cluster.rc +++ b/tests/cluster.rc @@ -45,8 +45,10 @@ function define_glusterds() { wopt="management.working-directory=${!b}/glusterd"; bopt="management.transport.socket.bind-address=${!h}"; popt="--pid-file=${!b}/glusterd.pid"; - eval "glusterd_$i='glusterd --xlator-option $wopt --xlator-option $bopt $popt'"; - eval "glusterd$i='glusterd --xlator-option $wopt --xlator-option $bopt $popt'"; + sopt="management.glusterd-sockfile=${!b}/glusterd/gd.sock" + lopt="--log-file=${!b}/glusterd.log" + eval "glusterd_$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $sopt $lopt $popt'"; + eval "glusterd$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $sopt $lopt $popt'"; done } @@ -98,9 +100,13 @@ function define_clis() { local h; for i in `seq 1 $count`; do - h="H$i"; - eval "CLI_$i='$CLI --remote-host=${!h}'"; - eval "CLI$i='$CLI --remote-host=${!h}'"; + b="B$i"; + eval "CLI_$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock'"; + eval "CLI$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock'"; done + CLI="$CLI_1" } +function peer_count() { + $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l +} diff --git a/tests/dht.rc b/tests/dht.rc index ee92a47bd..663ea5431 100644 --- a/tests/dht.rc +++ b/tests/dht.rc @@ -2,13 +2,7 @@ function get_layout() { - layout=`getfattr -n trusted.glusterfs.dht -e hex $1 2>&1|grep dht |cut -d = -f2` - if [ $? -eq 1] - then - return -1 - else - return $layout - fi + getfattr -n trusted.glusterfs.dht -e hex $1 2>&1|grep dht |cut -d = -f2 } diff --git a/tests/fallocate.rc b/tests/fallocate.rc new file mode 100644 index 000000000..3756bb949 --- /dev/null +++ b/tests/fallocate.rc @@ -0,0 +1,19 @@ +#!/bin/bash + +# Helper to verify a given fallocate command is supported and skip a test +# otherwise. Older versions of the fallocate utility might not support all modes +# (i.e., discard) and older versions of fuse might not support the associated +# fallocate requests. + +function require_fallocate() +{ + output=`fallocate $* 2>&1` + ret=$? + if [ ! $ret -eq 0 ] && ([[ $output == *unsupported* ]] || + [[ $output == *invalid* ]] || + [[ $output == *"not supported"* ]]) + then + SKIP_TESTS + exit + fi +} diff --git a/tests/features/glupy.t b/tests/features/glupy.t new file mode 100755 index 000000000..49bf11df5 --- /dev/null +++ b/tests/features/glupy.t @@ -0,0 +1,29 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc + +cleanup; + +TEST mkdir -p $B0/glupytest +cat > $B0/glupytest.vol <<EOF +volume vol-posix + type storage/posix + option directory $B0/glupytest +end-volume + +volume vol-glupy + type features/glupy + option module-name helloworld + subvolumes vol-posix +end-volume +EOF + +TEST glusterfs -f $B0/glupytest.vol $M0; + +TEST touch $M0/filename; +EXPECT "filename" ls $M0 +TEST rm -f $M0/filename; + +TEST umount -l $M0; + +cleanup; diff --git a/tests/features/readdir-ahead.t b/tests/features/readdir-ahead.t new file mode 100755 index 000000000..c7ee637f0 --- /dev/null +++ b/tests/features/readdir-ahead.t @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Test basic readdir-ahead functionality. Verify that readdir-ahead can be +# enabled, create a set of files and run some ls tests. +# +### + +. $(dirname $0)/../include.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume start $V0 + +TEST $CLI volume set $V0 readdir-ahead on + +TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 + +TEST mkdir $M0/test +for i in $(seq 0 99) +do + touch $M0/test/$i +done + +count=`ls -1 $M0/test | wc -l` +TEST [ $count -eq 100 ] + +count=`ls -1 $M0/test | wc -l` +TEST [ $count -eq 100 ] + +TEST rm -rf $M0/test/* + +count=`ls -1 $M0/test | wc -l` +TEST [ $count -eq 0 ] + +TEST rmdir $M0/test + +TEST umount -l $M0; +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup; diff --git a/tests/include.rc b/tests/include.rc index 4008ad36f..80457f124 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -3,6 +3,7 @@ M1=${M1:=/mnt/glusterfs/1}; # 1st mount point for FUSE N0=${N0:=/mnt/nfs/0}; # 0th mount point for NFS N1=${N1:=/mnt/nfs/1}; # 1st mount point for NFS V0=${V0:=patchy}; # volume name to use in tests +V1=${V1:=patchy1}; # volume name to use in tests B0=${B0:=/d/backends}; # top level of brick directories H0=${H0:=`hostname --fqdn`}; # hostname DEBUG=${DEBUG:=0} # turn on debugging? @@ -14,7 +15,17 @@ mkdir -p $B0; mkdir -p $M0 $M1; mkdir -p $N0 $N1; -testcnt=`egrep '^[[:space:]]*(EXPECT|TEST|EXPECT_WITHIN|EXPECT_KEYWORD)' $0 | wc -l`; +testcnt=`egrep '^[[:space:]]*(EXPECT|TEST|EXPECT_WITHIN|EXPECT_KEYWORD)[[:space:]]' $0 | wc -l` +expect_tests=`egrep '^[[:space:]]*TESTS_EXPECTED_IN_LOOP[[:space:]]*' $0` + +x_ifs=$IFS +IFS=$'\n' +for line in $expect_tests; do + expect_tests=`echo $line | cut -f 2 -d =` + testcnt=`expr $testcnt + $expect_tests` +done +IFS=$x_ifs + echo 1..$testcnt t=1 @@ -164,18 +175,26 @@ function SKIP_TESTS() } +function _TEST_IN_LOOP() +{ + testcnt=`expr $testcnt + 1`; + _TEST $@ +} + + function cleanup() { killall -15 glusterfs glusterfsd glusterd 2>/dev/null || true; killall -9 glusterfs glusterfsd glusterd 2>/dev/null || true; + type cleanup_lvm &>/dev/null && cleanup_lvm + MOUNTPOINTS=`mount | grep "$B0/" | awk '{print $3}'` for m in $MOUNTPOINTS; do umount $m done - LOOPDEVICES=`losetup -a | grep "$B0/" | awk '{print $1}' | tr -d :` for l in $LOOPDEVICES; do @@ -189,6 +208,7 @@ function cleanup() umount -l $M1 2>/dev/null || true; umount -l $N0 2>/dev/null || true; umount -l $N1 2>/dev/null || true; + } function volinfo_field() @@ -224,4 +244,5 @@ alias EXPECT='_EXPECT $LINENO' alias TEST='_TEST $LINENO' alias EXPECT_WITHIN='_EXPECT_WITHIN $LINENO' alias EXPECT_KEYWORD='_EXPECT_KEYWORD $LINENO' +alias TEST_IN_LOOP='_TEST_IN_LOOP $LINENO' shopt -s expand_aliases diff --git a/tests/nfs.rc b/tests/nfs.rc new file mode 100644 index 000000000..f3abee842 --- /dev/null +++ b/tests/nfs.rc @@ -0,0 +1,21 @@ +#!/bin/bash + + +# Due to portmap registration NFS takes some time to +# export all volumes. Therefore tests should start only +# after exports are visible by showmount command. This +# routine will check if showmount shows the exports or not +# +function is_nfs_export_available () +{ + vol=$1 + + if [ "$vol" == "" ]; then + vol=$V0 + fi + + exp=$(showmount -e 2> /dev/null | grep $vol | wc -l) + echo "$exp" +} + + diff --git a/tests/snapshot.rc b/tests/snapshot.rc new file mode 100755 index 000000000..a5b86f674 --- /dev/null +++ b/tests/snapshot.rc @@ -0,0 +1,251 @@ +#!/bin/bash + +LVM_DEFINED=0 +LVM_PREFIX="patchy_snap" +LVM_COUNT=0 +VHD_SIZE="1G" + +function init_lvm() { + if [ "$1" == "" ]; then + echo "Error: Invalid argument supplied" + return 1 + fi + LVM_COUNT=$1 + + if [ "$2" != "" ]; then + VHD_SIZE=$2 + fi + + local b + local i + + if [ "$B1" = "" ]; then + B1=$B0 + fi + + for i in `seq 1 $LVM_COUNT`; do + b="B$i" + if [ "${!b}" = "" ]; then + echo "Error: $b not defined." + echo "Please run launch_cluster with atleast $LVM_COUNT nodes" + return 1 + fi + + eval "L$i=${!b}/${LVM_PREFIX}_mnt" + l="L$i" + mkdir -p ${!l} + if [ $? -ne 0 ]; then + echo "Error: failed to create dir ${!l}" + return 1 + fi + + eval "VG$i=${LVM_PREFIX}_vg_${i}" + done + + LVM_DEFINED=1 + return 0 +} + +function setup_lvm() { + init_lvm $@ || return 1 + _setup_lvm + return 0 +} + +function cleanup_lvm() { + pkill gluster + sleep 2 + + if [ "$LVM_DEFINED" = "1" ]; then + _cleanup_lvm + fi + + _cleanup_lvm_again >/dev/null 2>&1 + return 0 +} + +######################################################## +# Private Functions +######################################################## +function _setup_lvm() { + local count=$LVM_COUNT + local b + local i + + for i in `seq 1 $count`; do + b="B$i" + + _create_vhd ${!b} $i + _create_lv ${!b} $i + _mount_lv $i + done +} + +function _cleanup_lvm() { + local count=$LVM_COUNT + local b + local i + + for i in `seq 1 $count`; do + b="B$i" + _umount_lv $i + _remove_lv $i + _remove_vhd ${!b} + done +} + +function _cleanup_lvm_again() { + local file + + mount | grep $LVM_PREFIX | awk '{print $3}' | xargs -r umount -f + + /sbin/vgs | grep $LVM_PREFIX | awk '{print $1}' | xargs -r vgremove -f + + find $B0 -name "${LVM_PREFIX}_loop" | xargs -r losetup -d + + find $B0 -name "${LVM_PREFIX}*" | xargs -r rm -rf + + find /run/gluster/snaps -name "*${LVM_PREFIX}*" | xargs -r rm -rf + + for file in `ls /run/gluster/snaps`; do + find /run/gluster/snaps/$file -mmin -2 | xargs -r rm -rf + done +} + +######################################################## +######################################################## +function _create_vhd() { + local dir=$1 + local num=$2 + local loop_num=`expr $2 + 8` + + fallocate -l${VHD_SIZE} $dir/${LVM_PREFIX}_vhd + mknod -m660 $dir/${LVM_PREFIX}_loop b 7 $loop_num + /sbin/losetup $dir/${LVM_PREFIX}_loop $dir/${LVM_PREFIX}_vhd +} + +function _create_lv() { + local dir=$1 + local num=$2 + local vg="VG$num" + + /sbin/pvcreate $dir/${LVM_PREFIX}_loop + /sbin/vgcreate ${!vg} $dir/${LVM_PREFIX}_loop + + /sbin/lvcreate -l 100%FREE -T /dev/${!vg}/thinpool + /sbin/lvcreate -V $VHD_SIZE -T /dev/${!vg}/thinpool -n brick_lvm + + mkfs.xfs -f /dev/${!vg}/brick_lvm +} + +function _mount_lv() { + local num=$1 + local vg="VG$num" + local l="L$num" + + mount -t xfs -o nouuid /dev/${!vg}/brick_lvm ${!l} +} + +function _umount_lv() { + local num=$1 + local l="L$num" + + umount -f ${!l} 2>/dev/null || true + rmdir ${!l} 2>/dev/null || true +} + +function _remove_lv() { + local num=$1 + local vg="VG$num" + + vgremove -f ${!vg} +} + +function _remove_vhd() { + local dir=$1 + + losetup -d $dir/${LVM_PREFIX}_loop + rm -f $dir/${LVM_PREFIX}_loop + rm -f $dir/${LVM_PREFIX}_vhd +} + +######################################################## +# Utility Functions +######################################################## +function snapshot_exists() { + local volname=$1 + local snapname=$2 + $CLI snapshot list $volname | egrep -q "^$snapname\$" + return $? +} + +#Create N number of snaps in a given volume +#Arg1 : <Volume Name> +#Arg2 : <Count of snaps to be created> +#Arg3 : <Snap Name Pattern> +#Return: Returns 0 if all snaps are created , +# if not will return exit code of last failed +# snap create command. +function create_n_snapshots() { + local vol=$1 + local snap_count=$2 + local snap_name=$3 + local ret=0 + for i in `seq 1 $snap_count`; do + $CLI_1 snapshot create $snap_name$i ${vol}& + PID_1=$! + wait $PID_1 + ret=$? + if [ "$ret" != "0" ]; then + break + fi + done + return $ret +} + + +#Delete N number of snaps in a given volume +#Arg1 : <Volume Name> +#Arg2 : <Count of snaps to be deleted> +#Arg3 : <Snap Name Pattern> +#Return: Returns 0 if all snaps are Delete, +# if not will return exit code of last failed +# snap delete command. +function delete_n_snapshots() { + local vol=$1 + local snap_count=$2 + local snap_name=$3 + local ret=0 + for i in `seq 1 $snap_count`; do + $CLI_1 snapshot delete $snap_name$i & + PID_1=$! + wait $PID_1 + temp=$? + if [ "$temp" != "0" ]; then + ret=$temp + fi + done + return $ret +} + +#Check for the existance of N number of snaps in a given volume +#Arg1 : <Volume Name> +#Arg2 : <Count of snaps to be checked> +#Arg3 : <Snap Name Pattern> +#Return: Returns 0 if all snaps exists, +# if not will return exit code of last failed +# snapshot_exists(). +function snapshot_n_exists() { + local vol=$1 + local snap_count=$2 + local snap_name=$3 + local ret=0 + for i in `seq 1 $snap_count`; do + snapshot_exists $snap_name$i + ret=$? + if [ "$ret" != "0" ]; then + break + fi + done + return $ret +} diff --git a/tests/volume.rc b/tests/volume.rc index 33a38ee7e..171f8d709 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -27,11 +27,18 @@ function volume_option() } function rebalance_status_field { - $CLI volume rebalance $1 status | sed -n '$p' | cut -d' ' -f4 + #The rebalance status can be upto 3 words, (ex:'fix-layout in progress'), hence the awk-print $7 thru $9. + #But if the status is less than 3 words, it also prints the next field i.e the run_time_in_secs.(ex:'completed 3.00'). + #So we trim the numbers out with `tr`. Finally remove the trailing white spaces with sed. What we get is one of the + #strings in the 'cli_vol_task_status_str' char array of cli-rpc-ops.c + + $CLI volume rebalance $1 status | awk '{print $7,$8,$9}' |sed -n 3p |tr -d '[^0-9+\.]'|sed 's/ *$//g' } function remove_brick_status_completed_field { - $CLI volume remove-brick $V0 $H0:$B0/r2d2_{4,5} status | awk '{print $6}' | sed -n 3p + local vol=$1 + local brick_list=$2 + $CLI volume remove-brick $vol $brick_list status | awk '{print $7}' | sed -n 3p } function get_mount_process_pid { @@ -105,6 +112,11 @@ function generate_shd_statedump { generate_statedump $(get_shd_process_pid $vol) } +function generate_nfs_statedump { + local vol=$1 + generate_statedump $(get_nfs_pid $vol) +} + function generate_brick_statedump { local vol=$1 local host=$2 @@ -119,6 +131,17 @@ function afr_child_up_status_in_shd { _afr_child_up_status $vol $brick_id generate_shd_statedump } +function afr_child_up_status_in_nfs { + local vol=$1 + #brick_id is (brick-num in volume info - 1) + local brick_id=$2 + _afr_child_up_status $vol $brick_id generate_nfs_statedump +} + +function nfs_up_status { + gluster volume status | grep "NFS Server" | awk '{print $6}' +} + function glustershd_up_status { gluster volume status | grep "Self-heal Daemon" | awk '{print $6}' } @@ -221,6 +244,26 @@ function dht_get_layout { getfattr -d -e hex -n $my_xa $1 2> /dev/null | grep "$my_xa=" | cut -d= -f2 } +function afr_get_specific_changelog_xattr () +{ + local path=$1 + local key=$2 + local type=$3 + local specific_changelog="" + + changelog_xattr=$(afr_get_changelog_xattr "$path" "$key") + if [ "$type" == "data" ]; then + specific_changelog=${changelog_xattr:2:8} + elif [ "$type" == "metadata" ]; then + specific_changelog=${changelog_xattr:10:8} + elif [ "$type" == "entry" ]; then + specific_changelog=${changelog_xattr:18:8} + else + specific_changlog="error" + fi + + echo $specific_changelog +} ## # query pathinfo xattr and extract POSIX pathname(s) ## @@ -229,3 +272,54 @@ function get_backend_paths { getfattr -m . -n trusted.glusterfs.pathinfo $path | tr ' ' '\n' | sed -n 's/<POSIX.*:.*:\(.*\)>.*/\1/p' } + +function do_volume_operations() { + local operation=$1 + local count=$2 + local force=$3 + + local pids=() + local cli + local v + + for i in `seq 1 $count`; do + cli="CLI_$i" + v="V`expr $i - 1`" + ${!cli} volume $operation ${!v} $force & + pids[$i]=$! + done + + for i in `seq 1 $count`; do + wait ${pids[$i]} + done +} + +function start_volumes() { + do_volume_operations start $1 +} + +function stop_volumes() { + do_volume_operations stop $1 +} + +function start_force_volumes() { + do_volume_operations start $1 force +} + +function stop_force_volumes() { + do_volume_operations stop $1 force +} + +function delete_volumes() { + do_volume_operations delete $1 +} + +function volume_exists() { + local volname=$1 + $CLI volume info $volname 2>&1 | grep -q 'does not exist' + if [ $? -eq 0 ]; then + return 1 + else + return 0 + fi +} |
