Fix defect of 'separate log level for Rally'
Change-Id: I4b765a6c3f5c8407ecf1fc4066d7774f0bab7ada
This commit is contained in:
parent
d70723a63c
commit
bec67ecb41
@ -8,6 +8,15 @@
|
||||
#fatal_exception_format_errors=false
|
||||
|
||||
|
||||
#
|
||||
# Options defined in rally.log
|
||||
#
|
||||
|
||||
# Print debugging output only for Rally. Off-site components
|
||||
# stay quiet. (boolean value)
|
||||
#rally_debug=false
|
||||
|
||||
|
||||
#
|
||||
# Options defined in rally.openstack.common.eventlet_backdoor
|
||||
#
|
||||
@ -372,6 +381,13 @@
|
||||
# Cluster status polling interval in seconds (integer value)
|
||||
#cluster_check_interval=5
|
||||
|
||||
# A timeout in seconds for a cluster create operation (integer
|
||||
# value)
|
||||
#job_execution_timeout=600
|
||||
|
||||
# Cluster status polling interval in seconds (integer value)
|
||||
#job_check_interval=5
|
||||
|
||||
|
||||
[database]
|
||||
|
||||
@ -514,7 +530,7 @@
|
||||
|
||||
# How many concurrent threads use for serving users context
|
||||
# (integer value)
|
||||
#concurrent=30
|
||||
#resource_management_workers=30
|
||||
|
||||
# ID of domain in which projects will be created. (string
|
||||
# value)
|
||||
|
@ -11,3 +11,4 @@ Rally Specific Commandments
|
||||
- [N301] Ensure that ``assert_*`` methods from ``mock`` library is used correctly
|
||||
- [N302] Sub-error of N301, related to nonexistent "assert_called"
|
||||
- [N303] Sub-error of N301, related to nonexistent "assert_called_once"
|
||||
- [N310] Ensure that ``rally.log`` is used instead of ``rally.openstack.common.log``
|
||||
|
@ -79,5 +79,22 @@ def check_assert_methods_from_mock(logical_line, filename):
|
||||
"custom_msg": custom_msg})
|
||||
|
||||
|
||||
def check_import_of_logging(logical_line, filename):
|
||||
"""Check correctness import of logging module N310."""
|
||||
|
||||
excluded_files = ["./rally/log.py"]
|
||||
|
||||
forbidden_imports = ["from rally.openstack.common import log",
|
||||
"import rally.openstack.common.log"
|
||||
"import logging"]
|
||||
|
||||
if filename not in excluded_files:
|
||||
for forbidden_import in forbidden_imports:
|
||||
if logical_line.startswith(forbidden_import):
|
||||
yield (0, "N310 Wrong module for logging is imported. Please "
|
||||
"use `rally.log` instead.")
|
||||
|
||||
|
||||
def factory(register):
|
||||
register(check_assert_methods_from_mock)
|
||||
register(check_import_of_logging)
|
||||
|
@ -60,3 +60,25 @@ class HackingTestCase(test.TestCase):
|
||||
fake_method, 'tests/fake/test'))
|
||||
self.assertEqual(4, actual_number)
|
||||
self.assertTrue(actual_msg.startswith('N303'))
|
||||
|
||||
def test_check_wrong_logging_import(self):
|
||||
fake_imports = ["from rally.openstack.common import log",
|
||||
"import rally.openstack.common.log"
|
||||
"import logging"]
|
||||
good_imports = ["from rally import log",
|
||||
"from rally.log",
|
||||
"import rally.log"]
|
||||
|
||||
for fake_import in fake_imports:
|
||||
checkres = checks.check_import_of_logging(fake_import, "fakefile")
|
||||
self.assertIsNotNone(next(checkres))
|
||||
|
||||
for fake_import in fake_imports:
|
||||
checkres = checks.check_import_of_logging(fake_import,
|
||||
"./rally/log.py")
|
||||
self.assertEqual([], list(checkres))
|
||||
|
||||
for fake_import in good_imports:
|
||||
checkres = checks.check_import_of_logging(fake_import,
|
||||
"fakefile")
|
||||
self.assertEqual([], list(checkres))
|
||||
|
Loading…
Reference in New Issue
Block a user