From f30d52bda8d3b4a952b9d9d91283579e2c596290 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Sat, 16 Jul 2022 01:35:27 +0200 Subject: [PATCH] Support parsing suite from all possible labels (#816) * Support parsing suite and configuration from label when a task is not split in chunks * Assert we can parse all labels to suites when checking if a group is still running on a push * Add mochitest-browser-a11y to the list of suites * Add a comment to remind ourselves of stopping to parse labels when the suite information will be part of the task definition --- mozci/push.py | 8 +++++++- mozci/task.py | 6 ++++-- tests/test_task.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/mozci/push.py b/mozci/push.py index 82cf0d14..6fb6519c 100644 --- a/mozci/push.py +++ b/mozci/push.py @@ -556,7 +556,13 @@ def is_group_running(self, group): task for task in self.tasks if task.state not in TASK_FINAL_STATES ] - group_types = {get_suite_from_label(task.label) for task in group.tasks} + group_types = set() + for task in group.tasks: + suite = get_suite_from_label(task.label) + assert ( + suite is not None + ), f"Couldn't parse suite for {task.label} ({task.id})" + group_types.add(suite) if all(task.is_tests_grouped for task in group.tasks): for task in running_tasks: diff --git a/mozci/task.py b/mozci/task.py index 3d5b5d30..ec8b8d31 100644 --- a/mozci/task.py +++ b/mozci/task.py @@ -40,6 +40,7 @@ class Status(Enum): "mochitest-chrome-gpu", "mochitest-chrome", "mochitest-devtools-chrome", + "mochitest-browser-a11y", "mochitest-browser-chrome", "web-platform-tests-crashtest", "web-platform-tests-reftest", @@ -74,9 +75,10 @@ class Status(Enum): ) +# We can stop relying on parsing the label when https://bugzilla.mozilla.org/show_bug.cgi?id=1632870 is fixed. def get_suite_from_label(label: str) -> Optional[str]: for s in SUITES: - if f"-{s}-" in label: + if f"-{s}-" in label or label.endswith(f"-{s}"): return s return None @@ -87,7 +89,7 @@ def get_configuration_from_label(label: str) -> str: # Remove the suite name. config = label for s in SUITES: - if f"-{s}-" in config: + if f"-{s}-" in config or label.endswith(f"-{s}"): config = config.replace(s, "*") # Remove the chunk number. diff --git a/tests/test_task.py b/tests/test_task.py index f0a21f19..dc448983 100644 --- a/tests/test_task.py +++ b/tests/test_task.py @@ -16,6 +16,8 @@ GroupSummary, Task, TestTask, + get_configuration_from_label, + get_suite_from_label, is_autoclassifiable, ) from mozci.util.taskcluster import ( @@ -953,3 +955,39 @@ def test_autoclassify( ) task._failure_types = task_failure_types assert is_autoclassifiable(task) is result + + +def test_get_suite_from_label_and_get_configuration_from_label(): + assert ( + get_suite_from_label("test-macosx1015-64-qr/opt-mochitest-devtools-chrome-1") + == "mochitest-devtools-chrome" + ) + assert ( + get_configuration_from_label( + "test-macosx1015-64-qr/opt-mochitest-devtools-chrome-1" + ) + == "test-macosx1015-64-qr/opt-*" + ) + assert get_suite_from_label("test-linux1804-64-qr/debug-crashtest") == "crashtest" + assert ( + get_configuration_from_label("test-linux1804-64-qr/debug-crashtest") + == "test-linux1804-64-qr/debug-*" + ) + assert ( + get_suite_from_label("test-linux1804-64-qr/debug-mochitest-browser-a11y") + == "mochitest-browser-a11y" + ) + assert ( + get_configuration_from_label( + "test-linux1804-64-qr/debug-mochitest-browser-a11y" + ) + == "test-linux1804-64-qr/debug-*" + ) + assert ( + get_suite_from_label("test-windows10-64-2004-qr/opt-mochitest-remote") + == "mochitest-remote" + ) + assert ( + get_configuration_from_label("test-windows10-64-2004-qr/opt-mochitest-remote") + == "test-windows10-64-2004-qr/opt-*" + )