Migrate to stestr for running tests

stestr is recommended by OpenStack Project Testing Interface for running tests
[1]. This change migrates to stestr for running unit tests and coverage
job. Modified `cover` env allows running it as Zuul job and visualising
its results in Gerrit.

[1] https://governance.openstack.org/tc/reference/pti/python.html#python-test-running

Change-Id: I9e8b79d7a18cd36946daff10abb1a2f43b1aa3a1
This commit is contained in:
Witold Bedyk 2018-07-02 13:20:05 +02:00
parent a74978619e
commit 9586972ddd
7 changed files with 13 additions and 32 deletions

2
.gitignore vendored
View File

@ -2,7 +2,7 @@
*.mo
*.pyc
.coverage
.testrepository
.stestr
.tox
AUTHORS
build/*

3
.stestr.conf Normal file
View File

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

View File

@ -1,9 +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:-600} \
${PYTHON:-python} -m subunit.run discover ${OS_TEST_PATH:-./ceilometer/tests} -t . $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
# NOTE(chdent): Only used/matches on gabbi-related tests.
group_regex=(gabbi\.(suitemaker|driver)\.test_gabbi_(?:prefix_|)[^_]+)_

View File

@ -27,6 +27,7 @@
check:
jobs:
- telemetry-tox-py37
- openstack-tox-cover
- grenade-dsvm-ceilometer:
irrelevant-files:
- ^(test-|)requirements.txt$

View File

@ -13,10 +13,9 @@ oslotest>=2.15.0 # Apache-2.0
oslo.vmware>=1.16.0 # Apache-2.0
pyOpenSSL>=0.14 # Apache-2.0
sphinx>=1.6.2 # BSD
testrepository>=0.0.18 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
gabbi>=1.30.0 # Apache-2.0
requests-aws>=0.1.4 # BSD License (3 clause)
os-testr>=0.4.1 # Apache-2.0
kafka-python>=1.3.2 # Apache-2.0
stestr>=1.0.0 # Apache-2.0

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -o pipefail
TESTRARGS=$1
# --until-failure is not compatible with --subunit see:
#
# https://bugs.launchpad.net/testrepository/+bug/1411804
#
# this work around exists until that is addressed
if [[ "$TESTARGS" =~ "until-failure" ]]; then
python setup.py testr --slowest --testr-args="$TESTRARGS"
else
python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | subunit-trace -f
fi

11
tox.ini
View File

@ -10,19 +10,22 @@ deps = .[gnocchi,zaqar]
install_command = pip install -U {opts} {packages}
usedevelop = True
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=ceilometer/tests/unit
CEILOMETER_TEST_BACKEND={env:CEILOMETER_TEST_BACKEND:none}
passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE CEILOMETER_*
commands =
{toxinidir}/tools/pretty_tox.sh "{posargs}"
stestr run {posargs}
oslo-config-generator --config-file=etc/ceilometer/ceilometer-config-generator.conf
whitelist_externals = bash
[testenv:cover]
basepython = python3
setenv = OS_TEST_PATH=ceilometer/tests
setenv =
PYTHON=coverage run --source ceilometer --parallel-mode
commands =
python setup.py testr --slowest --coverage --testr-args="{posargs}"
stestr run '{posargs}'
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
[testenv:pep8]
basepython = python3