diff options
author | Maru Newby <mnewby@internap.com> | 2012-01-31 15:27:29 -0800 |
---|---|---|
committer | Maru Newby <mnewby@internap.com> | 2012-03-07 22:44:34 -0800 |
commit | e6ea310751b58be0ad1d06d8acffc2b8fff8e5a3 (patch) | |
tree | 88835ec3e296df06a2c131f40278031fe39c362e | |
parent | ad6684a00f3952d5857035f0c2a4305224512567 (diff) | |
download | swift-e6ea310751b58be0ad1d06d8acffc2b8fff8e5a3.tar.gz |
Add support for venv-based test run with tox.
* Adds tox config
- based on the config from python-quantumclient and updated for
test, pep8 and coverage execution as per nova's run_tests.sh.
* Adds nosetests defaults in setup.cfg
* Adds runtime dependencies in tools/pip-requires
- dependencies were gathered by referencing the packages used in
creation of a Swift All In One. Versions were determined by
checking the swift-core/trunk ppa or, failing that, the version
available in lucid.
* Adds test dependencies in tools/test-requires
* Updates swift/common/middleware/formpost.py for pep8 compliance
* Adds instructions for executing the tests with Tox to the
developer_guidelines
* Adds instructions for installing openstack.nose_plugin to
developer_saio
* Fixes bug 909177
Change-Id: I5407924d2181e9ab335aaf76bf30c8d40deccbb4
-rwxr-xr-x | .functests | 4 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | .probetests | 2 | ||||
-rwxr-xr-x | .unittests | 2 | ||||
-rw-r--r-- | doc/source/development_guidelines.rst | 26 | ||||
-rw-r--r-- | doc/source/development_saio.rst | 2 | ||||
-rw-r--r-- | setup.cfg | 10 | ||||
-rw-r--r-- | swift/common/middleware/formpost.py | 2 | ||||
-rw-r--r-- | tools/pip-requires | 8 | ||||
-rw-r--r-- | tools/test-requires | 5 | ||||
-rw-r--r-- | tox.ini | 41 |
11 files changed, 98 insertions, 5 deletions
diff --git a/.functests b/.functests index a0123679c..fb2b0eb2e 100755 --- a/.functests +++ b/.functests @@ -1,4 +1,4 @@ #!/bin/bash -nosetests test/functional --exe $@ -nosetests test/functionalnosetests --exe $@ +nosetests test/functional $@ +nosetests test/functionalnosetests $@ diff --git a/.gitignore b/.gitignore index 8e13a40f6..6dac914d6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ ChangeLog .coverage swift.egg-info .DS_Store +.tox diff --git a/.probetests b/.probetests index 751469386..1fdd91816 100755 --- a/.probetests +++ b/.probetests @@ -1,3 +1,3 @@ #!/bin/bash -nosetests test/probe --exe +nosetests test/probe diff --git a/.unittests b/.unittests index f0ecf0581..aa54b06ff 100755 --- a/.unittests +++ b/.unittests @@ -1,4 +1,4 @@ #!/bin/bash -nosetests test/unit --exe --with-coverage --cover-package swift --cover-erase $@ +nosetests test/unit --with-coverage --cover-package swift --cover-erase $@ rm -f .coverage diff --git a/doc/source/development_guidelines.rst b/doc/source/development_guidelines.rst index 9abda8c90..70e299375 100644 --- a/doc/source/development_guidelines.rst +++ b/doc/source/development_guidelines.rst @@ -12,6 +12,32 @@ here: http://www.python.org/dev/peps/pep-0008/ There is a useful pep8 command line tool for checking files for pep8 compliance which can be installed with ``easy_install pep8``. +------------------ +Testing Guidelines +------------------ + +Swift has a comprehensive suite of tests that are run on all submitted code, +and it is recommended that developers execute the tests themselves to +catch regressions early. Developers are also expected to keep the +test suite up-to-date with any submitted code changes. + +Swift's suite of unit tests can be executed in an isolated environment +with Tox: http://tox.testrun.org/ + +To execute the unit tests: + +* Install Tox: + + - `pip install tox` + +* Run Tox from the root of the swift repo: + + - `tox` + +* Optionally, run only specific tox builds: + + - `tox -e pep8,py26` + ------------------------ Documentation Guidelines ------------------------ diff --git a/doc/source/development_saio.rst b/doc/source/development_saio.rst index 165b60350..38cb60977 100644 --- a/doc/source/development_saio.rst +++ b/doc/source/development_saio.rst @@ -32,6 +32,7 @@ Installing dependencies and the core code python-coverage python-dev python-nose python-setuptools python-simplejson python-xattr sqlite3 xfsprogs python-webob python-eventlet python-greenlet python-pastedeploy python-netifaces` + #. `pip install openstack.nose_plugin` #. Install anything else you want, like screen, ssh, vim, etc. * On Fedora, log in as root and do: @@ -41,6 +42,7 @@ Installing dependencies and the core code #. `yum install xinetd rsync` #. `yum install memcached` #. `yum install python-netifaces python-nose` + #. `pip install openstack.nose_plugin` This installs all necessary dependencies, and also creates user `swift` and group `swift`. So, `swift:swift` ought to be used in every place where @@ -21,3 +21,13 @@ input_file = locale/swift.pot keywords = _ l_ lazy_gettext mapping_file = babel.cfg output_file = locale/swift.pot + +[nosetests] +exe=1 +verbosity=2 +detailed-errors=1 +with-openstack=1 +openstack-red=0.05 +openstack-yellow=0.025 +openstack-show-elapsed=1 +openstack-color=1 diff --git a/swift/common/middleware/formpost.py b/swift/common/middleware/formpost.py index d52653300..dfef63773 100644 --- a/swift/common/middleware/formpost.py +++ b/swift/common/middleware/formpost.py @@ -258,7 +258,7 @@ class _CappedFileLikeObject(object): EOFError. """ - def __init__(self, fp, max_file_size): + def __init__(self, fp, max_file_size): self.fp = fp self.max_file_size = max_file_size self.amount_read = 0 diff --git a/tools/pip-requires b/tools/pip-requires new file mode 100644 index 000000000..f9ea5f241 --- /dev/null +++ b/tools/pip-requires @@ -0,0 +1,8 @@ +WebOb==1.0.8 +configobj==4.7.1 +eventlet==0.9.15 +greenlet==0.3.1 +netifaces==0.6 +pastedeploy==1.3.3 +simplejson==2.0.9 +xattr==0.4 diff --git a/tools/test-requires b/tools/test-requires new file mode 100644 index 000000000..8be4eb9da --- /dev/null +++ b/tools/test-requires @@ -0,0 +1,5 @@ +coverage +nose +nosexcover +openstack.nose_plugin +pep8==0.6.1 diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..c9afb3534 --- /dev/null +++ b/tox.ini @@ -0,0 +1,41 @@ +[tox] +envlist = py26,py27,pep8 + +[testenv] +deps = + -r{toxinidir}/tools/pip-requires + -r{toxinidir}/tools/test-requires +commands = nosetests test/unit [] + +[testenv:pep8] +deps = pep8==0.6.1 +commands = + pep8 --repeat --show-pep8 --show-source --ignore=W602 swift tools setup.py + +[testenv:cover] +commands = + coverage erase + nosetests test/unit --with-coverage --cover-html --cover-erase \ + --cover-package=swift + /bin/rm -f .coverage + +[testenv:hudson] +downloadcache = ~/cache/pip + +[testenv:jenkins26] +basepython = python2.6 +deps = file://{toxinidir}/.cache.bundle + +[testenv:jenkins27] +basepython = python2.7 +deps = file://{toxinidir}/.cache.bundle + +[testenv:jenkinspep8] +deps = file://{toxinidir}/.cache.bundle +commands = + pep8 --repeat --show-pep8 --show-source --ignore=W602 swift tools setup.py + +[testenv:jenkinscover] +deps = file://{toxinidir}/.cache.bundle +commands = + nosetests test/unit --with-xcoverage --cover-erase --cover-package=swift |