From 2cee21ffa5d2fe14341e6b172ebd9ec6183f8bbf Mon Sep 17 00:00:00 2001 From: Guilherme Gallo Date: Thu, 27 Apr 2023 18:48:53 -0300 Subject: [PATCH] ci/lava: Distinguish test suites in DUT vs Docker Test suite in the dut is just running SSH server and waiting for the docker container to start the SSH session. So it can take all the test cases accumulated duration, not just the init-stage1.sh part anymore. Signed-off-by: Guilherme Gallo Part-of: --- .gitlab-ci/lava/utils/log_section.py | 19 ++++++++++++++++--- .gitlab-ci/tests/utils/test_lava_log.py | 26 ++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci/lava/utils/log_section.py b/.gitlab-ci/lava/utils/log_section.py index b407266..25620a6 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"? ([^>]*ssh.*server.*)"), + levels=("debug"), + section_id="{}", + section_header="[dut] test_suite {}", + section_type=LogSectionType.TEST_DUT_SUITE, + ), + LogSection( regex=re.compile(r"? ([^>]*)"), - levels=("target", "debug"), + levels=("debug"), section_id="{}", - section_header="test_suite {}", + 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 882d33f..269253b 100644 --- a/.gitlab-ci/tests/utils/test_lava_log.py +++ b/.gitlab-ci/tests/utils/test_lava_log.py @@ -65,6 +65,11 @@ def test_gl_sections(): { "dt": datetime.now(), "lvl": "debug", + "msg": "Received signal: 0_setup-ssh-server 10145749_1.3.2.3.1", + }, + { + "dt": datetime.now(), + "lvl": "debug", "msg": "Received signal: 0_mesa 5971831_1.3.2.3.1", }, # Redundant log message which triggers the same Gitlab Section, it @@ -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(): -- 2.7.4