Add method to tox to use local neutron-lib with unit tests
Change-Id: Ic96bb04cc3f9ed1438596b2150030ab22887b091
This commit is contained in:
parent
4699801d42
commit
55f2336981
35
TESTING.rst
35
TESTING.rst
|
@ -509,6 +509,41 @@ To run only the unit tests::
|
||||||
|
|
||||||
tox -e py27
|
tox -e py27
|
||||||
|
|
||||||
|
Many changes span across both the neutron and neutron-lib repos, and tox
|
||||||
|
will always build the test environment using the published module versions
|
||||||
|
specified in requirements.txt and lower-constraints.txt. To run tox tests
|
||||||
|
against a different version of neutron-lib, use the TOX_ENV_SRC_MODULES
|
||||||
|
environment variable to point at a local package repo.
|
||||||
|
|
||||||
|
For example, to run against the 'master' branch of neutron-lib:
|
||||||
|
|
||||||
|
cd $SRC
|
||||||
|
git clone git://git.openstack.org/openstack/neutron-lib
|
||||||
|
cd $NEUTRON_DIR
|
||||||
|
env TOX_ENV_SRC_MODULES=$SRC/neutron-lib tox -r -e pep8,py27
|
||||||
|
|
||||||
|
To run against a change of your own, repeat the same steps, but use the
|
||||||
|
directory with your changes, not a fresh clone.
|
||||||
|
|
||||||
|
To run against a particular gerrit change of the lib (substituting the
|
||||||
|
desired gerrit refs for this example):
|
||||||
|
|
||||||
|
cd $SRC
|
||||||
|
git clone git://git.openstack.org/openstack/neutron-lib
|
||||||
|
cd neutron-lib
|
||||||
|
git fetch git://git.openstack.org/openstack/neutron-lib refs/changes/13/635313/6 && git checkout FETCH_HEAD
|
||||||
|
cd $NEUTRON_DIR
|
||||||
|
env TOX_ENV_SRC_MODULES=$SRC/neutron-lib tox -r -e pep8,py27
|
||||||
|
|
||||||
|
Note that the '-r' is needed to re-create the tox virtual envs, and will also
|
||||||
|
be needed to restore them to standard when not using this method.
|
||||||
|
|
||||||
|
Any pip installable package can be overriden with this environment variable,
|
||||||
|
not just neutron-lib. To specify multiple packages to override, specify them
|
||||||
|
as a space separated list to TOX_ENV_SRC_MODULES. Example:
|
||||||
|
|
||||||
|
env TOX_ENV_SRC_MODULES="$SRC/neutron-lib $SRC/oslo.db" tox -r -e pep8,py27
|
||||||
|
|
||||||
Functional Tests
|
Functional Tests
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# For neutron unit tests, you can define git repos containing modules
|
||||||
|
# that you want to use to override the requirements-based packages.
|
||||||
|
#
|
||||||
|
# Why, you ask? Because you made changes to neutron-lib, and you want
|
||||||
|
# run the unit tests together. E.g.:
|
||||||
|
#
|
||||||
|
# env TOX_ENV_SRC_MODULES="$HOME/src/neutron-lib" tox -e py27
|
||||||
|
|
||||||
|
toxinidir="$1"
|
||||||
|
|
||||||
|
if [ -z "$TOX_ENV_SRC_MODULES" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for repo in $TOX_ENV_SRC_MODULES; do
|
||||||
|
d="${toxinidir}/${repo}"
|
||||||
|
if [ ! -d "$d" ]; then
|
||||||
|
echo "tox_env_src: error: no directory found at $d"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "tox_env_src: pip installing from $d"
|
||||||
|
pip install -e "$d"
|
||||||
|
done
|
7
tox.ini
7
tox.ini
|
@ -9,7 +9,7 @@ setenv = VIRTUAL_ENV={envdir}
|
||||||
OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
|
OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
|
||||||
OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
|
OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
|
||||||
PYTHONWARNINGS=default::DeprecationWarning,ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site
|
PYTHONWARNINGS=default::DeprecationWarning,ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site
|
||||||
passenv = TRACE_FAILONLY GENERATE_HASHES http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
|
passenv = TRACE_FAILONLY GENERATE_HASHES http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY TOX_ENV_SRC_MODULES
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
install_command =
|
install_command =
|
||||||
pip install {opts} {packages}
|
pip install {opts} {packages}
|
||||||
|
@ -18,7 +18,10 @@ deps =
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
whitelist_externals = sh
|
whitelist_externals = sh
|
||||||
commands = stestr run {posargs}
|
commands =
|
||||||
|
{toxinidir}/tools/pip_install_src_modules.sh "{toxinidir}"
|
||||||
|
stestr run {posargs}
|
||||||
|
|
||||||
# there is also secret magic in ostestr which lets you run in a fail only
|
# there is also secret magic in ostestr which lets you run in a fail only
|
||||||
# mode. To do this define the TRACE_FAILONLY environmental variable.
|
# mode. To do this define the TRACE_FAILONLY environmental variable.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue