From 3a431dea6cf65547f3ff3a3378c7619f2eaebd2d Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 30 Dec 2011 14:03:15 -0800 Subject: [PATCH] Backport tox support for CI. Add tox.ini file. The tox.ini drives the current test suite in multiple virtual envs, so this is a first step in trying to get multi-version testing. Prep tox config for jenkins builds. Add a generic tox build environment. Allow for the running of arbitrary commands inside of a venv so that we don't have to make tox envs for every blessed thing we want to do. Align to jenkins tox patterns. Split requires in to pip-requires and test-requires. Updated install_venv to know about test-requires. Update tox.ini for jenkins. The tox documentation is wrong, it looks for [tox:jenkins] instead of [tox:hudson]. Also, run "pip freeze" before running tests from within the virtualenv so we have a record of all versions used in each test run in Jenkins. Fix typo in tox.ini. My last commit message was right, the code was wrong. It's tox:jenkins. Commands are invalid in tox: sections, so we'll get pip freeze run another way. Change-Id: I9c28ee11aa7bbe1b221a72e0ee8cc51d788f73c9 --- .gitignore | 1 + setup.cfg | 13 +++++++++++++ tools/install_venv.py | 16 +++++++++++----- tools/pip-requires | 6 ------ tools/test-requires | 11 +++++++++++ tox.ini | 37 +++++++++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 tools/test-requires create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index b1817152a4..00a9311e00 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ *.log .glance-venv .venv +.tox tests.sqlite diff --git a/setup.cfg b/setup.cfg index d53addcbf3..6585cc74e0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,3 +7,16 @@ source-dir = doc/source tag_build = tag_date = 0 tag_svn_revision = 0 + +[nosetests] +# NOTE(jkoelker) To run the test suite under nose install the following +# coverage http://pypi.python.org/pypi/coverage +# tissue http://pypi.python.org/pypi/tissue (pep8 checker) +# openstack-nose https://github.com/jkoelker/openstack-nose +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/tools/install_venv.py b/tools/install_venv.py index 7a9473a63a..cbecd3685e 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -30,6 +30,7 @@ import sys ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) VENV = os.path.join(ROOT, '.venv') PIP_REQUIRES = os.path.join(ROOT, 'tools', 'pip-requires') +TEST_REQUIRES = os.path.join(ROOT, 'tools', 'test-requires') def die(message, *args): @@ -90,14 +91,19 @@ def create_virtualenv(venv=VENV): print 'done.' +def pip_install(*args): + run_command(['tools/with_venv.sh', + 'pip', 'install', '--upgrade'] + list(args), + redirect_output=False) + + def install_dependencies(venv=VENV): print 'Installing dependencies with pip (this can take a while)...' - # Install greenlet by hand - just listing it in the requires file does not - # get it in stalled in the right order - venv_tool = 'tools/with_venv.sh' - run_command([venv_tool, 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES], - redirect_output=False) + pip_install('pip') + + pip_install('-r', PIP_REQUIRES) + pip_install('-r', TEST_REQUIRES) # Tell the virtual env how to "import glance" py_ver = _detect_python_version(venv) diff --git a/tools/pip-requires b/tools/pip-requires index e439219d88..a7d753a9a8 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -1,18 +1,12 @@ greenlet>=0.3.1 SQLAlchemy>=0.6.3,<0.7 -pep8==0.6.1 -pylint==0.19 anyjson eventlet>=0.9.12 PasteDeploy routes webob==1.0.8 wsgiref -nose -nose-exclude -sphinx argparse -mox boto swift -f http://pymox.googlecode.com/files/mox-0.5.0.tar.gz diff --git a/tools/test-requires b/tools/test-requires new file mode 100644 index 0000000000..753315d805 --- /dev/null +++ b/tools/test-requires @@ -0,0 +1,11 @@ +# Packages needed for dev testing +distribute>=0.6.24 + +# Needed for testing +mox +nose +nose-exclude +nosexcover +openstack.nose_plugin +pep8==0.6.1 +sphinx>=1.1.2 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000..f1f1aea0d5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,37 @@ +[tox] +envlist = py26,py27,pep8 + +[testenv] +setenv = VIRTUAL_ENV={envdir} +deps = -r{toxinidir}/tools/pip-requires + -r{toxinidir}/tools/test-requires +commands = nosetests + +[testenv:pep8] +deps = pep8 +commands = pep8 --repeat --show-source bin glance setup.py + +[testenv:cover] +commands = nosetests --with-coverage --cover-html --cover-erase --cover-package=glance + +[testenv:venv] +commands = {posargs} + +[tox:jenkins] +downloadcache = ~/cache/pip + +[testenv:jenkins26] +basepython = python2.6 +deps = file://{toxinidir}/.cache.bundle + +[testenv:jenkins27] +basepython = python2.7 +deps = file://{toxinidir}/.cache.bundle + +[testenv:jenkinscover] +deps = file://{toxinidir}/.cache.bundle +commands = nosetests --cover-erase --cover-package=glance --with-xcoverage + +[testenv:jenkinsvenv] +deps = file://{toxinidir}/.cache.bundle +commands = {posargs}