summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLuis Pabon <lpabon@redhat.com>2013-07-03 13:04:02 -0400
committerLuis Pabon <lpabon@redhat.com>2013-07-03 11:09:26 -0700
commitc52b88965707c0f6a1cd35143161410be0fdfe92 (patch)
tree86eb39433b06a7f4af5894ad003448d922f41db0 /tools
parentceb18f16ccbfecd5ac36c1623629c2c2c33f307a (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/functional_tests.sh63
1 files changed, 63 insertions, 0 deletions
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