Use tox to satisfy functional test requirements

Instead of installing and polluting the host development system
with the required packages to run the functional tests, it is
now possible to run the functional tests from inside tox.  All
the required packages are installed in the tox environment and
run from there.

The only external dependencies are that the functional tests
still must use /etc/swift for configuration files on the host
and /mnt/gluster-object must be on a XFS or GlusterFS volume.

Change-Id: I4a949dbcad778018e22c61d09ae1ba5f21a03aec
Signed-off-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/5976
Reviewed-by: Peter Portante <pportant@redhat.com>
Tested-by: Peter Portante <pportant@redhat.com>
This commit is contained in:
Luis Pabon 2013-09-19 13:18:17 -04:00 committed by Peter Portante
parent 7d5e6ed57e
commit b8bc402508
5 changed files with 45 additions and 36 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ test/unit/nosetests.xml
test/unit/coverage.xml test/unit/coverage.xml
test/unit/cover test/unit/cover
build build
*.pyc

View File

@ -12,12 +12,20 @@ changes to Gerrit. Follow the the information given
at [GitHub Generating SSH Keys][] if you need help creating your key. at [GitHub Generating SSH Keys][] if you need help creating your key.
### Package Requirements ### Package Requirements
Type the following to install the required packages:
#### Fedora 19 * Ubuntu
On Fedora 19 systems, type:
~~~ ~~~
sudo yum install gcc python-devel python-setuptools libffi-devel git rpm-build sudo apt-get -y install gcc python-dev python-setuptools libffi-dev \
git xfsprogs memcached
~~~
* Fedora 19
~~~
sudo yum install gcc python-devel python-setuptools libffi-devel \
git rpm-build xfsprogs memcached
~~~ ~~~
### Git Setup ### Git Setup
@ -51,7 +59,7 @@ It is recommended to use this tool to upload, modify, and query changes in Gerri
The tool can be installed by running the following command: The tool can be installed by running the following command:
~~~ ~~~
sudo pip install git-review sudo pip install --upgrade git-review
~~~ ~~~
While many Linux distributions offer a version of `git review`, While many Linux distributions offer a version of `git review`,
@ -93,7 +101,7 @@ Like OpenStack Swift, Gluster for Swift uses `tox` python virtual
environment for its unit tests. To install `tox` type: environment for its unit tests. To install `tox` type:
~~~ ~~~
pip install tox nose sudo pip install --upgrade tox nose
~~~ ~~~
## Workflow ## Workflow
@ -136,28 +144,19 @@ tests are available under the `test/unit` directory.
#### Functional Tests #### Functional Tests
##### OpenStack Swift Havana Setup
Currently, Havana OpenStack Swift is still under development. While
currently there is no official release for Havana Swift, there is a
yum repo with multiple Havana Swift RPM development releases available.
Please refer to the following [README][] file for more information.
##### Executing the tests ##### Executing the tests
The automated functional tests only run on RPM based systems To run the functional tests, the following requirements must be met.
like Fedora/CentOS, etc. To run the functional tests, the following
requirements must be met.
1. `/etc/swift` must not exist. 1. `/etc/swift` must not exist.
1. User needs to have `sudo` access; no password necessary 1. User needs to have `sudo` access
1. `/mnt/gluster-object/test` and `/mnt/gluster-object/test2` directories 1. `/mnt/gluster-object/test` and `/mnt/gluster-object/test2` directories
must be created on either an XFS or GlusterFS volume. must be created on either an XFS or GlusterFS volume.
1. glusterfs-openstack-swift RPM must not be installed on the system
Once the requirements have been met, you can now run the full functional Once the requirements have been met, you can now run the full functional
tests using the following command: tests using the following command:
~~~ ~~~
tools/functional_tests.sh tox -e functest
~~~ ~~~
### Commiting changes ### Commiting changes

View File

@ -33,15 +33,21 @@ setup(
packages=find_packages(exclude=['test', 'bin']), packages=find_packages(exclude=['test', 'bin']),
test_suite='nose.collector', test_suite='nose.collector',
classifiers=[ classifiers=[
'Development Status :: 4 - Beta', 'Development Status :: 5 - Production/Stable'
'License :: OSI Approved :: Apache Software License', 'Environment :: OpenStack'
'Operating System :: POSIX :: Linux', 'Intended Audience :: Information Technology'
'Programming Language :: Python :: 2.6', 'Intended Audience :: System Administrators'
'Environment :: No Input/Output (Daemon)', 'License :: OSI Approved :: Apache Software License'
'Operating System :: POSIX :: Linux'
'Programming Language :: Python'
'Programming Language :: Python :: 2'
'Programming Language :: Python :: 2.6'
'Programming Language :: Python :: 2.7'
], ],
install_requires=[], # removed for better compat install_requires=[],
scripts=[ scripts=[
'bin/gluster-swift-gen-builders', 'bin/gluster-swift-gen-builders',
'bin/gluster-swift-print-metadata',
], ],
entry_points={ entry_points={
'paste.app_factory': [ 'paste.app_factory': [

View File

@ -15,13 +15,18 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Globals # This program expects to be run by tox in a virtual python environment
# so that it does not pollute the host development system
sudo_env()
{
sudo bash -c "PATH=$PATH $*"
}
cleanup() cleanup()
{ {
sudo service memcached stop sudo service memcached stop
sudo swift-init main stop sudo_env swift-init main stop
sudo pip uninstall -y gluster-swift
sudo rm -rf /etc/swift > /dev/null 2>&1 sudo rm -rf /etc/swift > /dev/null 2>&1
sudo rm -rf /mnt/gluster-object/test{,2}/* > /dev/null 2>&1 sudo rm -rf /mnt/gluster-object/test{,2}/* > /dev/null 2>&1
sudo setfattr -x user.swift.metadata /mnt/gluster-object/test{,2} > /dev/null 2>&1 sudo setfattr -x user.swift.metadata /mnt/gluster-object/test{,2} > /dev/null 2>&1
@ -57,21 +62,14 @@ done
export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf export SWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf
# Download and cache swift
pip install --no-install --download-cache=$HOME/.pipcache swift==1.9.1
# Install swift
sudo pip install --download-cache=$HOME/.pipcache swift==1.9.1
# Install gluster-swift
sudo pip install -e $PWD
# Install the configuration files # Install the configuration files
sudo mkdir /etc/swift > /dev/null 2>&1 sudo mkdir /etc/swift > /dev/null 2>&1
sudo cp -r test/functional/conf/* /etc/swift || fail "Unable to copy configuration files to /etc/swift" 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" sudo_env gluster-swift-gen-builders test test2 || fail "Unable to create ring files"
# Start the services # Start the services
sudo service memcached start || fail "Unable to start memcached" sudo service memcached start || fail "Unable to start memcached"
sudo swift-init main start || fail "Unable to start swift" sudo_env swift-init main start || fail "Unable to start swift"
mkdir functional_tests > /dev/null 2>&1 mkdir functional_tests > /dev/null 2>&1
nosetests -v --exe \ nosetests -v --exe \

View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = py26,py27,pep8 envlist = py26,py27,pep8,functest
[testenv] [testenv]
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
@ -18,6 +18,11 @@ commands = nosetests -v --exe --with-xunit --with-coverage --cover-package glust
[tox:jenkins] [tox:jenkins]
downloadcache = ~/cache/pip downloadcache = ~/cache/pip
[testenv:functest]
changedir = {toxinidir}
whitelist_externals=bash
commands = bash tools/functional_tests.sh
[testenv:pep8] [testenv:pep8]
changedir = {toxinidir} changedir = {toxinidir}
commands = commands =