Reduce Log Size
To reduce the testrepository.subunit output, eliminate debugging logs from gear.Server and gear.Client. This is handled via an ENV defined in the tox.ini called `OS_LOG_DEFAULTS`. Any module can be specified in the typicall python logging format (e.g. "gear.Server=INFO"). Each entry should be comma separated. For each valid entry, a fake logger is created with the log level set to that level. An invalid format will be skipped (expected: `<module name str>=<level_str>`). An invalid logging level will default to logging.DEBUG. Specifying OS_LOG_DEFAULT as an ENV var prior to running tox will override the default values defined in tox.ini. Change-Id: I893418435c538bfcedb803d12b57832c8111f06f
This commit is contained in:
parent
e9c5d62304
commit
d34e0b4dc7
@ -1,4 +1,4 @@
|
||||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} ${PYTHON:-python} -m subunit.run discover -t ./ tests $LISTOPT $IDOPTION
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} OS_LOG_DEFAULTS=${OS_LOG_DEFAULTS:-""} ${PYTHON:-python} -m subunit.run discover -t ./ tests $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
|
@ -862,6 +862,28 @@ class BaseTestCase(testtools.TestCase):
|
||||
format='%(asctime)s %(name)-32s '
|
||||
'%(levelname)-8s %(message)s'))
|
||||
|
||||
# NOTE(notmorgan): Extract logging overrides for specific libraries
|
||||
# from the OS_LOG_DEFAULTS env and create FakeLogger fixtures for
|
||||
# each. This is used to limit the output during test runs from
|
||||
# libraries that zuul depends on such as gear.
|
||||
log_defaults_from_env = os.environ.get('OS_LOG_DEFAULTS')
|
||||
|
||||
if log_defaults_from_env:
|
||||
for default in log_defaults_from_env.split(','):
|
||||
try:
|
||||
name, level_str = default.split('=', 1)
|
||||
level = getattr(logging, level_str, logging.DEBUG)
|
||||
self.useFixture(fixtures.FakeLogger(
|
||||
name=name,
|
||||
level=level,
|
||||
format='%(asctime)s %(name)-32s '
|
||||
'%(levelname)-8s %(message)s'))
|
||||
except ValueError:
|
||||
# NOTE(notmorgan): Invalid format of the log default,
|
||||
# skip and don't try and apply a logger for the
|
||||
# specified module
|
||||
pass
|
||||
|
||||
|
||||
class ZuulTestCase(BaseTestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user