diff --git a/sysinv/sysinv/sysinv/.gitignore b/sysinv/sysinv/sysinv/.gitignore index d7cc8415eb..78c457c6eb 100644 --- a/sysinv/sysinv/sysinv/.gitignore +++ b/sysinv/sysinv/sysinv/.gitignore @@ -22,6 +22,7 @@ develop-eggs # Other *.DS_Store +.stestr .testrepository .tox .venv diff --git a/sysinv/sysinv/sysinv/.stestr.conf b/sysinv/sysinv/sysinv/.stestr.conf new file mode 100644 index 0000000000..9ddfaf4961 --- /dev/null +++ b/sysinv/sysinv/sysinv/.stestr.conf @@ -0,0 +1,5 @@ +[DEFAULT] +test_path=./sysinv/tests +top_dir=./sysinv +# Default concurrency is 5. +test_run_concurrency=echo 5 diff --git a/sysinv/sysinv/sysinv/.testr.conf b/sysinv/sysinv/sysinv/.testr.conf deleted file mode 100644 index 60a6f878f7..0000000000 --- a/sysinv/sysinv/sysinv/.testr.conf +++ /dev/null @@ -1,12 +0,0 @@ -[DEFAULT] -# Default concurrency is 5. -test_run_concurrency=echo 5 -test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ - OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ - OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \ - ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./sysinv/tests} $LISTOPT $IDOPTION -test_id_option=--load-list $IDFILE -test_list_option=--list -# group tests when running concurrently -# This regex groups by classname -#group_regex=([^\.]+\.)+ diff --git a/sysinv/sysinv/sysinv/sysinv/tests/api/base.py b/sysinv/sysinv/sysinv/sysinv/tests/api/base.py index 7c3b9d0859..55b8cc497e 100644 --- a/sysinv/sysinv/sysinv/sysinv/tests/api/base.py +++ b/sysinv/sysinv/sysinv/sysinv/tests/api/base.py @@ -33,6 +33,7 @@ from sysinv.common import utils as cutils PATH_PREFIX = '/v1' +DEBUG_PRINTING = False class FunctionalTest(base.TestCase): @@ -86,7 +87,8 @@ class FunctionalTest(base.TestCase): method="post", extra_environ=None, status=None, path_prefix=PATH_PREFIX): full_path = path_prefix + path - print('%s: %s %s' % (method.upper(), full_path, params)) + if DEBUG_PRINTING: + print('%s: %s %s' % (method.upper(), full_path, params)) response = getattr(self.app, "%s_json" % method)( str(full_path), params=params, @@ -95,7 +97,8 @@ class FunctionalTest(base.TestCase): extra_environ=extra_environ, expect_errors=expect_errors ) - print('GOT:%s' % response) + if DEBUG_PRINTING: + print('GOT:%s' % response) return response def put_json(self, *args, **kwargs): @@ -120,13 +123,15 @@ class FunctionalTest(base.TestCase): def delete(self, path, expect_errors=False, headers=None, extra_environ=None, status=None, path_prefix=PATH_PREFIX): full_path = path_prefix + path - print('DELETE: %s' % (full_path)) + if DEBUG_PRINTING: + print('DELETE: %s' % (full_path)) response = self.app.delete(str(full_path), headers=headers, status=status, extra_environ=extra_environ, expect_errors=expect_errors) - print('GOT:%s' % response) + if DEBUG_PRINTING: + print('GOT: %s' % response) return response def get_json(self, path, expect_errors=False, headers=None, @@ -143,7 +148,8 @@ class FunctionalTest(base.TestCase): all_params.update(params) if q: all_params.update(query_params) - print('GET: %s %r' % (full_path, all_params)) + if DEBUG_PRINTING: + print('GET: %s %r' % (full_path, all_params)) response = self.app.get(full_path, params=all_params, headers=headers, @@ -151,5 +157,6 @@ class FunctionalTest(base.TestCase): expect_errors=expect_errors) if not expect_errors: response = response.json - print('GOT:%s' % response) + if DEBUG_PRINTING: + print('GOT:%s' % response) return response diff --git a/sysinv/sysinv/sysinv/sysinv/tests/api/test_storage_tier.py b/sysinv/sysinv/sysinv/sysinv/tests/api/test_storage_tier.py index 5d5a7b8720..07d0d3dc82 100644 --- a/sysinv/sysinv/sysinv/sysinv/tests/api/test_storage_tier.py +++ b/sysinv/sysinv/sysinv/sysinv/tests/api/test_storage_tier.py @@ -31,13 +31,20 @@ from sysinv.tests.db import utils as dbutils class StorageTierIndependentTCs(base.FunctionalTest): + set_crushmap_patcher = mock.patch.object(ceph_utils.CephApiOperator, 'set_crushmap') + def setUp(self): super(StorageTierIndependentTCs, self).setUp() + self.mock_set_crushmap = self.set_crushmap_patcher.start() self.system = dbutils.create_test_isystem() self.cluster = dbutils.create_test_cluster(system_id=self.system.id, name='ceph_cluster') self.load = dbutils.create_test_load() self.host = dbutils.create_test_ihost(forisystemid=self.system.id) + def tearDown(self): + super(StorageTierIndependentTCs, self).tearDown() + self.set_crushmap_patcher.stop() + def assertDeleted(self, fullPath): self.get_json(fullPath, expect_errors=True) # Make sure this line raises an error @@ -511,8 +518,11 @@ class StorageTierIndependentTCs(base.FunctionalTest): class StorageTierDependentTCs(base.FunctionalTest): + set_crushmap_patcher = mock.patch.object(ceph_utils.CephApiOperator, 'set_crushmap') + def setUp(self): super(StorageTierDependentTCs, self).setUp() + self.mock_set_crushmap = self.set_crushmap_patcher.start() self.service = manager.ConductorManager('test-host', 'test-topic') self.service.dbapi = dbapi.get_instance() self.context = context.get_admin_context() @@ -521,6 +531,10 @@ class StorageTierDependentTCs(base.FunctionalTest): self.load = dbutils.create_test_load() self.host_index = -1 + def tearDown(self): + super(StorageTierDependentTCs, self).tearDown() + self.set_crushmap_patcher.stop() + def assertDeleted(self, fullPath): self.get_json(fullPath, expect_errors=True) # Make sure this line raises an error diff --git a/sysinv/sysinv/sysinv/test-requirements.txt b/sysinv/sysinv/sysinv/test-requirements.txt index 6a4372b6f7..124a9f2b81 100644 --- a/sysinv/sysinv/sysinv/test-requirements.txt +++ b/sysinv/sysinv/sysinv/test-requirements.txt @@ -17,6 +17,7 @@ requests-mock>=0.6.0 # Apache-2.0 sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 oslosphinx<2.6.0,>=2.5.0 # Apache-2.0 oslotest<1.6.0,>=1.5.1 # Apache-2.0 +stestr testrepository>=0.0.18 testtools!=1.2.0,>=0.9.36 tempest-lib<0.5.0,>=0.4.0 diff --git a/sysinv/sysinv/sysinv/tox.ini b/sysinv/sysinv/sysinv/tox.ini index c6790c7eb2..230557550b 100644 --- a/sysinv/sysinv/sysinv/tox.ini +++ b/sysinv/sysinv/sysinv/tox.ini @@ -48,9 +48,6 @@ deps = -r{toxinidir}/requirements.txt commands = find . -type f -name "*.pyc" -delete - python tools/patch_tox_venv.py - python setup.py testr --testr-args='{posargs}' - #py.test {posargs} # TODO: remove ignore E722 when issue 8174 is resolved # F series are flake8. All should be fixed @@ -96,7 +93,17 @@ commands = [testenv:py27] basepython = python2.7 +commands = + {[testenv]commands} + stestr run '{posargs}' + stestr slowest +[testenv:py35] +basepython = python3.5 +commands = + {[testenv]commands} + stestr run '{posargs}' + stestr slowest [testenv:pep8] # testenv:flake8 clone