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

Commit

Permalink
Adding PGO as a returning build_type in get_buildername_metadata() (#469
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Kalpesh Krishna authored and armenzg committed May 5, 2016
1 parent 25800da commit 593c629
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 43 deletions.
39 changes: 23 additions & 16 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,31 @@ def get_buildername_metadata(buildername):
platform_name = props['platform']
suite_name = None

if platform_name.endswith('-debug'):
# e.g. win32-debug
platform_name = platform_name[:-len('-debug')]
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'
ending = platform_name.split('-')[-1]
if ending in ('debug', 'opt', 'pgo'):
build_type = ending
platform_name = platform_name[:-len(ending) - 1]
elif 'debug' in buildername:
build_type = 'debug'
elif 'opt' in buildername:
build_type = 'opt'
elif 'pgo' in buildername:
build_type = 'pgo'
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 +321,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
60 changes: 33 additions & 27 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 @@ -361,20 +362,40 @@ 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 try debug test mochitest-1", "debug"),
("Platform1 try talos tp5o", "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", 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_job_type(test_job)
assert obtained == expected, \
'obtained: "%s", expected "%s"' % (obtained, expected)


def test_include_builders_matching():
Expand All @@ -385,18 +406,3 @@ def test_include_builders_matching():
expected = ["Ubuntu HW 12.04 mozilla-aurora talos svgr"]
assert obtained == expected, \
'obtained: "%s", expected "%s"' % (obtained, expected)


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")]


@pytest.mark.parametrize("test_job, expected", get_job_type_test_cases)
def test_get_job_type(test_job, expected):
"""Test that _get_job_type correctly classifies jobs."""
obtained = _get_job_type(test_job)
assert obtained == expected, \
'obtained: "%s", expected "%s"' % (obtained, expected)

0 comments on commit 593c629

Please sign in to comment.