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
This commit is contained in:
Monty Taylor 2011-12-30 14:03:15 -08:00 committed by Eoghan Glynn
parent 5b86b1fdf7
commit 3a431dea6c
6 changed files with 73 additions and 11 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@
*.log
.glance-venv
.venv
.tox
tests.sqlite

View File

@ -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

View File

@ -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)

View File

@ -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

11
tools/test-requires Normal file
View File

@ -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

37
tox.ini Normal file
View File

@ -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}