Merge "Add method to tox to use local neutron-lib with unit tests"

This commit is contained in:
Zuul 2019-03-04 19:40:17 +00:00 committed by Gerrit Code Review
commit 21f6edf1e4
3 changed files with 65 additions and 2 deletions

View File

@ -509,6 +509,41 @@ To run only the unit tests::
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
~~~~~~~~~~~~~~~~

View File

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

View File

@ -9,7 +9,7 @@ setenv = VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
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
install_command =
pip install {opts} {packages}
@ -18,7 +18,10 @@ deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
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
# mode. To do this define the TRACE_FAILONLY environmental variable.