Update sysinv to not invoke ceph during unit testing

- reduces invocations of ceph during sysinv unit tests
 - Potentially eliminate timeouts related to ceph invocation
 - convert testrepository to stestr (current openstack test framework)
 - reduces printing to stdout of REST operations

Story:2002803
Task: 26852
Change-Id: I4236352498d2ea4f6fb9f4521355695fd0140a26
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
Al Bailey 2018-09-26 08:57:35 -05:00
parent 3290e3221b
commit 1a30700bb8
7 changed files with 44 additions and 21 deletions

View File

@ -22,6 +22,7 @@ develop-eggs
# Other
*.DS_Store
.stestr
.testrepository
.tox
.venv

View File

@ -0,0 +1,5 @@
[DEFAULT]
test_path=./sysinv/tests
top_dir=./sysinv
# Default concurrency is 5.
test_run_concurrency=echo 5

View File

@ -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=([^\.]+\.)+

View File

@ -33,6 +33,7 @@ from sysinv.common import utils as cutils
PATH_PREFIX = '/v1'
DEBUG_PRINTING = False
class FunctionalTest(base.TestCase):
@ -86,6 +87,7 @@ class FunctionalTest(base.TestCase):
method="post", extra_environ=None, status=None,
path_prefix=PATH_PREFIX):
full_path = path_prefix + path
if DEBUG_PRINTING:
print('%s: %s %s' % (method.upper(), full_path, params))
response = getattr(self.app, "%s_json" % method)(
str(full_path),
@ -95,6 +97,7 @@ class FunctionalTest(base.TestCase):
extra_environ=extra_environ,
expect_errors=expect_errors
)
if DEBUG_PRINTING:
print('GOT:%s' % response)
return response
@ -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
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,6 +148,7 @@ class FunctionalTest(base.TestCase):
all_params.update(params)
if q:
all_params.update(query_params)
if DEBUG_PRINTING:
print('GET: %s %r' % (full_path, all_params))
response = self.app.get(full_path,
params=all_params,
@ -151,5 +157,6 @@ class FunctionalTest(base.TestCase):
expect_errors=expect_errors)
if not expect_errors:
response = response.json
if DEBUG_PRINTING:
print('GOT:%s' % response)
return response

View File

@ -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

View File

@ -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

View File

@ -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