Backport tox.ini to switch to stestr

The pike branch was still using ostestr (instead of stestr) which makes
running tests significantly different from queens or master. To make
things behave the same way this commit backports most of the tox.ini
from queens so that pike will behave the same way for running tests.
This does not use the standard backport mechanism because it involves a
lot of different commits over time. It's also not a functional change
for nova itself, so the proper procedure is less important here.

Change-Id: Ie207afaf8defabc1d1eb9332f43a9753a00f784d
This commit is contained in:
Matthew Treinish 2018-07-05 16:09:17 -04:00
parent 966a5a2154
commit 5939ae995f
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177
5 changed files with 52 additions and 40 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@
.pydevproject
.ropeproject
.testrepository/
.stestr/
.tox
.idea
.venv

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=./nova/tests/unit
top_dir=./

View File

@ -1,18 +0,0 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./nova/tests} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
# NOTE(cdent): The group_regex describes how testrepository will
# group tests into the same process when running concurently. The
# following insures that gabbi tests coming from the same YAML file
# are all in the same process. This is important because each YAML
# file represents an ordered sequence of HTTP requests. Note that
# tests which do not match this regex will not be grouped in any
# special way. See the following for more details.
# http://testrepository.readthedocs.io/en/latest/MANUAL.html#grouping-tests
# https://gabbi.readthedocs.io/en/latest/#purpose
group_regex=nova\.tests\.functional\.api\.openstack\.placement\.test_placement_api(?:\.|_)([^_]+)

View File

@ -17,9 +17,8 @@ requests-mock>=1.1 # Apache-2.0
sphinx>=1.6.2 # BSD
os-api-ref>=1.0.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
os-testr>=0.8.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD
testresources>=0.2.4 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=1.4.0 # MIT

67
tox.ini
View File

@ -12,13 +12,14 @@ whitelist_externals = bash
env
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike} {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=./nova/tests/unit
LANGUAGE=en_US
LC_ALL=en_US.utf-8
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=160
deps = -r{toxinidir}/test-requirements.txt
commands =
find . -type f -name "*.pyc" -delete
rm -Rf .testrepository/times.dbm
passenv = OS_DEBUG GENERATE_HASHES
# there is also secret magic in subunit-trace which lets you run in a fail only
# mode. To do this define the TRACE_FAILONLY environmental variable.
@ -26,12 +27,21 @@ passenv = OS_DEBUG GENERATE_HASHES
[testenv:py27]
commands =
{[testenv]commands}
ostestr '{posargs}'
stestr run '{posargs}'
env TEST_OSPROFILER=1 stestr run --combine --no-discover 'nova.tests.unit.test_profiler'
stestr slowest
[testenv:py35]
commands =
{[testenv]commands}
bash tools/pretty_tox3.sh '{posargs}'
stestr run --blacklist-file=tests-py3.txt '{posargs}'
env TEST_OSPROFILER=1 stestr run --combine --no-discover 'nova.tests.unit.test_profiler'
[testenv:py36]
commands =
{[testenv]commands}
stestr run --blacklist-file=tests-py3.txt '{posargs}'
env TEST_OSPROFILER=1 stestr run --combine --no-discover 'nova.tests.unit.test_profiler'
[testenv:pep8]
basepython = python2.7
@ -57,35 +67,47 @@ commands =
# python 3.x
basepython = python2.7
usedevelop = True
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=./nova/tests/functional
LANGUAGE=en_US
setenv = {[testenv]setenv}
commands =
find . -type f -name "*.pyc" -delete
ostestr '{posargs}'
{[testenv]commands}
# NOTE(cdent): The group_regex describes how stestr will group tests into the
# same process when running concurently. The following ensures that gabbi tests
# coming from the same YAML file are all in the same process. This is important
# because each YAML file represents an ordered sequence of HTTP requests. Note
# that tests which do not match this regex will not be grouped in any
# special way. See the following for more details.
# http://stestr.readthedocs.io/en/latest/MANUAL.html#grouping-tests
# https://gabbi.readthedocs.io/en/latest/#purpose
stestr --test-path=./nova/tests/functional --group-regex=nova\.tests\.functional\.api\.openstack\.placement\.test_placement_api(?:\.|_)([^_]+) run '{posargs}'
stestr slowest
# TODO(gcb) Merge this into [testenv:functional] when functional tests are gating
# with python 3.5
[testenv:functional-py35]
basepython = python3.5
usedevelop = True
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=./nova/tests/functional
LANGUAGE=en_US
setenv = {[testenv]setenv}
commands =
{[testenv]commands}
bash tools/pretty_tox3.sh '{posargs}'
# NOTE(cdent): The group_regex describes how stestr will group tests into the
# same process when running concurently. The following ensures that gabbi tests
# coming from the same YAML file are all in the same process. This is important
# because each YAML file represents an ordered sequence of HTTP requests. Note
# that tests which do not match this regex will not be grouped in any
# special way. See the following for more details.
# http://stestr.readthedocs.io/en/latest/MANUAL.html#grouping-tests
# https://gabbi.readthedocs.io/en/latest/#purpose
stestr --test-path=./nova/tests/functional --group-regex=nova\.tests\.functional\.api\.openstack\.placement\.test_placement_api(?:\.|_)([^_]+) run '{posargs}'
[testenv:api-samples]
usedevelop = True
setenv = VIRTUAL_ENV={envdir}
GENERATE_SAMPLES=True
PYTHONHASHSEED=0
OS_TEST_PATH=./nova/tests/functional/api_sample_tests
LANGUAGE=en_US
setenv = {[testenv]setenv}
GENERATE_SAMPLES=True
PYTHONHASHSEED=0
commands =
find . -type f -name "*.pyc" -delete
ostestr '{posargs}'
stestr --test-path=./nova/tests/functional/api_sample_tests run '{posargs}'
stestr slowest
[testenv:genconfig]
commands = oslo-config-generator --config-file=etc/nova/nova-config-generator.conf
@ -96,10 +118,15 @@ commands = oslopolicy-sample-generator --config-file=etc/nova/nova-policy-genera
[testenv:cover]
# Also do not run test_coverage_ext tests while gathering coverage as those
# tests conflict with coverage.
setenv = {[testenv]setenv}
PYTHON=coverage run --source nova --parallel-mode
commands =
coverage erase
find . -type f -name "*.pyc" -delete
python setup.py testr --coverage --testr-args='{posargs}'
stestr run '{posargs}'
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report
[testenv:debug]