Merge "Add hacking rule to enfore no config in tempest.lib"
This commit is contained in:
commit
55fd59831c
@ -21,6 +21,7 @@ Tempest Specific Commandments
|
|||||||
- [T111] Check that service client names of DELETE should be consistent
|
- [T111] Check that service client names of DELETE should be consistent
|
||||||
- [T112] Check that tempest.lib should not import local tempest code
|
- [T112] Check that tempest.lib should not import local tempest code
|
||||||
- [T113] Check that tests use data_utils.rand_uuid() instead of uuid.uuid4()
|
- [T113] Check that tests use data_utils.rand_uuid() instead of uuid.uuid4()
|
||||||
|
- [T114] Check that tempest.lib does not use tempest config
|
||||||
- [N322] Method's default argument shouldn't be mutable
|
- [N322] Method's default argument shouldn't be mutable
|
||||||
|
|
||||||
Test Data/Configuration
|
Test Data/Configuration
|
||||||
|
@ -256,6 +256,23 @@ def use_rand_uuid_instead_of_uuid4(logical_line, filename):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
|
def dont_use_config_in_tempest_lib(logical_line, filename):
|
||||||
|
"""Check that tempest.lib doesn't use tempest config
|
||||||
|
|
||||||
|
T114
|
||||||
|
"""
|
||||||
|
|
||||||
|
if 'tempest/lib/' not in filename:
|
||||||
|
return
|
||||||
|
|
||||||
|
if ('tempest.config' in logical_line
|
||||||
|
or 'from tempest import config' in logical_line
|
||||||
|
or 'oslo_config' in logical_line):
|
||||||
|
msg = ('T114: tempest.lib can not have any dependency on tempest '
|
||||||
|
'config.')
|
||||||
|
yield(0, msg)
|
||||||
|
|
||||||
|
|
||||||
def factory(register):
|
def factory(register):
|
||||||
register(import_no_clients_in_api_and_scenario_tests)
|
register(import_no_clients_in_api_and_scenario_tests)
|
||||||
register(scenario_tests_need_service_tags)
|
register(scenario_tests_need_service_tags)
|
||||||
@ -268,4 +285,5 @@ def factory(register):
|
|||||||
register(get_resources_on_service_clients)
|
register(get_resources_on_service_clients)
|
||||||
register(delete_resources_on_service_clients)
|
register(delete_resources_on_service_clients)
|
||||||
register(dont_import_local_tempest_into_lib)
|
register(dont_import_local_tempest_into_lib)
|
||||||
|
register(dont_use_config_in_tempest_lib)
|
||||||
register(use_rand_uuid_instead_of_uuid4)
|
register(use_rand_uuid_instead_of_uuid4)
|
||||||
|
@ -167,3 +167,16 @@ class HackingTestCase(base.TestCase):
|
|||||||
self.assertEqual(1, len(list(checks.dont_import_local_tempest_into_lib(
|
self.assertEqual(1, len(list(checks.dont_import_local_tempest_into_lib(
|
||||||
"import tempest.exception",
|
"import tempest.exception",
|
||||||
'./tempest/lib/common/compute.py'))))
|
'./tempest/lib/common/compute.py'))))
|
||||||
|
|
||||||
|
def test_dont_use_config_in_tempest_lib(self):
|
||||||
|
self.assertFalse(list(checks.dont_use_config_in_tempest_lib(
|
||||||
|
'from tempest import config', './tempest/common/compute.py')))
|
||||||
|
self.assertFalse(list(checks.dont_use_config_in_tempest_lib(
|
||||||
|
'from oslo_concurrency import lockutils',
|
||||||
|
'./tempest/lib/auth.py')))
|
||||||
|
self.assertTrue(list(checks.dont_use_config_in_tempest_lib(
|
||||||
|
'from tempest import config', './tempest/lib/auth.py')))
|
||||||
|
self.assertTrue(list(checks.dont_use_config_in_tempest_lib(
|
||||||
|
'from oslo_config import cfg', './tempest/lib/decorators.py')))
|
||||||
|
self.assertTrue(list(checks.dont_use_config_in_tempest_lib(
|
||||||
|
'import tempest.config', './tempest/lib/common/rest_client.py')))
|
||||||
|
Loading…
Reference in New Issue
Block a user