Switch to using stestr

When the TC merged I2637dd714cbb6d38ef8b8dc1083e359207118284 we're
supposed to invoke stestr rather than testr so lets do that

Change-Id: Icd303c37d2371d44726d55c947bbc8b9e99f2a1c
This commit is contained in:
Brad P. Crochet 2018-05-21 18:24:50 -04:00
parent ec66e1d945
commit 9883814cdc
8 changed files with 36 additions and 42 deletions

1
.gitignore vendored
View File

@ -28,6 +28,7 @@ pip-log.txt
nosetests.xml
cover/*
.testrepository/
.stestr/
subunit.log
.mistral.conf
AUTHORS

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=./mistral/tests/unit
top_dir=./

View File

@ -1,10 +0,0 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
${PYTHON:-python} -m subunit.run discover -t ./ ./mistral/tests/unit $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
test_run_concurrency=echo ${TEST_RUN_CONCURRENCY:-0}

View File

@ -153,7 +153,7 @@ sqlalchemy-migrate==0.11.0
SQLAlchemy==1.2.5
sqlparse==0.2.2
statsd==3.2.1
stestr==1.0.0
stestr==2.0.0
stevedore==1.20.0
tempest==17.1.0
Tempita==0.5.2

View File

@ -71,8 +71,8 @@ function process_options {
(( i++ ))
parallel=${!i}
;;
-*) testropts="$testropts ${!i}";;
*) testrargs="$testrargs ${!i}"
-*) stestropts="$stestropts ${!i}";;
*) stestrargs="$stestrargs ${!i}"
esac
(( i++ ))
done
@ -89,8 +89,8 @@ never_venv=0
force=0
no_site_packages=0
installvenvopts=
testrargs=
testropts=
stestrargs=
stestropts=
wrapper=""
just_pep8=0
no_pep8=0
@ -178,43 +178,43 @@ function run_tests {
${wrapper} find . -type f -name "*.pyc" -delete
if [ $debug -eq 1 ]; then
if [ "$testropts" = "" ] && [ "$testrargs" = "" ]; then
if [ "$stestropts" = "" ] && [ "$stestrargs" = "" ]; then
# Default to running all tests if specific test is not
# provided.
testrargs="discover ./mistral/tests/unit"
stestrargs="discover ./mistral/tests/unit"
fi
${wrapper} python -m testtools.run $testropts $testrargs
${wrapper} python -m testtools.run $stestropts $stestrargs
# Short circuit because all of the testr and coverage stuff
# Short circuit because all of the stestr and coverage stuff
# below does not make sense when running testtools.run for
# debugging purposes.
return $?
fi
if [ $coverage -eq 1 ]; then
TESTRTESTS="$TESTRTESTS --coverage"
STESTRTESTS="$STESTRTESTS --coverage"
else
TESTRTESTS="$TESTRTESTS --slowest"
STESTRTESTS="$STESTRTESTS --slowest"
fi
# Just run the test suites in current environment
set +e
testrargs=$(echo "$testrargs" | sed -e's/^\s*\(.*\)\s*$/\1/')
stestrargs=$(echo "$stestrargs" | sed -e's/^\s*\(.*\)\s*$/\1/')
if [ $parallel = true ]
then
runoptions="--subunit"
else
runoptions="--concurrency=1 --subunit"
runoptions="--concurrency 1 --subunit"
fi
TESTRTESTS="$TESTRTESTS --testr-args='$runoptions $testropts $testrargs'"
OS_TEST_PATH=$(echo $testrargs|grep -o 'mistral\.tests[^[:space:]:]*\+'|tr . /)
STESTRTESTS="$STESTRTESTS $runoptions $stestropts $stestrargs"
OS_TEST_PATH=$(echo $stestrargs|grep -o 'mistral\.tests[^[:space:]:]*\+'|tr . /)
if [ -d "$OS_TEST_PATH" ]; then
wrapper="OS_TEST_PATH=$OS_TEST_PATH $wrapper"
elif [ -d "$(dirname $OS_TEST_PATH)" ]; then
wrapper="OS_TEST_PATH=$(dirname $OS_TEST_PATH) $wrapper"
fi
echo "Running ${wrapper} $TESTRTESTS"
bash -c "${wrapper} $TESTRTESTS | ${wrapper} subunit2pyunit"
echo "Running ${wrapper} $STESTRTESTS"
bash -c "${wrapper} $STESTRTESTS | ${wrapper} subunit2pyunit"
RESULT=$?
set -e
@ -232,9 +232,7 @@ function run_tests {
}
function copy_subunit_log {
LOGNAME=$(cat .testrepository/next-stream)
LOGNAME=$(($LOGNAME - 1))
LOGNAME=".testrepository/${LOGNAME}"
LOGNAME=".stestr/$(($(cat .stestr/next-stream) - 1))"
cp $LOGNAME subunit.log
}
@ -245,7 +243,7 @@ function run_pep8 {
}
TESTRTESTS="python setup.py testr"
STESTRTESTS="stestr run"
if [ $never_venv -eq 0 ]
then
@ -298,9 +296,9 @@ run_tests
# NOTE(sirp): we only want to run pep8 when we're running the full-test suite,
# not when we're running tests individually. To handle this, we need to
# distinguish between options (testropts), which begin with a '-', and
# arguments (testrargs).
if [ -z "$testrargs" ]; then
# distinguish between options (stestropts), which begin with a '-', and
# arguments (stestrargs).
if [ -z "$stestrargs" ]; then
if [ $no_pep8 -eq 0 ]; then
run_pep8
fi

View File

@ -27,7 +27,7 @@ sphinxcontrib-pecanwsme>=0.8.0 # Apache-2.0
openstackdocstheme>=1.18.1 # Apache-2.0
tooz>=1.58.0 # Apache-2.0
tempest>=17.1.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD
stestr>=2.0.0 # Apache-2.0
testtools>=2.2.0 # MIT
unittest2>=1.1.0 # BSD
WSME>=0.8.0 # MIT

View File

@ -25,7 +25,7 @@ uncommitted=$(git status --porcelain | grep -v "^??")
git checkout HEAD^
baseline_report=$(mktemp -t mistral_coverageXXXXXXX)
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
find . -type f -name "*.pyc" -delete && stestr --coverage "$*"
coverage report -m > $baseline_report
baseline_missing=$(awk 'END { print $3 }' $baseline_report)
previous_sha=$(git rev-parse HEAD);
@ -39,7 +39,7 @@ coverage erase;
# Generate and save coverage report
current_report=$(mktemp -t mistral_coverageXXXXXXX)
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
find . -type f -name "*.pyc" -delete && stestr --coverage "$*"
coverage report -m > $current_report
current_missing=$(awk 'END { print $3 }' $current_report)

12
tox.ini
View File

@ -19,7 +19,7 @@ deps =
commands =
rm -f .testrepository/times.dbm
find . -type f -name "*.pyc" -delete
python setup.py testr --slowest --testr-args='{posargs}'
stestr run --slowest {posargs}
whitelist_externals =
rm
find
@ -41,11 +41,13 @@ commands =
flake8 {posargs} . {toxinidir}/tools/get_action_list.py {toxinidir}/tools/sync_db.py
[testenv:cover]
# Also do not run test_coverage_ext tests while gathering coverage as those
# tests conflict with coverage.
setenv = VIRTUAL_ENV={envdir}
setenv =
PYTHON=coverage run --source $project --parallel-mode
commands =
{toxinidir}/tools/cover.sh {posargs}
stestr run '{posargs}'
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
[testenv:genconfig]
commands =