Use ostestr unit test runner

This patch moves ironic-inspector to use 'stestr' test runner
via 'ostestr' wrapper.

Effective changes:

- unit tests are now being run in parallel by default
- 'py*' jobs are not running code coverage measurements,
  which is left for 'cover' job only
- 'cover' job now also produces html reports consumable by upstream CI,
  and fails under 90% of code coverage
- users can leverage all the ostestr/stestr features

Change-Id: I75f539457dbb1d811fdee69de52d1bcee4c6ebe6
Depends-On: Ica838db23b5714c2da1e4313e1a7ece0ca241d44
Closes-Bug: #1666232
This commit is contained in:
Pavlo Shchelokovskyy 2017-09-28 10:43:07 +00:00 committed by Milan Kováčik
parent 37b556ab7a
commit 7625ed68c8
4 changed files with 20 additions and 7 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ develop-eggs
# Other # Other
*.DS_Store *.DS_Store
.idea .idea
.stestr
.testrepository .testrepository
.tox .tox
.venv .venv

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${TESTS_DIR:-./ironic_inspector/test/unit/}
top_dir=./

View File

@ -8,6 +8,7 @@ hacking<0.13,>=0.12.0 # Apache-2.0
mock>=2.0.0 # BSD mock>=2.0.0 # BSD
sphinx>=1.6.2 # BSD sphinx>=1.6.2 # BSD
openstackdocstheme>=1.17.0 # Apache-2.0 openstackdocstheme>=1.17.0 # Apache-2.0
os-testr>=1.0.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0 reno>=2.5.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
testresources>=2.0.0 # Apache-2.0/BSD testresources>=2.0.0 # Apache-2.0/BSD

20
tox.ini
View File

@ -8,10 +8,12 @@ deps =
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
-r{toxinidir}/plugin-requirements.txt -r{toxinidir}/plugin-requirements.txt
commands = commands =
coverage run --branch --include "ironic_inspector*" -m unittest discover ironic_inspector.test.unit ostestr {posargs}
coverage report -m --fail-under 90 setenv =
setenv = PYTHONDONTWRITEBYTECODE=1 VIRTUAL_ENV={envdir}
TZ=UTC PYTHONDONTWRITEBYTECODE=1
TZ=UTC
TESTS_DIR=./ironic_inspector/test/unit/
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
[testenv:venv] [testenv:venv]
@ -22,9 +24,15 @@ envdir = {toxworkdir}/venv
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:cover] [testenv:cover]
setenv =
{[testenv]setenv}
PYTHON=coverage run --branch --omit='*test*' --source ironic_inspector --parallel-mode
commands = commands =
coverage run --branch --include "ironic_inspector*" -m unittest discover ironic_inspector.test.unit coverage erase
coverage report -m ostestr {posargs}
coverage combine
coverage report -m --omit='*test*' --fail-under 90
coverage html -d ./cover --omit='*test*'
[testenv:pep8] [testenv:pep8]
basepython = python2.7 basepython = python2.7