Commit bd0f0208 authored by qyearsley's avatar qyearsley Committed by Commit bot

Use builder_type when requesting/fetching builds, and add support for full linux builds.

Changes in this CL:
 - In request_build.py, add a URL for linux try bot.
 - Add sample config for functional bisect.
 - Make perf-related config parameters optional.
 - Use builder type when starting build try jobs, and when fetching builds.

A few other changes:
 - Update bisect_perf_regression.py file docstring.
 - Rename _BuilderTryjob to _StartBuilderTryJob and refactor.
 - Remove unused code in request_build.py.

Proposed follow-up:
 - Move functions related to builder to be methods of one class, so that the builder-specific info/logic (e.g. builder bot and archive location) is in one place.

BUG=

Review URL: https://codereview.chromium.org/806943007

Cr-Commit-Position: refs/heads/master@{#313415}
parent db0e8ddf
This diff is collapsed.
......@@ -13,6 +13,7 @@ sys.path.append(os.path.join(SRC, 'third_party', 'pymock'))
import bisect_perf_regression
import bisect_utils
import fetch_build
import mock
import source_control
......@@ -584,7 +585,7 @@ class GitTryJobTestCases(unittest.TestCase):
bisect_perf_regression._PrepareBisectBranch,
parent_branch, new_branch)
def testBuilderTryJobForException(self):
def testStartBuilderTryJobForException(self):
git_revision = 'ac4a9f31fe2610bd146857bbd55d7a260003a888'
bot_name = 'linux_perf_bisect_builder'
bisect_job_name = 'testBisectJobname'
......@@ -602,16 +603,17 @@ class GitTryJobTestCases(unittest.TestCase):
(['branch', '--set-upstream-to', parent_branch],
('Setuptream fails', 0)),
(['try',
'-b', bot_name,
'-r', git_revision,
'-n', bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.SVN_REPO_URL,
'--bot=%s' % bot_name,
'--revision=%s' % git_revision,
'--name=%s' % bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.PERF_SVN_REPO_URL,
'--diff=%s' % patch_content
], (None, 1)),
]
self._AssertRunGitExceptions(try_cmd,
bisect_perf_regression._BuilderTryjob,
git_revision, bot_name, bisect_job_name, patch)
self._AssertRunGitExceptions(
try_cmd, bisect_perf_regression._StartBuilderTryJob,
fetch_build.PERF_BUILDER, git_revision, bot_name, bisect_job_name,
patch)
def testBuilderTryJob(self):
git_revision = 'ac4a9f31fe2610bd146857bbd55d7a260003a888'
......@@ -631,16 +633,17 @@ class GitTryJobTestCases(unittest.TestCase):
(['branch', '--set-upstream-to', parent_branch],
('Setuptream fails', 0)),
(['try',
'-b', bot_name,
'-r', git_revision,
'-n', bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.SVN_REPO_URL,
'--bot=%s' % bot_name,
'--revision=%s' % git_revision,
'--name=%s' % bisect_job_name,
'--svn_repo=%s' % bisect_perf_regression.PERF_SVN_REPO_URL,
'--diff=%s' % patch_content
], (None, 0)),
]
self._SetupRunGitMock(try_cmd)
bisect_perf_regression._BuilderTryjob(
git_revision, bot_name, bisect_job_name, patch)
bisect_perf_regression._StartBuilderTryJob(
fetch_build.PERF_BUILDER, git_revision, bot_name, bisect_job_name,
patch)
if __name__ == '__main__':
......
# This should reproduce the regression in http://crbug.com/425582.
# It was based on:
# http://build.chromium.org/p/tryserver.chromium.perf/builders/linux_perf_bisect/builds/704
config = {
'command': 'out/Release/content_unittests --single-process-tests --gtest_filter=DOMStorageAreaTest',
'good_revision': '311607',
'bad_revision': '311608',
'bisect_mode': 'return_code',
'builder_type': 'full',
}
# Workaround git try issue, see crbug.com/257689
......@@ -51,6 +51,8 @@ def GetBucketAndRemotePath(revision, builder_type=PERF_BUILDER,
Returns:
A pair of strings (bucket, path), where the archive is expected to be.
"""
logging.info('Creating BuildArchive, type "%s", arch "%s", platform "%s".',
builder_type, target_arch, target_platform)
build_archive = BuildArchive.Create(
builder_type, target_arch=target_arch, target_platform=target_platform,
extra_src=extra_src)
......@@ -70,7 +72,9 @@ class BuildArchive(object):
@staticmethod
def Create(builder_type, target_arch='ia32', target_platform='chromium',
extra_src=None):
extra_src=None):
logging.info('Creating BuildArchive, type "%s", arch "%s", platform "%s".',
builder_type, target_arch, target_platform)
if builder_type == PERF_BUILDER:
return PerfBuildArchive(target_arch, target_platform)
if builder_type == FULL_BUILDER:
......@@ -414,4 +418,3 @@ def Main(argv):
if __name__ == '__main__':
sys.exit(Main(sys.argv))
......@@ -26,23 +26,16 @@ BUILDER_JSON_URL = ('%(server_url)s/json/builders/%(bot_name)s/builds/'
'%(build_num)s?as_text=1&filter=0')
# URL template for displaying build steps.
BUILDER_HTML_URL = ('%(server_url)s/builders/%(bot_name)s/builds/%(build_num)s')
BUILDER_HTML_URL = '%(server_url)s/builders/%(bot_name)s/builds/%(build_num)s'
# Try server status page for the perf try server.
# Try server status page URLs, used to get build status.
PERF_TRY_SERVER_URL = 'http://build.chromium.org/p/tryserver.chromium.perf'
LINUX_TRY_SERVER_URL = 'http://build.chromium.org/p/tryserver.chromium.linux'
# Hostname of the tryserver where perf bisect builders are hosted.
# This is used for posting build requests to the tryserver.
PERF_BISECT_BUILDER_HOST = 'master4.golo.chromium.org'
# The default 'try_job_port' on tryserver to post build request.
PERF_BISECT_BUILDER_PORT = 8341
# Status codes that can be returned by the GetBuildStatus method.
# Status codes that can be returned by the GetBuildStatus method
# From buildbot.status.builder.
# See: http://docs.buildbot.net/current/developer/results.html
SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, TRYPENDING = range(7)
OK = (SUCCESS, WARNINGS) # These indicate build is complete.
FAILED = (FAILURE, EXCEPTION, SKIPPED) # These indicate build failure.
PENDING = (RETRY, TRYPENDING) # These indicate in progress or in pending queue.
......@@ -54,51 +47,6 @@ class ServerAccessError(Exception):
return '%s\nSorry, cannot connect to server.' % self.args[0]
def PostTryJob(host, port, params):
"""Sends a build request to the server using the HTTP protocol.
The required parameters are:
'revision': "src@rev", where rev is a git hash or SVN revision.
'bot': Name of builder bot to use, e.g. "win_perf_bisect_builder".
Args:
host: Hostname of the try server.
port: Port of the try server.
params: A dictionary of parameters to be sent in the POST request.
Returns:
True if the request is posted successfully.
Raises:
ServerAccessError: Failed to make a request to the try server.
ValueError: Not all of the expected inputs were given.
"""
if not params.get('revision'):
raise ValueError('Missing revision number.')
if not params.get('bot'):
raise ValueError('Missing bot name.')
base_url = 'http://%s:%s/send_try_patch' % (host, port)
print 'Posting build request by HTTP.'
print 'URL: %s, params: %s' % (base_url, params)
connection = None
try:
print 'Opening connection...'
connection = urllib2.urlopen(base_url, urllib.urlencode(params))
print 'Done, request sent to server to produce build.'
except IOError as e:
raise ServerAccessError('%s is unaccessible. Reason: %s' % (base_url, e))
if not connection:
raise ServerAccessError('%s is unaccessible.' % base_url)
response = connection.read()
print 'Received response from server: %s' % response
if response != 'OK':
raise ServerAccessError('Response was not "OK".')
return True
def _IsBuildRunning(build_data):
"""Checks whether the build is in progress on buildbot.
......@@ -218,8 +166,9 @@ def _GetBuildBotUrl(builder_type):
"""
if builder_type == fetch_build.PERF_BUILDER:
return PERF_TRY_SERVER_URL
else:
raise NotImplementedError('Cannot yet get non-perf builds.')
if builder_type == fetch_build.FULL_BUILDER:
return LINUX_TRY_SERVER_URL
raise NotImplementedError('Unsupported builder type "%s".' % builder_type)
def GetBuildStatus(build_num, bot_name, builder_type):
......@@ -234,6 +183,8 @@ def GetBuildStatus(build_num, bot_name, builder_type):
A pair which consists of build status (SUCCESS, FAILED or PENDING) and a
link to build status page on the waterfall.
"""
# TODO(prasadv, qyearsley): Make this a method of BuildArchive
# (which may be renamed to BuilderTryBot or Builder).
results_url = None
if build_num:
# Get the URL for requesting JSON data with status information.
......@@ -277,6 +228,8 @@ def GetBuildNumFromBuilder(build_reason, bot_name, builder_type):
Returns:
A build number as a string if found, otherwise None.
"""
# TODO(prasadv, qyearsley): Make this a method of BuildArchive
# (which may be renamed to BuilderTryBot or Builder).
# Gets the buildbot url for the given host and port.
server_url = _GetBuildBotUrl(builder_type)
buildbot_url = BUILDER_JSON_URL % {
......@@ -291,77 +244,3 @@ def GetBuildNumFromBuilder(build_reason, bot_name, builder_type):
if builds_data[current_build].get('reason') == build_reason:
return builds_data[current_build].get('number')
return None
def _GetRequestParams(options):
"""Extracts request parameters which will be passed to PostTryJob.
Args:
options: The options object parsed from the command line.
Returns:
A dictionary with parameters to pass to PostTryJob.
"""
params = {
'user': options.user,
'name': options.name,
}
# Add other parameters if they're available in the options object.
for key in ['email', 'revision', 'root', 'bot', 'patch']:
option = getattr(options, key)
if option:
params[key] = option
return params
def _GenParser():
"""Returns a parser for getting command line arguments."""
usage = ('%prog [options]\n'
'Post a build request to the try server for the given revision.')
parser = optparse.OptionParser(usage=usage)
parser.add_option('-H', '--host',
help='Host address of the try server (required).')
parser.add_option('-P', '--port', type='int',
help='HTTP port of the try server (required).')
parser.add_option('-u', '--user', default=getpass.getuser(),
dest='user',
help='Owner user name [default: %default]')
parser.add_option('-e', '--email',
default=os.environ.get('TRYBOT_RESULTS_EMAIL_ADDRESS',
os.environ.get('EMAIL_ADDRESS')),
help=('Email address where to send the results. Use either '
'the TRYBOT_RESULTS_EMAIL_ADDRESS environment '
'variable or EMAIL_ADDRESS to set the email address '
'the try bots report results to [default: %default]'))
parser.add_option('-n', '--name',
default='try_job_http',
help='Descriptive name of the try job')
parser.add_option('-b', '--bot',
help=('Only one builder per run may be specified; to post '
'jobs on on multiple builders, run script for each '
'builder separately.'))
parser.add_option('-r', '--revision',
help=('Revision to use for the try job. The revision may '
'be determined by the try server; see its waterfall '
'for more info.'))
parser.add_option('--root',
help=('Root to use for the patch; base subdirectory for '
'patch created in a subdirectory.'))
parser.add_option('--patch',
help='Patch information.')
return parser
def Main(_):
"""Posts a try job based on command line parameters."""
parser = _GenParser()
options, _ = parser.parse_args()
if not options.host or not options.port:
parser.print_help()
return 1
params = _GetRequestParams(options)
PostTryJob(options.host, options.port, params)
if __name__ == '__main__':
sys.exit(Main(sys.argv))
......@@ -148,13 +148,7 @@ def _ValidatePerfConfigFile(config_contents):
Returns:
True if valid.
"""
required_parameters = [
'command',
'repeat_count',
'truncate_percent',
'max_time_minutes',
]
return _ValidateConfigFile(config_contents, required_parameters)
return _ValidateConfigFile(config_contents, required_parameters=['command'])
def _ValidateBisectConfigFile(config_contents):
......@@ -169,16 +163,9 @@ def _ValidateBisectConfigFile(config_contents):
Returns:
True if valid.
"""
required_params = [
'command',
'good_revision',
'bad_revision',
'metric',
'repeat_count',
'truncate_percent',
'max_time_minutes',
]
return _ValidateConfigFile(config_contents, required_params)
return _ValidateConfigFile(
config_contents,
required_parameters=['command', 'good_revision', 'bad_revision'])
def _OutputFailedResults(text_to_print):
......@@ -498,13 +485,13 @@ def _RunBisectionScript(
'--command', config['command'],
'--good_revision', config['good_revision'],
'--bad_revision', config['bad_revision'],
'--metric', config['metric'],
'--working_directory', working_directory,
'--output_buildbot_annotations'
]
# Add flags for any optional config parameters if given in the config.
options = [
('metric', '--metric'),
('repeat_count', '--repeat_test_count'),
('truncate_percent', '--truncate_percent'),
('max_time_minutes', '--max_time_minutes'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment