Bug 1643689 - [taskgraph] Fix error in 'split_bugbug_args', r=marco

The dict needs to be passed to the last two substrategies, not just the last
one.

Differential Revision: https://phabricator.services.mozilla.com/D90159
This commit is contained in:
Andrew Halberstadt 2020-09-17 22:49:19 +00:00
parent 222db7d319
commit bd84e6e3aa
2 changed files with 45 additions and 11 deletions

View File

@ -462,6 +462,7 @@ class Alias(CompositeStrategy):
This can be useful to swap strategies in and out without needing to modify
the task transforms.
"""
def __init__(self, strategy):
super(Alias, self).__init__(strategy)
@ -475,6 +476,7 @@ class Alias(CompositeStrategy):
class Not(CompositeStrategy):
"""Given a strategy, returns the opposite."""
def __init__(self, strategy):
super(Not, self).__init__(strategy)
@ -491,10 +493,15 @@ def split_bugbug_arg(arg, substrategies):
Many bugbug based optimizations require passing an empty dict by reference
to communicate to downstream strategies. This function passes the provided
arg to the first strategies and an empty dict to last (bugbug based)
strategy.
arg to the first (non bugbug) strategies and a shared empty dict to the
bugbug strategy and all substrategies after it.
"""
return [arg] * (len(substrategies) - 1) + [{}]
from taskgraph.optimize.bugbug import BugBugPushSchedules
index = [i for i, strategy in enumerate(substrategies)
if isinstance(strategy, BugBugPushSchedules)][0]
return [arg] * index + [{}] * (len(substrategies) - index)
# Trigger registration in sibling modules.
@ -602,7 +609,9 @@ class experimental(object):
bugbug_debug_disperse = {
'test': Any(
'skip-unless-schedules',
Any('bugbug-low', 'platform-debug', 'platform-disperse'),
'bugbug-low',
'platform-debug',
'platform-disperse',
split_args=split_bugbug_arg
),
}
@ -611,7 +620,8 @@ class experimental(object):
bugbug_disperse_low = {
'test': Any(
'skip-unless-schedules',
Any('bugbug-low', 'platform-disperse'),
'bugbug-low',
'platform-disperse',
split_args=split_bugbug_arg
),
}
@ -620,7 +630,8 @@ class experimental(object):
bugbug_disperse_medium = {
'test': Any(
'skip-unless-schedules',
Any('bugbug-medium', 'platform-disperse'),
'bugbug-medium',
'platform-disperse',
split_args=split_bugbug_arg
),
}
@ -629,7 +640,8 @@ class experimental(object):
bugbug_disperse_reduced_medium = {
'test': Any(
'skip-unless-schedules',
Any('bugbug-reduced-manifests', 'platform-disperse'),
'bugbug-reduced-manifests',
'platform-disperse',
split_args=split_bugbug_arg
),
}
@ -638,7 +650,8 @@ class experimental(object):
bugbug_disperse_medium_no_unseen = {
'test': Any(
'skip-unless-schedules',
Any('bugbug-medium', 'platform-disperse-no-unseen'),
'bugbug-medium',
'platform-disperse-no-unseen',
split_args=split_bugbug_arg
),
}
@ -648,7 +661,8 @@ class experimental(object):
bugbug_disperse_medium_only_one = {
'test': Any(
'skip-unless-schedules',
Any('bugbug-medium', 'platform-disperse-only-one'),
'bugbug-medium',
'platform-disperse-only-one',
split_args=split_bugbug_arg
),
}
@ -657,7 +671,8 @@ class experimental(object):
bugbug_disperse_high = {
'test': Any(
'skip-unless-schedules',
Any('bugbug-high', 'platform-disperse'),
'bugbug-high',
'platform-disperse',
split_args=split_bugbug_arg
),
}
@ -691,6 +706,7 @@ class ExperimentalOverride(object):
base (object): A container class supporting attribute access.
overrides (dict): Values to update any accessed dictionaries with.
"""
def __init__(self, base, overrides):
self.base = base
self.overrides = overrides

View File

@ -54,6 +54,25 @@ def test_only_important_manifests(params, full_task_graph, filter_tasks):
assert unimportant == []
@pytest.mark.parametrize(
"func,min_expected",
(
pytest.param(
lambda t: (
t.kind == "test"
and t.attributes["unittest_suite"] == "mochitest-browser-chrome"
),
5,
id="mochitest-browser-chrome",
),
),
)
def test_tasks_are_scheduled(optimized_task_graph, filter_tasks, func, min_expected):
"""Ensure the specified tasks are scheduled on mozilla-central."""
tasks = [t.label for t in filter_tasks(optimized_task_graph, func)]
assert len(tasks) >= min_expected
@pytest.mark.parametrize(
"func",
(
@ -69,7 +88,6 @@ def test_only_important_manifests(params, full_task_graph, filter_tasks):
pytest.param(
lambda t: t.kind == "build-signing",
id="no build-signing",
marks=pytest.mark.xfail,
),
pytest.param(
lambda t: t.kind == "upload-symbols",