Cleanup handlers defined in OS_LOG_DEFAULTS
The base test class currently adds a handler for every logger specified in OS_LOG_DEFAULTS in every test case. Those don't get cleaned so they accumulate with each test case and multiply logging which leads to slow test cases and high memory consumption. This has been hidden in ci so far because of a bug in the tox configuration that sets the log config explicitly to an empty string overriding the default logging config specified in the base test class. Fix this by adding the missing cleanup to remove the handler from logging. Change-Id: I1359acd7aef7e22505151f66915348bae1b1c740
This commit is contained in:
parent
418a144e93
commit
8b69274560
|
@ -3117,8 +3117,6 @@ class BaseTestCase(testtools.TestCase):
|
|||
# Make sure we don't carry old handlers around in process state
|
||||
# which slows down test runs
|
||||
self.addCleanup(logger.removeHandler, handler)
|
||||
self.addCleanup(handler.close)
|
||||
self.addCleanup(handler.flush)
|
||||
|
||||
# NOTE(notmorgan): Extract logging overrides for specific
|
||||
# libraries from the OS_LOG_DEFAULTS env and create loggers
|
||||
|
@ -3136,12 +3134,15 @@ class BaseTestCase(testtools.TestCase):
|
|||
logger = logging.getLogger(name)
|
||||
logger.setLevel(level)
|
||||
logger.addHandler(handler)
|
||||
self.addCleanup(logger.removeHandler, handler)
|
||||
logger.propagate = False
|
||||
except ValueError:
|
||||
# NOTE(notmorgan): Invalid format of the log default,
|
||||
# skip and don't try and apply a logger for the
|
||||
# specified module
|
||||
pass
|
||||
self.addCleanup(handler.close)
|
||||
self.addCleanup(handler.flush)
|
||||
|
||||
|
||||
class SymLink(object):
|
||||
|
|
Loading…
Reference in New Issue