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

Commit

Permalink
Merge 514b8ec into 25800da
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalpesh Krishna committed May 5, 2016
2 parents 25800da + 514b8ec commit 7c779ad
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 31 deletions.
39 changes: 26 additions & 13 deletions mozci/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def get_buildername_metadata(buildername):
"""Return metadata associated to a buildername.
Returns a dictionary with the following information:
* build_type - It returns 'opt' or 'debug'
* build_type - It returns 'opt' or 'debug' or 'pgo'
* downstream - If the job requires an upstream job to be triggered
* job_type - It returns 'build', 'test' or 'talos'
* platform_name - It associates upstream & downstream builders (e.g. win32)
Expand Down Expand Up @@ -261,16 +261,37 @@ def get_buildername_metadata(buildername):
platform_name = props['platform']
suite_name = None

repo_path = props.get('branch')
repo_name = _get_repo_name(repo_path)

# First check whether build type is obvious from platform_name
# In case that fails, look for a keyword in buildername
# Lastly, check a special case of PGO build
# Default case is 'opt'
if platform_name.endswith('-debug'):
# e.g. win32-debug
build_type = 'debug'
platform_name = platform_name[:-len('-debug')]
elif platform_name.endswith('-pgo'):
build_type = 'pgo'
platform_name = platform_name[:-len('-pgo')]
elif platform_name.endswith('-opt'):
build_type = 'opt'
platform_name = platform_name[:-len('-opt')]
elif 'debug' in buildername:
build_type = 'debug'
elif 'pgo' in buildername:
build_type = 'pgo'
elif 'opt' in buildername:
build_type = 'opt'
elif (repo_name in ['mozilla-aurora', 'mozilla-beta', 'mozilla-release'] or
'esr' in repo_name) and job_type == 'build':
# special cases of a PGO build
build_type = 'pgo'
else:
# default choice
build_type = 'opt'

repo_path = props.get('branch')
repo_name = _get_repo_name(repo_path)

# Builders in gaia-try are at same time build and test jobs, and
# should be considered upstream.
if repo_name == 'gaia-try':
Expand Down Expand Up @@ -306,15 +327,7 @@ def _get_job_type(test_job):
mobile jobs naming. This function does not apply to B2g and
TaskCluster.
"""
job_type = None

if 'pgo test' in test_job or 'pgo talos' in test_job:
job_type = 'pgo'
elif 'opt' in test_job or 'talos' in test_job:
job_type = 'opt'
elif 'debug' in test_job:
job_type = 'debug'
return job_type
return get_buildername_metadata(test_job)['build_type']


