Bug 1662427 - Backout 7c48fc6f04e3 for causing tasks with 'push-interval' optimizations to stop running on central,

Differential Revision: https://phabricator.services.mozilla.com/D89004
This commit is contained in:
Andrew Halberstadt 2020-09-01 16:38:15 +00:00
Родитель 8eaafae8fd
Коммит d82c6de5d5
2 изменённых файлов: 22 добавлений и 1 удалений

Просмотреть файл

@ -5,6 +5,7 @@
from __future__ import absolute_import, print_function, unicode_literals
from taskgraph.optimize import OptimizationStrategy, register_strategy
from taskgraph.util.attributes import match_run_on_projects
@register_strategy("backstop")
@ -25,10 +26,21 @@ class PushInterval(OptimizationStrategy):
Args:
push_interval (int): Number of pushes
remove_on_projects (set): For non-autoland projects, the task will
be removed if we're running on one of these projects, otherwise
it will be kept.
"""
def __init__(self, push_interval):
def __init__(self, push_interval, remove_on_projects=None):
self.push_interval = push_interval
self.remove_on_projects = remove_on_projects or {'try'}
def should_remove_task(self, task, params, _):
project = params["project"]
# Scheduling on a backstop only makes sense on autoland. For other projects,
# remove the task if the project matches self.remove_on_projects.
if project != 'autoland':
return match_run_on_projects(project, self.remove_on_projects)
# On every Nth push, want to run all tasks.
return int(params["pushlog_id"]) % self.push_interval != 0

Просмотреть файл

@ -336,6 +336,15 @@ def test_push_interval(params):
scheduled = {t.label for t in default_tasks if not opt.should_remove_task(t, params, None)}
assert scheduled == all_labels
# On non-autoland projects the 'remove_on_projects' value is used.
params['project'] = 'mozilla-central'
scheduled = {t.label for t in default_tasks if not opt.should_remove_task(t, params, None)}
assert scheduled == all_labels
params['project'] = 'try'
scheduled = {t.label for t in default_tasks if not opt.should_remove_task(t, params, None)}
assert scheduled == set()
if __name__ == '__main__':
main()