Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Unified Diff: infra/services/gsubtreed/test/gsubtreed_test.py

Issue 2063913002: Fix gsubtreed to only include logs from modules that we care about. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: flaek Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/services/gsubtreed/gsubtreed.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/services/gsubtreed/test/gsubtreed_test.py
diff --git a/infra/services/gsubtreed/test/gsubtreed_test.py b/infra/services/gsubtreed/test/gsubtreed_test.py
index b994eec8ecd843aa16a0aa8b00cd75e6ccc346ad..8a64060d5d8b8c861f517edaaaa3e4018f810704 100644
--- a/infra/services/gsubtreed/test/gsubtreed_test.py
+++ b/infra/services/gsubtreed/test/gsubtreed_test.py
@@ -64,6 +64,19 @@ def RunTest(test_name):
s = super(LogFormatter, self).format(record)
return s.replace(base_repo_path, '[TMPDIR]')
+ class LogFilterer(logging.Filter):
+ def filter(self, record):
+ # infra.libs.git2.repo logs this message if the command took longer than
+ # 1s to run. This causes test flakes occasionally.
+ if (record.name.startswith('infra.libs.git2.repo.Repo') and
+ record.msg.startswith('Finished in ')): # pragma: no cover
+ return False
+
+ return record.name.startswith((
+ 'infra.services.gsubtreed',
+ 'infra.libs.git2',
+ ))
+
def checkpoint(message, include_committer=False, include_config=False):
repos = collections.OrderedDict()
repos['origin'] = origin.snap(include_committer, include_config)
@@ -79,6 +92,7 @@ def RunTest(test_name):
root_logger = logging.getLogger()
shandler = logging.StreamHandler(logout)
shandler.setFormatter(LogFormatter('%(levelname)s: %(message)s'))
+ shandler.addFilter(LogFilterer())
root_logger.addHandler(shandler)
shandler.setLevel(logging.INFO)
@@ -103,11 +117,7 @@ def RunTest(test_name):
root_logger.removeHandler(shandler)
- # infra.libs.git2.repo logs this message if the command took longer than
- # 1s to run. This causes test flakes occasionally.
- log_lines = [x for x in logout.getvalue().splitlines()
- if 'Finished in ' not in x]
- ret.append({'log output': log_lines})
+ ret.append({'log output': logout.getvalue().splitlines()})
ret.append({
'inner_loop success': success,
« no previous file with comments | « infra/services/gsubtreed/gsubtreed.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698