Use setstr to execute unittest test

The stestr[1] is parallel Python test runner designed to execute unittest test suites using multiple processes.
Test cases can be executed faster.

[1]https://github.com/mtreinish/stestr

Change-Id: Ic0b210685535f94a70a175385afdd9f399f4d690
This commit is contained in:
caihui 2020-07-01 01:11:26 -07:00
parent 6fabbd4a41
commit 11dfa6a003
6 changed files with 29 additions and 39 deletions

1
.gitignore vendored
View File

@ -21,6 +21,7 @@ coverage.xml
subunit.log
AUTHORS
ChangeLog
.stestr/
# Django files that get created during the test runs
.secret_key_store

4
.stestr.conf Normal file
View File

@ -0,0 +1,4 @@
[DEFAULT]
test_path=${OS_TEST_PATH:-./freezer_api/tests/unit}
top_dir=./
group_regex=([^\.]+\.)+

View File

@ -1,9 +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} \
${PYTHON:-python} -m subunit.run discover -s ${OS_TEST_PATH:-./freezer_api/tests/unit} -t . $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
group_regex=([^\.]+\.)+

View File

@ -3,7 +3,7 @@ alembic==0.9.8
Babel==2.5.3
certifi==2018.1.18
chardet==3.0.4
coverage==4.0
coverage==4.5.1
debtcollector==1.19.0
decorator==4.2.1
docutils==0.14
@ -68,11 +68,12 @@ sqlalchemy-migrate==0.11.0
SQLAlchemy==1.2.5
sqlparse==0.2.4
statsd==3.2.2
stestr==2.0.0
stevedore==1.28.0
Tempita==0.5.2
testrepository==0.0.18
testresources==2.0.1
testscenarios==0.5.0
testresources==2.0.1
testtools==2.2.0
traceback2==1.4.0
unittest2==1.1.0

View File

@ -5,12 +5,15 @@
# hacking already pins flake8
hacking>=3.0.1,<=3.1.0 # Apache-2.0
pylint==2.3.1 # GPLv2
coverage!=4.4,>=4.0 # Apache-2.0
coverage>=4.5.1 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
oslotest>=3.3.0 # Apache-2.0
sphinx>=1.8.0,!=2.1.0 # BSD
testrepository>=0.0.18 # Apache-2.0/BSD
stestr>=2.0.0 # Apache-2.0
testtools>=2.2.0 # MIT
testresources>=2.0.1
testscenarios>=0.5.0
os-api-ref>=1.4.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0
openstackdocstheme>=1.31.2 # Apache-2.0

44
tox.ini
View File

@ -7,14 +7,28 @@ skipsdist = True
basepython = python3
usedevelop = True
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
passenv =
http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
install_command = pip install {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
OS_TEST_PATH = ./freezer_api/tests/unit
PYTHON=coverage run --source freezer_api --parallel-mode
commands =
find . -type f -name "*.py[c|o]" -delete
stestr run {posargs}
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report -m
rm -f .coverage
rm -rf .testrepository
whitelist_externals =
find
@ -22,41 +36,17 @@ whitelist_externals =
rm
python_files = test_*.py
norecursedirs = .tox .venv specs
norecursedirs = .tox .venv
[testenv:py36]
basepython = python3.6
setenv = OS_PATH_TEST = ./freezer_api/tests/unit
commands =
find . -type f -name "*.py[c|o]" -delete
rm -rf .testrepository
python setup.py test --coverage --coverage-package-name freezer_api --testr-args={posargs}
coverage report -m
rm -f .coverage
rm -rf .testrepository
[testenv:py37]
basepython = python3.7
setenv = OS_PATH_TEST = ./freezer_api/tests/unit
commands =
find . -type f -name "*.py[c|o]" -delete
rm -rf .testrepository
python setup.py test --coverage --coverage-package-name freezer_api --testr-args={posargs}
coverage report -m
rm -f .coverage
rm -rf .testrepository
[testenv:venv]
commands = {posargs}
[testenv:cover]
commands =
find . -type f -name "*.py[c|o]" -delete
python setup.py test --coverage --coverage-package-name freezer_api --testr-args={posargs}
coverage report -m
rm -f .coverage
rm -rf .testrepository
[testenv:pylint]
commands = pylint --rcfile .pylintrc freezer_api