Skip to content

Commit

Permalink
Backport tox.ini to switch to stestr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mtreinish committed Jul 5, 2018
1 parent 966a5a2 commit 5939ae9
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,6 +14,7 @@
.pydevproject
.ropeproject
.testrepository/
.stestr/
.tox
.idea
.venv
Expand Down
3 changes: 3 additions & 0 deletions .stestr.conf
@@ -0,0 +1,3 @@
[DEFAULT]
test_path=./nova/tests/unit
top_dir=./
18 changes: 0 additions & 18 deletions .testr.conf

This file was deleted.

3 changes: 1 addition & 2 deletions test-requirements.txt
Expand Up @@ -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
Expand Down
67 changes: 47 additions & 20 deletions tox.ini
Expand Up @@ -12,26 +12,36 @@ 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.

[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
Expand All @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit 5939ae9

Please sign in to comment.