Migrate to stestr as unit tests runner

Recent update brought os-testr 1.0.0 that already uses stestr test [1]
runner instead of testrepository. This patch migrates those places using
testrepository to using stestr.

[1] http://lists.openstack.org/pipermail/openstack-dev/2017-September/122135.html

Co-Authored-By: Nate Johnston <nate.johnston@redhat.com>
Change-Id: I36f922799fa5a0ed75f412999922f7d5bab180cc
This commit is contained in:
Yushiro FURUKAWA 2017-09-20 17:00:08 +09:00
parent 61294f5103
commit 0a2bef43e3
5 changed files with 24 additions and 16 deletions

1
.gitignore vendored
View File

@ -32,6 +32,7 @@ subunit.log
!/.pylintrc !/.pylintrc
!/.testr.conf !/.testr.conf
!/.zuul.yaml !/.zuul.yaml
!/.stestr.conf
# Files created by releasenotes build # Files created by releasenotes build
releasenotes/build releasenotes/build

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${OS_TEST_PATH:-./neutron_fwaas/tests/unit}
top_dir=./

View File

@ -12,11 +12,11 @@ venv=${1:-"dsvm-functional"}
function generate_testr_results { function generate_testr_results {
# Give job user rights to access tox logs # Give job user rights to access tox logs
sudo -H -u $owner chmod o+rw . sudo -H -u $owner chmod o+rw .
sudo -H -u $owner chmod o+rw -R .testrepository sudo -H -u $owner chmod o+rw -R .stestr
if [ -f ".testrepository/0" ] ; then if [ -f ".stestr/0" ] ; then
.tox/$venv/bin/subunit-1to2 < .testrepository/0 > ./testrepository.subunit .tox/$venv/bin/subunit-1to2 < .stestr/0 > ./stestr.subunit
$SCRIPTS_DIR/subunit2html ./testrepository.subunit testr_results.html $SCRIPTS_DIR/subunit2html ./stestr.subunit testr_results.html
gzip -9 ./testrepository.subunit gzip -9 ./stestr.subunit
gzip -9 ./testr_results.html gzip -9 ./testr_results.html
sudo mv ./*.gz /opt/stack/logs/ sudo mv ./*.gz /opt/stack/logs/
fi fi

View File

@ -10,7 +10,7 @@ python-subunit>=1.0.0 # Apache-2.0/BSD
requests-mock>=1.2.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0
oslo.concurrency>=3.26.0 # Apache-2.0 oslo.concurrency>=3.26.0 # Apache-2.0
os-testr>=1.0.0 # Apache-2.0 os-testr>=1.0.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD stestr>=1.0.0 # Apache-2.0
testresources>=2.0.0 # Apache-2.0/BSD testresources>=2.0.0 # Apache-2.0/BSD
testtools>=2.2.0 # MIT testtools>=2.2.0 # MIT
testscenarios>=0.4 # Apache-2.0/BSD testscenarios>=0.4 # Apache-2.0/BSD

24
tox.ini
View File

@ -16,10 +16,7 @@ whitelist_externals =
commands = commands =
find . -type f -name "*.py[c|o]" -delete find . -type f -name "*.py[c|o]" -delete
find . -path "*/__pycache__*" -delete find . -path "*/__pycache__*" -delete
{toxinidir}/tools/ostestr_compat_shim.sh {posargs} 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.
[testenv:common] [testenv:common]
# Fake job to define environment variables shared between dsvm/non-dsvm jobs # Fake job to define environment variables shared between dsvm/non-dsvm jobs
@ -43,7 +40,7 @@ setenv = {[testenv]setenv}
OS_TEST_PATH=./neutron_fwaas/tests/functional OS_TEST_PATH=./neutron_fwaas/tests/functional
OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs} OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs}
commands = commands =
python setup.py testr --slowest --testr-args='{posargs}' stestr run {posargs}
[testenv:dsvm-fullstack] [testenv:dsvm-fullstack]
basepython = python3 basepython = python3
@ -63,7 +60,7 @@ setenv =
OS_TESTR_CONCURRENCY=1 OS_TESTR_CONCURRENCY=1
TEMPEST_CONFIG_DIR={env:TEMPEST_CONFIG_DIR:/opt/stack/tempest/etc} TEMPEST_CONFIG_DIR={env:TEMPEST_CONFIG_DIR:/opt/stack/tempest/etc}
commands = commands =
python setup.py testr --slowest --testr-args='{posargs}' stestr run {posargs}
[testenv:scenario] [testenv:scenario]
basepython = python3 basepython = python3
@ -73,7 +70,7 @@ setenv =
OS_TESTR_CONCURRENCY=1 OS_TESTR_CONCURRENCY=1
TEMPEST_CONFIG_DIR={env:TEMPEST_CONFIG_DIR:/opt/stack/tempest/etc} TEMPEST_CONFIG_DIR={env:TEMPEST_CONFIG_DIR:/opt/stack/tempest/etc}
commands = commands =
python setup.py testr --slowest --testr-args='{posargs}' stestr run {posargs}
[testenv:dsvm-functional] [testenv:dsvm-functional]
setenv = setenv =
@ -89,7 +86,7 @@ whitelist_externals =
sudo sudo
commands = commands =
{toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin {toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin
python setup.py testr --slowest --testr-args='{posargs}' stestr run {posargs}
[testenv:releasenotes] [testenv:releasenotes]
basepython = python3 basepython = python3
@ -109,9 +106,16 @@ whitelist_externals = sh
[testenv:cover] [testenv:cover]
basepython = python3 basepython = python3
setenv = VIRTUAL_ENV={envdir}
LANGUAGE=en_US
PYTHON=coverage run --source neutron_fwaas --omit='*tests*' --parallel-mode
commands = commands =
python setup.py test --coverage --coverage-package-name=neutron_fwaas --testr-args='{posargs}' coverage erase
coverage report stestr run {posargs}
coverage combine
coverage report --skip-covered --omit='*test*'
coverage html -d cover
coverage xml -o cover/coverage.xml
[testenv:venv] [testenv:venv]
basepython = python3 basepython = python3