diff --git a/.gitlab-ci/lava/utils/log_section.py b/.gitlab-ci/lava/utils/log_section.py index b4072667eca..25620a6155b 100644 --- a/.gitlab-ci/lava/utils/log_section.py +++ b/.gitlab-ci/lava/utils/log_section.py @@ -11,6 +11,7 @@ from lava.utils.gitlab_section import GitlabSection class LogSectionType(Enum): UNKNOWN = auto() LAVA_BOOT = auto() + TEST_DUT_SUITE = auto() TEST_SUITE = auto() TEST_CASE = auto() LAVA_POST_PROCESSING = auto() @@ -24,7 +25,11 @@ class LogSectionType(Enum): # the enqueue delay. LAVA_BOOT_TIMEOUT = int(getenv("LAVA_BOOT_TIMEOUT", 9)) -# Test suite phase is where the initialization happens. +# Test DUT suite phase is where the initialization happens in DUT, not on docker. +# The device will be listening to SSH session until the end of the job. +LAVA_TEST_DUT_SUITE_TIMEOUT = int(getenv("JOB_TIMEOUT", 60)) + +# Test suite phase is where the initialization happens on docker. LAVA_TEST_SUITE_TIMEOUT = int(getenv("LAVA_TEST_SUITE_TIMEOUT", 5)) # Test cases may take a long time, this script has no right to interrupt @@ -39,6 +44,7 @@ LAVA_POST_PROCESSING_TIMEOUT = int(getenv("LAVA_POST_PROCESSING_TIMEOUT", 5)) FALLBACK_GITLAB_SECTION_TIMEOUT = timedelta(minutes=10) DEFAULT_GITLAB_SECTION_TIMEOUTS = { LogSectionType.LAVA_BOOT: timedelta(minutes=LAVA_BOOT_TIMEOUT), + LogSectionType.TEST_DUT_SUITE: timedelta(minutes=LAVA_TEST_DUT_SUITE_TIMEOUT), LogSectionType.TEST_SUITE: timedelta(minutes=LAVA_TEST_SUITE_TIMEOUT), LogSectionType.TEST_CASE: timedelta(minutes=LAVA_TEST_CASE_TIMEOUT), LogSectionType.LAVA_POST_PROCESSING: timedelta( @@ -83,10 +89,17 @@ LOG_SECTIONS = ( section_type=LogSectionType.TEST_CASE, ), LogSection( - regex=re.compile(r"? ([^>]*)"), - levels=("target", "debug"), + regex=re.compile(r"? ([^>]*ssh.*server.*)"), + levels=("debug"), section_id="{}", - section_header="test_suite {}", + section_header="[dut] test_suite {}", + section_type=LogSectionType.TEST_DUT_SUITE, + ), + LogSection( + regex=re.compile(r"? ([^>]*)"), + levels=("debug"), + section_id="{}", + section_header="[docker] test_suite {}", section_type=LogSectionType.TEST_SUITE, ), LogSection( diff --git a/.gitlab-ci/tests/utils/test_lava_log.py b/.gitlab-ci/tests/utils/test_lava_log.py index 882d33f6607..269253b0336 100644 --- a/.gitlab-ci/tests/utils/test_lava_log.py +++ b/.gitlab-ci/tests/utils/test_lava_log.py @@ -62,6 +62,11 @@ def test_gitlab_section(method, collapsed, expectation): def test_gl_sections(): lines = [ + { + "dt": datetime.now(), + "lvl": "debug", + "msg": "Received signal: 0_setup-ssh-server 10145749_1.3.2.3.1", + }, { "dt": datetime.now(), "lvl": "debug", @@ -92,10 +97,13 @@ def test_gl_sections(): }, ] lf = LogFollower() - for line in lines: - lf.manage_gl_sections(line) + with lf: + for line in lines: + lf.manage_gl_sections(line) + parsed_lines = lf.flush() + + section_types = [s.type for s in lf.section_history] - parsed_lines = lf.flush() assert "section_start" in parsed_lines[0] assert "collapsed=true" not in parsed_lines[0] assert "section_end" in parsed_lines[1] @@ -103,7 +111,17 @@ def test_gl_sections(): assert "collapsed=true" not in parsed_lines[2] assert "section_end" in parsed_lines[3] assert "section_start" in parsed_lines[4] - assert "collapsed=true" in parsed_lines[4] + assert "collapsed=true" not in parsed_lines[4] + assert "section_end" in parsed_lines[5] + assert "section_start" in parsed_lines[6] + assert "collapsed=true" in parsed_lines[6] + assert section_types == [ + # LogSectionType.LAVA_BOOT, True, if LogFollower started with Boot section + LogSectionType.TEST_DUT_SUITE, + LogSectionType.TEST_SUITE, + LogSectionType.TEST_CASE, + LogSectionType.LAVA_POST_PROCESSING, + ] def test_log_follower_flush():