Index: tools/auto_bisect/request_build.py |
diff --git a/tools/auto_bisect/request_build.py b/tools/auto_bisect/request_build.py |
index 55b3768590eb56a512ad6d3fdb26d6251b7bd0a9..70a139c88180873ffe8e8dae6a671b612c7cada6 100644 |
--- a/tools/auto_bisect/request_build.py |
+++ b/tools/auto_bisect/request_build.py |
@@ -26,23 +26,15 @@ 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. |
PERF_TRY_SERVER_URL = 'http://build.chromium.org/p/tryserver.chromium.perf' |
-# 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 +46,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 +165,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 'http://build.chromium.org/p/tryserver.chromium.linux' |
prasadv
2015/01/27 22:54:31
May be using a constant for this will make it cons
|
+ raise NotImplementedError('Unsupported builder type "%s".' % builder_type) |
def GetBuildStatus(build_num, bot_name, builder_type): |
@@ -234,6 +182,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 +227,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 +243,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)) |