Skip to content

Commit

Permalink
Support parsing suite from all possible labels (#816)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
marco-c committed Jul 15, 2022
1 parent a4cbb26 commit f30d52b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
8 changes: 7 additions & 1 deletion mozci/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions mozci/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
38 changes: 38 additions & 0 deletions tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
GroupSummary,
Task,
TestTask,
get_configuration_from_label,
get_suite_from_label,
is_autoclassifiable,
)
from mozci.util.taskcluster import (
Expand Down Expand Up @@ -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-*"
)

0 comments on commit f30d52b

Please sign in to comment.