diff options
Diffstat (limited to 'tests/basic')
| -rwxr-xr-x | tests/basic/bd.t | 76 | ||||
| -rwxr-xr-x | tests/basic/cdc.t | 135 | ||||
| -rwxr-xr-x | tests/basic/file-snapshot.t | 56 | ||||
| -rwxr-xr-x | tests/basic/mgmt_v3-locks.t | 121 | ||||
| -rwxr-xr-x | tests/basic/mount.t | 2 | ||||
| -rw-r--r-- | tests/basic/nufa.t | 32 | ||||
| -rwxr-xr-x | tests/basic/rpm.t | 79 | ||||
| -rwxr-xr-x | tests/basic/volume-snapshot.t | 83 | ||||
| -rw-r--r-- | tests/basic/volume-status.t | 11 |
9 files changed, 524 insertions, 71 deletions
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; |
