From c52b88965707c0f6a1cd35143161410be0fdfe92 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Wed, 3 Jul 2013 13:04:02 -0400 Subject: 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 Reviewed-on: http://review.gluster.org/5281 Reviewed-by: Peter Portante --- tools/functional_tests.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tools/functional_tests.sh (limited to 'tools/functional_tests.sh') diff --git a/tools/functional_tests.sh b/tools/functional_tests.sh new file mode 100644 index 0000000..155978b --- /dev/null +++ b/tools/functional_tests.sh @@ -0,0 +1,63 @@ +#!/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 -- cgit