summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Gallo <guilherme.gallo@collabora.com>2022-06-21 16:30:34 -0300
committerMarge Bot <emma+marge@anholt.net>2022-06-28 22:51:45 +0000
commit3b8d10d270413a1f49ccce5563c1e4e96e10b6ef (patch)
tree758666aa9ce1a3a766249b6dbb88184fa79ef712
parent58313f3257b338928a8ae4ea375eedb50accf2bb (diff)
ci/lava: Improve result parsing regex
LAVA job logs have an ongoing problem of message interleaving with kmsg. So any kernel dumps and LAVA signals (which are being printed in kmsg) will have a chance to clutter the pattern matching for `hwci: mesa: (pass|fail)` line. v2: - Add an 1 second sleep before exiting the test script, to give enough time to print the result message without conflicting with LAVA ENDTC signal from kmsg Closes: #6714 Signed-off-by: Guilherme Gallo <guilherme.gallo@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17175>
-rwxr-xr-x.gitlab-ci/common/init-stage2.sh4
-rwxr-xr-x.gitlab-ci/lava/lava_job_submitter.py2
-rw-r--r--.gitlab-ci/tests/test_lava_job_submitter.py49
3 files changed, 54 insertions, 1 deletions
diff --git a/.gitlab-ci/common/init-stage2.sh b/.gitlab-ci/common/init-stage2.sh
index 2f6f498c9d6..ff73ec8a06f 100755
--- a/.gitlab-ci/common/init-stage2.sh
+++ b/.gitlab-ci/common/init-stage2.sh
@@ -157,5 +157,9 @@ fi
# We still need to echo the hwci: mesa message, as some scripts rely on it, such
# as the python ones inside the bare-metal folder
[ ${EXIT_CODE} -eq 0 ] && RESULT=pass
+
+set +x
echo "hwci: mesa: $RESULT"
+# Sleep a bit to avoid kernel dump message interleave from LAVA ENDTC signal
+sleep 1
exit $EXIT_CODE
diff --git a/.gitlab-ci/lava/lava_job_submitter.py b/.gitlab-ci/lava/lava_job_submitter.py
index f9d4d89b893..9eba34c8820 100755
--- a/.gitlab-ci/lava/lava_job_submitter.py
+++ b/.gitlab-ci/lava/lava_job_submitter.py
@@ -313,7 +313,7 @@ class LAVAJob:
"""
log_lines = [l["msg"] for l in lava_lines if l["lvl"] == "target"]
for line in log_lines:
- if result := re.search(r"hwci: mesa: (\S*)", line):
+ if result := re.search(r"hwci: mesa: (pass|fail)", line):
self.is_finished = True
self.status = result.group(1)
color = LAVAJob.color_status_map.get(self.status, CONSOLE_LOG_COLOR_RED)
diff --git a/.gitlab-ci/tests/test_lava_job_submitter.py b/.gitlab-ci/tests/test_lava_job_submitter.py
index 76a43c33eff..9e010b46b14 100644
--- a/.gitlab-ci/tests/test_lava_job_submitter.py
+++ b/.gitlab-ci/tests/test_lava_job_submitter.py
@@ -421,6 +421,7 @@ GITLAB_SECTION_MANGLED_SCENARIOS = {
),
}
+
@pytest.mark.parametrize(
"message, fixed_message",
GITLAB_SECTION_MANGLED_SCENARIOS.values(),
@@ -464,3 +465,51 @@ LAVA_DEBUG_SPAM_MESSAGES = {
)
def test_filter_debug_messages(message, expectation):
assert filter_debug_messages(message) == expectation
+
+
+LAVA_RESULT_LOG_SCENARIOS = {
+ # the submitter should accept xtrace logs
+ "Bash xtrace echo with kmsg interleaving": (
+ create_lava_yaml_msg(
+ msg="echo hwci: mesa: pass[ 737.673352] <LAVA_SIGNAL_ENDTC mesa-ci>",
+ lvl="target",
+ ),
+ "pass",
+ ),
+ # the submitter should accept xtrace logs
+ "kmsg result print": (
+ create_lava_yaml_msg(
+ msg="[ 737.673352] hwci: mesa: pass",
+ lvl="target",
+ ),
+ "pass",
+ ),
+ # if the job result echo has a very bad luck, it still can be interleaved
+ # with kmsg
+ "echo output with kmsg interleaving": (
+ create_lava_yaml_msg(
+ msg="hwci: mesa: pass[ 737.673352] <LAVA_SIGNAL_ENDTC mesa-ci>",
+ lvl="target",
+ ),
+ "pass",
+ ),
+ "fail case": (
+ create_lava_yaml_msg(
+ msg="hwci: mesa: fail",
+ lvl="target",
+ ),
+ "fail",
+ ),
+}
+
+
+@pytest.mark.parametrize(
+ "message, expectation",
+ LAVA_RESULT_LOG_SCENARIOS.values(),
+ ids=LAVA_RESULT_LOG_SCENARIOS.keys(),
+)
+def test_filter_debug_messages(message, expectation, mock_proxy):
+ job = LAVAJob(mock_proxy(), "")
+ job.parse_job_result_from_log([message])
+
+ assert job.status == expectation