Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Commit

Permalink
Add support to trigger talos jobs for a given build (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalpesh Krishna authored and armenzg committed May 6, 2016
1 parent 4cfb217 commit 171c253
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 3 deletions.
13 changes: 13 additions & 0 deletions mozci/mozci.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
determine_upstream_builder,
is_downstream,
list_builders,
get_talos_jobs_for_build,
)
from mozci.sources import buildjson
from mozci.query_jobs import (
Expand Down Expand Up @@ -558,6 +559,18 @@ def trigger(builder, revision, files=[], dry_run=False, extra_properties=None):
extra_properties=extra_properties)


def trigger_talos_jobs_for_build(buildername, revision, times, priority, dry_run=False):
"""
Trigger all talos jobs for a given build and revision.
"""
buildernames = get_talos_jobs_for_build(buildername)
for buildername in buildernames:
trigger_range(buildername=buildername,
revisions=[revision],
times=times,
dry_run=dry_run)


def trigger_all_talos_jobs(repo_name, revision, times, priority=0, dry_run=False):
"""
Trigger talos jobs (excluding 'pgo') for a given revision.
Expand Down
11 changes: 11 additions & 0 deletions mozci/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,17 @@ def build_tests_per_platform_graph(builders):
return graph


def get_talos_jobs_for_build(buildername):
buildernames = []
build_type = 'pgo' if get_buildername_metadata(buildername)['build_type'] == 'pgo' else 'opt'
downstream_jobs = get_downstream_jobs(buildername)
for job in downstream_jobs:
info = get_buildername_metadata(job)
if info['build_type'] == build_type and info['job_type'] == 'talos':
buildernames.append(job)
return buildernames


def build_talos_buildernames_for_repo(repo_name, pgo_only=False):
"""
This function aims to generate all possible talos jobs for a given branch.
Expand Down
64 changes: 64 additions & 0 deletions test/mock_talos_allthethings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{"builders": {
"Linux x86-64 mozilla-inbound pgo-build": {
"properties": {
"basedir": "/builds/slave/m-in-l64-pgo-00000000000000000",
"branch": "mozilla-inbound",
"platform": "linux64",
"product": "firefox",
"repo_path": "integration/mozilla-inbound",
"script_repo_revision": "production"
},
"shortname": "mozilla-inbound-linux64-pgo",
"slavebuilddir": "m-in-l64-pgo-00000000000000000",
"slavepool": "2e490369b232e800931337b9b1186f5027eac1e6"
},
"Ubuntu HW 12.04 x64 mozilla-inbound pgo talos chromez-e10s": {
"properties": {
"basedir": "/builds/slave/test",
"branch": "mozilla-inbound",
"builddir": "mozilla-inbound_ubuntu64_hw_test-chromez-e10s",
"platform": "ubuntu64_hw",
"product": "firefox",
"repo_path": "integration/mozilla-inbound",
"script_repo_revision": "production",
"slavebuilddir": "test",
"stage_platform": "linux64-pgo"
},
"shortname": "mozilla-inbound_ubuntu64_hw_test-chromez-e10s-pgo",
"slavebuilddir": "test",
"slavepool": "65cdcbde3592dd1a95a3fc3a90d029f113f6bac1"
},
"Ubuntu HW 12.04 x64 mozilla-inbound pgo talos dromaeojs": {
"properties": {
"basedir": "/builds/slave/test",
"branch": "mozilla-inbound",
"builddir": "mozilla-inbound_ubuntu64_hw_test-dromaeojs",
"platform": "ubuntu64_hw",
"product": "firefox",
"repo_path": "integration/mozilla-inbound",
"script_repo_revision": "production",
"slavebuilddir": "test",
"stage_platform": "linux64-pgo"
},
"shortname": "mozilla-inbound_ubuntu64_hw_test-dromaeojs-pgo",
"slavebuilddir": "test",
"slavepool": "65cdcbde3592dd1a95a3fc3a90d029f113f6bac1"
},
"Ubuntu HW 12.04 x64 mozilla-inbound pgo talos dromaeojs-e10s": {
"properties": {
"basedir": "/builds/slave/test",
"branch": "mozilla-inbound",
"builddir": "mozilla-inbound_ubuntu64_hw_test-dromaeojs-e10s",
"platform": "ubuntu64_hw",
"product": "firefox",
"repo_path": "integration/mozilla-inbound",
"script_repo_revision": "production",
"slavebuilddir": "test",
"stage_platform": "linux64-pgo"
},
"shortname": "mozilla-inbound_ubuntu64_hw_test-dromaeojs-e10s-pgo",
"slavebuilddir": "test",
"slavepool": "65cdcbde3592dd1a95a3fc3a90d029f113f6bac1"
}
}
}
23 changes: 20 additions & 3 deletions test/test_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@
find_buildernames,
is_downstream,
list_builders,
get_talos_jobs_for_build,
)


def _get_mock_allthethings():
def _get_file(file_name):
"""Load a mock allthethings.json from disk."""
PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"mock_allthethings.json"
file_name
)
with open(PATH, 'r') as f:
return json.load(f)

MOCK_ALLTHETHINGS = _get_mock_allthethings()
MOCK_ALLTHETHINGS = _get_file("mock_allthethings.json")
TALOS_ALLTHETHINGS = _get_file("mock_talos_allthethings.json")


class TestIsDownstream(unittest.TestCase):
Expand Down Expand Up @@ -363,6 +365,21 @@ def test_talos_buildernames(self, list_builders):
'PlatformB try talos buildername'])
self.assertEquals(build_talos_buildernames_for_repo('not-a-repo'), [])

def test_talos_single_build(self):
"""Test if the function finds the right suite_name."""
import mozci.platforms
mozci.platforms.fetch_allthethings_data = Mock(return_value=TALOS_ALLTHETHINGS)
DOWNSTREAM = [
"Ubuntu HW 12.04 x64 mozilla-inbound pgo talos chromez-e10s",
"Ubuntu HW 12.04 x64 mozilla-inbound pgo talos dromaeojs",
"Ubuntu HW 12.04 x64 mozilla-inbound pgo talos dromaeojs-e10s"
]
mozci.platforms.get_downstream_jobs = Mock(return_value=DOWNSTREAM)
build = "Linux x86-64 mozilla-inbound pgo-build"
expected = DOWNSTREAM
self.assertEquals(get_talos_jobs_for_build(build), expected)


suitename_test_cases = [
("Platform1 try talos tp5o", "tp5o"),
("Platform1 try opt test mochitest-1", "mochitest-1"),
Expand Down

0 comments on commit 171c253

Please sign in to comment.