def build_tests_per_platform_graph(builders):
Expand Down
79 changes: 79 additions & 0 deletions test/mock_allthethings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@
"slavebuilddir": "test",
"slavepool": "b23a27e728808b811f86a8a7a20edb1b3648ec9a"
},
"Platform1 try pgo test mochitest-1": {
"properties": {
"basedir": "/builds/slave/test",
"branch": "try",
"moz_repo_path": "",
"platform": "platform1",
"product": "firefox",
"repo_path": "try",
"script_repo_revision": "production",
"slavebuilddir": "test",
"stage_platform": "linux-pgo"
},
"shortname": "fx-team_ubuntu32_vm_test_pgo-mochitest-1",
"slavebuilddir": "test",
"slavepool": "b4fe660632a9f74c0e413094fbb19fc9c627f095"
},
"Platform1 try talos tp5o": {
"properties": {
"branch": "try",
Expand Down Expand Up @@ -241,6 +257,18 @@
"slavebuilddir": "branch-platform-00000000000000000",
"slavepool": "2e490369b232e800931337b9b1186f5027eac1e6"
},
"Platform1 fx-team pgo test mochitest-1": {
"properties": {
"branch": "fx-team",
"platform": "platform1",
"product": "real-product",
"slavebuilddir": "branch-platform-00000000000000000",
"stage_platform": "real-platform"
},
"shortname": "fx-team-platform1",
"slavebuilddir": "branch-platform-00000000000000000",
"slavepool": "2e490369b232e800931337b9b1186f5027eac1e6"
},
"Platform1 mozilla-inbound opt test mochitest-1": {
"properties": {
"branch": "mozilla-inbound",
Expand All @@ -253,6 +281,57 @@
"slavebuilddir": "branch-platform-00000000000000000",
"slavepool": "2e490369b232e800931337b9b1186f5027eac1e6"
},
"Platform1 fx-team opt test mochitest-1": {
"properties": {
"branch": "fx-team",
"platform": "platform1",
"product": "real-product",
"slavebuilddir": "branch-platform-00000000000000000",
"stage_platform": "real-platform"
},
"shortname": "fx-team-platform1",
"slavebuilddir": "branch-platform-00000000000000000",
"slavepool": "2e490369b232e800931337b9b1186f5027eac1e6"
},
"Platform1 mozilla-inbound build": {
"properties": {
"basedir": "/c/builds/moz2_slave/m-in-w32-000000000000000000000",
"branch": "mozilla-inbound",
"platform": "platform1",
"product": "firefox",
"repo_path": "integration/mozilla-inbound",
"script_repo_revision": "production"
},
"shortname": "mozilla-inbound-platform1",
"slavebuilddir": "m-in-w32-000000000000000000000",
"slavepool": "32d810114513a7bb3240c73039fd8114b8040c7e"
},
"Platform1 mozilla-aurora build": {
"properties": {
"basedir": "/c/builds/moz2_slave/m-aurora-w32-00000000000000000",
"branch": "mozilla-aurora",
"platform": "platform1",
"product": "firefox",
"repo_path": "releases/mozilla-aurora",
"script_repo_revision": "production"
},
"shortname": "mozilla-aurora-platform1",
"slavebuilddir": "m-aurora-w32-00000000000000000",
"slavepool": "32d810114513a7bb3240c73039fd8114b8040c7e"
},
"Platform1 mozilla-inbound pgo-build": {
"properties": {
"basedir": "/c/builds/moz2_slave/m-in-w32-pgo-00000000000000000",
"branch": "mozilla-inbound",
"platform": "platform1",
"product": "firefox",
"repo_path": "integration/mozilla-inbound",
"script_repo_revision": "production"
},
"shortname": "mozilla-inbound-platform1-pgo",
"slavebuilddir": "m-in-w32-pgo-00000000000000000",
"slavepool": "32d810114513a7bb3240c73039fd8114b8040c7e"
},
"Platform1 mozilla-release pgo test mochitest-1": {
"properties": {
"branch": "mozilla-release",
Expand Down
54 changes: 36 additions & 18 deletions test/test_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest

from mock import patch
from mock import Mock
from mozci.errors import MozciError
from mozci.platforms import (
MAX_PUSHES,
Expand Down Expand Up @@ -220,7 +221,7 @@ def test_pgo(self, fetch_allthethings_data):
_wanted_builder('Platform1 mozilla-esr45 pgo test mochitest-1'),
True)
self.assertEquals(
_wanted_builder('Platform1 try pgo test mochitest-1'),
_wanted_builder('Platform1 fx-team pgo test mochitest-1'),
False)
with pytest.raises(MozciError):
_wanted_builder('Platform1 non-existent-repo1 pgo test mochitest-1')
Expand Down Expand Up @@ -284,7 +285,6 @@ def test_build_graph(self, fetch_allthethings_data):
}
}
}

self.assertEquals(build_tests_per_platform_graph(builders), expected)


Expand Down Expand Up @@ -361,20 +361,37 @@ def test_talos_buildernames(self, list_builders):
'PlatformB try talos buildername'])
self.assertEquals(build_talos_buildernames_for_repo('not-a-repo'), [])

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

class TestGetBuildernameMetadata(unittest.TestCase):
""" Test that we can evaluate metadata correctly """

@patch('mozci.platforms.fetch_allthethings_data')
def test_suite_name(self, fetch_allthethings_data):
"""Test if the function finds the right suite_name."""
fetch_allthethings_data.return_value = MOCK_ALLTHETHINGS
test_cases = [
("Platform1 try talos tp5o", "tp5o"),
("Platform1 try opt test mochitest-1", "mochitest-1")
]
for t in test_cases:
self.assertEquals(get_buildername_metadata(t[0])['suite_name'], t[1])
@pytest.mark.parametrize("test_job, expected", suitename_test_cases)
def test_suite_name(test_job, expected):
"""Test if the function finds the right suite_name."""
import mozci.platforms
mozci.platforms.fetch_allthethings_data = Mock(return_value=MOCK_ALLTHETHINGS)
obtained = get_buildername_metadata(test_job)['suite_name']
assert obtained == expected, \
'obtained: "%s", expected "%s"' % (obtained, expected)


buildtype_test_cases = [
("Platform1 mozilla-inbound build", "opt"),
("Platform1 mozilla-aurora build", "pgo"),
("Platform1 mozilla-inbound pgo-build", "pgo")
]


@pytest.mark.parametrize("test_job, expected", buildtype_test_cases)
def test_buildtype_name(test_job, expected):
"""Test if the function finds the right build_type."""
import mozci.platforms
mozci.platforms.fetch_allthethings_data = Mock(return_value=MOCK_ALLTHETHINGS)
obtained = get_buildername_metadata(test_job)['build_type']
assert obtained == expected, \
'obtained: "%s", expected "%s"' % (obtained, expected)


def test_include_builders_matching():
Expand All @@ -388,10 +405,11 @@ def test_include_builders_matching():


get_job_type_test_cases = [
("Platform1 try pgo talos mochitest-1", "pgo"),
("Platform1 try debug test mochitest-1", "debug"),
("Platform2 try talos tp5o", "opt"),
("Platform1 try opt test mochitest-1", "opt")]
("Platform1 try opt test mochitest-1", "opt"),
("Platform1 mozilla-inbound build", "opt"),
("Platform1 mozilla-aurora build", "pgo"),
("Platform1 mozilla-inbound pgo-build", "pgo")
]


@pytest.mark.parametrize("test_job, expected", get_job_type_test_cases)
Expand Down

0 comments on commit 7c779ad

Please sign in to comment.