swiftonfile/tools/functional_tests.sh
Luis Pabon c52b889657 Automate functional tests
By storing the functional tests configuration files in the
repo, we can now run the functional_tests.sh to setup,
run the functional tests, and teardown.

Most likely this will be able to be run as a user from
the same directory as the repo, but at the moment, the
configuration files are copied to /etc/swift.

The only requirements are:
1. /etc/swift does not exist.  That way the tests will
not interfere with an existing deployment.
2. /mnt/gluster-object/test and /mnt/gluster-object/test2
must have been created and setup correctly on an XFS
or GlusterFS volume
3. sudo rights without password prompt
4. glusterfs-openstack-swift-* rpm must not be installed
on the system

Once the requirements are met, you can execute the tests
as follows:

$ bash tools/functional_tests.sh

Change-Id: Icdbcd420355b02e64f294df7298a3e473b343655
Signed-off-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/5281
Reviewed-by: Peter Portante <pportant@redhat.com>
2013-07-03 11:09:26 -07:00

64 lines
1.6 KiB
Bash

#!/bin/bash
cleanup()
{
sudo service memcached stop
sudo swift-init main stop
sudo yum -y remove glusterfs-openstack-swift
sudo rm -rf /etc/swift > /dev/null 2>&1
}
quit()
{
echo "$1"
exit 1
}
fail()
{
cleanup
quit "$1"
}
### MAIN ###
# Only run if there is no configuration in the system
if [ -x /etc/swift ] ; then
quit "/etc/swift exists, cannot run functional tests."
fi
# Check the directories exist
DIRS="/mnt/gluster-object /mnt/gluster-object/test /mnt/gluster-object/test2"
for d in $DIRS ; do
if [ ! -x $d ] ; then
quit "$d must exist on an XFS or GlusterFS volume"
fi
done
export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf
# Create and install the rpm
PKG_RELEASE=functest bash makerpm.sh
sudo yum -y install build/glusterfs-openstack-swift-1.8.0-functest.noarch.rpm || fail "Unable to install rpm"
# Install the configuration files
mkdir /etc/swift > /dev/null 2>&1
sudo cp -r test/functional/conf/* /etc/swift || fail "Unable to copy configuration files to /etc/swift"
( cd /etc/swift ; sudo gluster-swift-gen-builders test test2 ) || fail "Unable to create ring files"
# Start the services
sudo service memcached start || fail "Unable to start memcached"
sudo swift-init main start || fail "Unable to start swift"
mkdir functional_tests > /dev/null 2>&1
nosetests -v --exe \
--with-xunit \
--xunit-file functional_tests/gluster-swift-functional-TC-report.xml test/functional || fail "Functional tests failed"
nosetests -v --exe \
--with-xunit \
--xunit-file functional_tests/gluster-swift-functionalnosetests-TC-report.xml test/functionalnosetests || fail "Functional-nose tests failed"
cleanup
exit 0