diff --git a/.gitignore b/.gitignore index aedc5b9f9..115157ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ pip-log.txt nosetests.xml cover/* .testrepository/ +.stestr/ subunit.log .mistral.conf AUTHORS diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 000000000..787b115c4 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./mistral/tests/unit +top_dir=./ diff --git a/.testr.conf b/.testr.conf deleted file mode 100644 index ed0237d16..000000000 --- a/.testr.conf +++ /dev/null @@ -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} diff --git a/lower-constraints.txt b/lower-constraints.txt index 6e697554a..5f6425d66 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -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 diff --git a/run_tests.sh b/run_tests.sh index 1e7706a1c..0bf86127b 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index e5bdc9f03..ad3a1f811 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tools/cover.sh b/tools/cover.sh index b6882a7eb..56acd422d 100755 --- a/tools/cover.sh +++ b/tools/cover.sh @@ -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) diff --git a/tox.ini b/tox.ini index fcdc326ba..d4bd2ecd3 100644 --- a/tox.ini +++ b/tox.ini @@ -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 =