From 7625ed68c8f8f946323b129ddd116e0261668a75 Mon Sep 17 00:00:00 2001 From: Pavlo Shchelokovskyy Date: Thu, 28 Sep 2017 10:43:07 +0000 Subject: [PATCH] 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 --- .gitignore | 3 ++- .stestr.conf | 3 +++ test-requirements.txt | 1 + tox.ini | 20 ++++++++++++++------ 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .stestr.conf diff --git a/.gitignore b/.gitignore index 82f0112dd..4153f8687 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ develop-eggs # Other *.DS_Store .idea +.stestr .testrepository .tox .venv @@ -39,4 +40,4 @@ ChangeLog *~ # Vagrant -.vagrant \ No newline at end of file +.vagrant diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 000000000..7111fd065 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=${TESTS_DIR:-./ironic_inspector/test/unit/} +top_dir=./ diff --git a/test-requirements.txt b/test-requirements.txt index 2de4c9cbc..592f4c5f8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,6 +8,7 @@ hacking<0.13,>=0.12.0 # Apache-2.0 mock>=2.0.0 # BSD sphinx>=1.6.2 # BSD openstackdocstheme>=1.17.0 # Apache-2.0 +os-testr>=1.0.0 # Apache-2.0 reno>=2.5.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD testresources>=2.0.0 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index 6d79ffbf7..fd77bfc00 100644 --- a/tox.ini +++ b/tox.ini @@ -8,10 +8,12 @@ deps = -r{toxinidir}/test-requirements.txt -r{toxinidir}/plugin-requirements.txt commands = - coverage run --branch --include "ironic_inspector*" -m unittest discover ironic_inspector.test.unit - coverage report -m --fail-under 90 -setenv = PYTHONDONTWRITEBYTECODE=1 - TZ=UTC + ostestr {posargs} +setenv = + VIRTUAL_ENV={envdir} + PYTHONDONTWRITEBYTECODE=1 + TZ=UTC + TESTS_DIR=./ironic_inspector/test/unit/ passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY [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 [testenv:cover] +setenv = + {[testenv]setenv} + PYTHON=coverage run --branch --omit='*test*' --source ironic_inspector --parallel-mode commands = - coverage run --branch --include "ironic_inspector*" -m unittest discover ironic_inspector.test.unit - coverage report -m + coverage erase + ostestr {posargs} + coverage combine + coverage report -m --omit='*test*' --fail-under 90 + coverage html -d ./cover --omit='*test*' [testenv:pep8] basepython = python2.7