From d0b8ebd84a649bd58f2d0eb946597c7bbd63dab2 Mon Sep 17 00:00:00 2001 From: Masayuki Igawa Date: Thu, 14 Sep 2017 14:51:25 -0600 Subject: [PATCH] Switch to use stestr for unit tests directly This commit switches to use stestr command to run unit tests directly. Recently, the latest ostestr command uses stestr instead of testr. However, we should use stestr directly because it's simple and straight forward. There is no reason to use ostestr for unit tests anymore. We still have the other ostestr/testr usage such as tempest run command and documentations. So, that will be changed with following patches. Change-Id: Iff4abef50178bdc83b868eed4a906e22d790762b --- .gitignore | 1 + .stestr.conf | 4 ++++ requirements.txt | 2 +- tempest/tests/test_list_tests.py | 6 ++---- tox.ini | 5 ++--- 5 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 .stestr.conf diff --git a/.gitignore b/.gitignore index 287db4cf50..7cb052f0df 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ include/swift_objects/swift_large dist build .testrepository +.stestr .idea .project .pydevproject diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000000..e3201c13c0 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_path=./tempest/test_discover +group_regex=([^\.]*\.)* + diff --git a/requirements.txt b/requirements.txt index 36b9efab1d..9bb7a55b78 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ PyYAML>=3.10 # MIT python-subunit>=0.0.18 # Apache-2.0/BSD stevedore>=1.20.0 # Apache-2.0 PrettyTable<0.8,>=0.7.1 # BSD -os-testr>=0.8.0 # Apache-2.0 +os-testr>=1.0.0 # Apache-2.0 urllib3>=1.21.1 # MIT debtcollector>=1.2.0 # Apache-2.0 unittest2 # BSD diff --git a/tempest/tests/test_list_tests.py b/tempest/tests/test_list_tests.py index a238879656..4af74630d5 100644 --- a/tempest/tests/test_list_tests.py +++ b/tempest/tests/test_list_tests.py @@ -23,12 +23,10 @@ from tempest.tests import base class TestTestList(base.TestCase): - def test_testr_list_tests_no_errors(self): - # Remove unit test discover path from env to test tempest tests + def test_stestr_list_no_errors(self): test_env = os.environ.copy() - test_env.pop('OS_TEST_PATH') import_failures = [] - p = subprocess.Popen(['testr', 'list-tests'], stdout=subprocess.PIPE, + p = subprocess.Popen(['stestr', 'list'], stdout=subprocess.PIPE, env=test_env) ids, err = p.communicate() self.assertEqual(0, p.returncode, diff --git a/tox.ini b/tox.ini index 7bdc580800..21696eb511 100644 --- a/tox.ini +++ b/tox.ini @@ -16,12 +16,11 @@ deps = [testenv] setenv = VIRTUAL_ENV={envdir} - OS_TEST_PATH=./tempest/tests OS_LOG_CAPTURE=1 PYTHONWARNINGS=default::DeprecationWarning BRANCH_NAME=master CLIENT_NAME=tempest -passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH OS_TEST_PATH TEMPEST_CONFIG TEMPEST_CONFIG_DIR http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY ZUUL_CACHE_DIR REQUIREMENTS_PIP_LOCATION GENERATE_TEMPEST_PLUGIN_LIST +passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH TEMPEST_CONFIG TEMPEST_CONFIG_DIR http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY ZUUL_CACHE_DIR REQUIREMENTS_PIP_LOCATION GENERATE_TEMPEST_PLUGIN_LIST usedevelop = True install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} @@ -31,7 +30,7 @@ deps = -r{toxinidir}/test-requirements.txt commands = find . -type f -name "*.pyc" -delete - ostestr {posargs} + stestr --test-path ./tempest/tests run {posargs} [testenv:genconfig] commands = oslo-config-generator --config-file tempest/cmd/config-generator.tempest.conf