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 nosetests.xml
cover/* cover/*
.testrepository/ .testrepository/
.stestr/
subunit.log subunit.log
.mistral.conf .mistral.conf
AUTHORS 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 SQLAlchemy==1.2.5
sqlparse==0.2.2 sqlparse==0.2.2
statsd==3.2.1 statsd==3.2.1
stestr==1.0.0 stestr==2.0.0
stevedore==1.20.0 stevedore==1.20.0
tempest==17.1.0 tempest==17.1.0
Tempita==0.5.2 Tempita==0.5.2

View File

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

View File

@ -27,7 +27,7 @@ sphinxcontrib-pecanwsme>=0.8.0 # Apache-2.0
openstackdocstheme>=1.18.1 # Apache-2.0 openstackdocstheme>=1.18.1 # Apache-2.0
tooz>=1.58.0 # Apache-2.0 tooz>=1.58.0 # Apache-2.0
tempest>=17.1.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 testtools>=2.2.0 # MIT
unittest2>=1.1.0 # BSD unittest2>=1.1.0 # BSD
WSME>=0.8.0 # MIT WSME>=0.8.0 # MIT

View File

@ -25,7 +25,7 @@ uncommitted=$(git status --porcelain | grep -v "^??")
git checkout HEAD^ git checkout HEAD^
baseline_report=$(mktemp -t mistral_coverageXXXXXXX) 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 coverage report -m > $baseline_report
baseline_missing=$(awk 'END { print $3 }' $baseline_report) baseline_missing=$(awk 'END { print $3 }' $baseline_report)
previous_sha=$(git rev-parse HEAD); previous_sha=$(git rev-parse HEAD);
@ -39,7 +39,7 @@ coverage erase;
# Generate and save coverage report # Generate and save coverage report
current_report=$(mktemp -t mistral_coverageXXXXXXX) 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 coverage report -m > $current_report
current_missing=$(awk 'END { print $3 }' $current_report) current_missing=$(awk 'END { print $3 }' $current_report)

12
tox.ini
View File

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