diff --git a/.gitignore b/.gitignore index 423682f9b..2064ca09d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ .*.swp .*sw? .coverage -.testrepository +.stestr .tox AUTHORS build/* diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 000000000..5f3e9f7cf --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,12 @@ +[DEFAULT] +test_path=${OS_TEST_PATH:-./aodh/tests/unit} +top_dir=./ +# 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 +group_regex=(gabbi\.(suitemaker|driver)\.test_gabbi_([^_]+))_ diff --git a/.testr.conf b/.testr.conf deleted file mode 100644 index c242a9823..000000000 --- a/.testr.conf +++ /dev/null @@ -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:-./aodh/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_([^_]+))_ diff --git a/run-functional-tests.sh b/run-functional-tests.sh index 6720dc9d4..4b92e9651 100755 --- a/run-functional-tests.sh +++ b/run-functional-tests.sh @@ -6,8 +6,8 @@ cleanup(){ } trap cleanup EXIT +export OS_TEST_PATH=aodh/tests/functional_live export GABBI_LIVE_FAIL_IF_NO_TEST=1 -export OS_TEST_PATH=aodh/tests/functional_live/ export AODH_SERVICE_TOKEN=foobar # Needed for gabbi export AODH_SERVICE_ROLES=admin @@ -15,6 +15,6 @@ AODH_TEST_DRIVERS=${AODH_TEST_DRIVERS:-postgresql} for indexer in ${AODH_TEST_DRIVERS} do eval $(pifpaf -e DATABASE run $indexer) - pifpaf -e AODH run aodh --database-url $DATABASE_URL -- ./tools/pretty_tox.sh $* + pifpaf -e AODH run aodh --database-url $DATABASE_URL -- stestr run $* cleanup done diff --git a/run-tests.sh b/run-tests.sh index 50198945f..e41258057 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,11 +2,11 @@ set -e export OS_TEST_PATH=aodh/tests/unit -./tools/pretty_tox.sh $* +stestr run $* export OS_TEST_PATH=aodh/tests/functional AODH_TEST_DRIVERS=${AODH_TEST_DRIVERS:-postgresql} for indexer in ${AODH_TEST_DRIVERS} do - pifpaf -g AODH_TEST_STORAGE_URL run $indexer -- ./tools/pretty_tox.sh $* + pifpaf -g AODH_TEST_STORAGE_URL run $indexer -- stestr run $* done diff --git a/setup.cfg b/setup.cfg index 067e039e1..bb8fe9d19 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,12 +45,11 @@ zaqar = test = pifpaf[gnocchi]>=1.0.1 - os-testr>=0.4.1 # Apache-2.0 + stestr>=2.0.0 # Apache-2.0 oslotest>=2.15.0 # Apache-2.0 coverage>=3.6 fixtures>=1.3.1 sqlalchemy-utils - testrepository>=0.0.18 testresources>=0.2.4 # Apache-2.0/BSD gabbi>=1.30.0 # Apache-2.0 # Provides subunit-trace diff --git a/tools/pretty_tox.sh b/tools/pretty_tox.sh deleted file mode 100755 index 5094f61e0..000000000 --- a/tools/pretty_tox.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail - -TESTRARGS=$* - -# --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 diff --git a/tox.ini b/tox.ini index 10f11fc2c..0813e85d7 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,10 @@ ignore_basepython_conflict = True basepython = python3 usedevelop = True setenv = + OS_STDOUT_CAPTURE=1 + OS_STDERR_CAPTURE=1 + OS_TEST_TIMEOUT=600 + AODH_TEST_DRIVERS=postgresql mysql mysql: AODH_TEST_DRIVERS=mysql postgresql: AODH_TEST_DRIVERS=postgresql @@ -16,18 +20,28 @@ setenv = mysql: AODH_TEST_DEPS=mysql postgresql: AODH_TEST_DEPS=postgresql deps = - -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} - .[test,{env:AODH_TEST_DEPS}] + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + .[test,{env:AODH_TEST_DEPS}] passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE AODH_TEST_DRIVERS commands = - {toxinidir}/run-tests.sh {posargs} - {toxinidir}/run-functional-tests.sh "{posargs}" - aodh-config-generator + {toxinidir}/run-tests.sh {posargs} + {toxinidir}/run-functional-tests.sh {posargs} + aodh-config-generator allowlist_externals = bash [testenv:cover] +setenv = + {[testenv]setenv} + PYTHON=coverage run --source aodh --parallel-mode commands = - pifpaf -g AODH_TEST_STORAGE_URL run mysql -- python setup.py testr --slowest --coverage --testr-args="{posargs}" + coverage erase + stestr run {posargs} + stestr --test-path=./aodh/tests/functional run {posargs} + coverage combine + coverage html -d cover + coverage xml -o cover/coverage.xml + coverage report + pifpaf -g AODH_TEST_STORAGE_URL run mysql -- stestr --test-path=./aodh/tests run coverage report [testenv:pep8]