From 29af4212726bbab8464fa06ad549129382f05c5e Mon Sep 17 00:00:00 2001 From: Guilherme Gallo Date: Thu, 30 Jun 2022 18:41:14 -0300 Subject: [PATCH] ci/lava: Don't print LAVA debug messages Remove debug messages from the output in order to unclutter the log a little more for the developers. Signed-off-by: Guilherme Gallo Part-of: --- .gitlab-ci/lava/utils/lava_log.py | 23 +--------------- .gitlab-ci/tests/utils/test_lava_log.py | 35 ------------------------- 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/.gitlab-ci/lava/utils/lava_log.py b/.gitlab-ci/lava/utils/lava_log.py index e2eb4ef6589..eeb3d4d3a43 100644 --- a/.gitlab-ci/lava/utils/lava_log.py +++ b/.gitlab-ci/lava/utils/lava_log.py @@ -329,36 +329,15 @@ def fix_lava_gitlab_section_log(line): line["msg"] = f"\x1b[0K{marker}:{timestamp}:{id_collapsible}\r\x1b[0K{header}" -def filter_debug_messages(line: dict[str, str]) -> bool: - """Filter some LAVA debug messages that does not add much information to the - developer and may clutter the trace log.""" - if line["lvl"] != "debug": - return False - # line["msg"] can be a list[str] when there is a kernel dump - if not isinstance(line["msg"], str): - return False - - if re.match( - # Sometimes LAVA dumps this messages lots of times when the LAVA job is - # reaching the end. - r"^Listened to connection for namespace", - line["msg"], - ): - return True - return False - - def parse_lava_line(line) -> Optional[str]: prefix = "" suffix = "" - if line["lvl"] in ["results", "feedback"]: + if line["lvl"] in ["results", "feedback", "debug"]: return elif line["lvl"] in ["warning", "error"]: prefix = CONSOLE_LOG["COLOR_RED"] suffix = CONSOLE_LOG["RESET"] - elif filter_debug_messages(line): - return elif line["lvl"] == "input": prefix = "$ " suffix = "" diff --git a/.gitlab-ci/tests/utils/test_lava_log.py b/.gitlab-ci/tests/utils/test_lava_log.py index 144046c4707..32325c99d86 100644 --- a/.gitlab-ci/tests/utils/test_lava_log.py +++ b/.gitlab-ci/tests/utils/test_lava_log.py @@ -31,7 +31,6 @@ from lava.utils.lava_log import ( GitlabSection, LogFollower, LogSectionType, - filter_debug_messages, fix_lava_color_log, fix_lava_gitlab_section_log, hide_sensitive_data, @@ -250,40 +249,6 @@ def test_fix_lava_gitlab_section_log(message, fixed_message): assert message["msg"] == fixed_message -LAVA_DEBUG_SPAM_MESSAGES = { - "Listened to connection in debug level": ( - create_lava_yaml_msg( - msg="Listened to connection for namespace 'common' for up to 1s", - lvl="debug", - ), - True, - ), - "Listened to connection in debug level - v2": ( - create_lava_yaml_msg( - msg="Listened to connection for namespace 'prepare' for up to 9s", - lvl="debug", - ), - True, - ), - "Listened to connection in target level": ( - create_lava_yaml_msg( - msg="Listened to connection for namespace 'common' for up to 1s", - lvl="target", - ), - False, - ), -} - - -@pytest.mark.parametrize( - "message, expectation", - LAVA_DEBUG_SPAM_MESSAGES.values(), - ids=LAVA_DEBUG_SPAM_MESSAGES.keys(), -) -def test_filter_debug_messages(message, expectation): - assert filter_debug_messages(message) == expectation - - WATCHDOG_SCENARIOS = { "1 second before timeout": ({"seconds": -1}, does_not_raise()), "1 second after timeout": ({"seconds": 1}, pytest.raises(MesaCITimeoutError)),