# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import unittest from pprint import pprint from unittest.mock import patch
import pytest from mozunit import MockedOpen, main from taskgraph import create from taskgraph.util import json, taskcluster from taskgraph.util.taskcluster import _task_definitions_cache
from gecko_taskgraph import actions from gecko_taskgraph.actions.util import (
combine_task_graph_files,
get_pushes_in_gap,
relativize_datestamps,
) from gecko_taskgraph.decision import read_artifact
TASK_DEF = { "created": "2017-10-10T18:33:03.460Z", # note that this is not an even number of seconds off! "deadline": "2017-10-11T18:33:03.461Z", "dependencies": [], "expires": "2018-10-10T18:33:04.461Z", "payload": { "artifacts": { "public": { "expires": "2018-10-10T18:33:03.463Z", "path": "/builds/worker/artifacts", "type": "directory",
},
}, "maxRunTime": 1800,
},
}
class TestCombineTaskGraphFiles(unittest.TestCase): def test_no_suffixes(self): with MockedOpen({}):
combine_task_graph_files([])
self.assertRaises(Exception, open("artifacts/to-run.json"))
def is_subset(subset, superset): if isinstance(subset, dict): return all(
key in superset and is_subset(val, superset[key]) for key, val in subset.items()
)
if isinstance(subset, list) or isinstance(subset, set): return all(
any(is_subset(subitem, superitem) for superitem in superset) for subitem in subset
)
if isinstance(subset, str): return subset in superset
# assume that subset is a plain value if none of the above match return subset == superset
def test_get_pushes_in_gap_finds_boundary(mocker): """Stop early when a push with the label is found within first chunk."""
label = "raptor-browsertime-firefox-tp6"
parameters = { "pushlog_id": "125", "head_repository": "https://hg.mozilla.org/mozilla-central", "project": "mozilla-central",
}
# pushes 100..124, boundary found at push 106 (has the label)
mocker.patch( "gecko_taskgraph.actions.util.get_pushes",
return_value=[str(i) for i in range(100, 125)],
)
# only pushes after the boundary (107..124) should be in gap assert result == [str(i) for i in range(107, 125)]
def test_get_pushes_in_gap_no_boundary_found(mocker): """Return all fetched pushes when no boundary is found within max depth."""
label = "raptor-browsertime-firefox-tp6"
parameters = { "pushlog_id": "125", "head_repository": "https://hg.mozilla.org/mozilla-central", "project": "mozilla-central",
}
# 4 chunks of 25, none has the label
mocker.patch( "gecko_taskgraph.actions.util.get_pushes",
side_effect=[
[str(i) for i in range(100, 125)],
[str(i) for i in range(75, 100)],
[str(i) for i in range(50, 75)],
[str(i) for i in range(25, 50)],
],
)
mocker.patch( "gecko_taskgraph.actions.util.get_label_to_taskid",
return_value={},
)
result = get_pushes_in_gap(parameters, label)
# all 100 pushes should be returned as gap assert result == [str(i) for i in range(25, 125)]
def test_get_pushes_in_gap_boundary_at_first_push(mocker): """
Boundary found at the first searched push (124, newest push),
so no pushes are added to gap before returning """
label = "raptor-browsertime-firefox-tp6"
parameters = { "pushlog_id": "125", "head_repository": "https://hg.mozilla.org/mozilla-central", "project": "mozilla-central",
}
mocker.patch( "gecko_taskgraph.actions.util.get_pushes",
return_value=[str(i) for i in range(100, 125)],
)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.