Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: tools/post_perf_builder_job.py

Issue 184293011: Make bisect script to post build request to try server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/bisect-perf-regression.py ('K') | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/post_perf_builder_job.py
diff --git a/tools/post_perf_builder_job.py b/tools/post_perf_builder_job.py
new file mode 100644
index 0000000000000000000000000000000000000000..0e9083669ac98677e564048b77f5154043ff9bae
--- /dev/null
+++ b/tools/post_perf_builder_job.py
@@ -0,0 +1,128 @@
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Post a try job to the Try server to produce build. It communicates
+to server by directly connecting via HTTP.
qyearsley 2014/03/06 23:40:45 Any try server? I have a general question about o
prasadv 2014/03/07 01:07:44 The main purpose of this module is to post a reque
+"""
+
+import getpass
+import optparse
+import os
+import sys
+import urllib
+import urllib2
+
+
+class ServerAccessError(Exception):
+ def __str__(self):
+ return '%s\nSorry, cannot connect to server.' % self.args[0]
+
+
+def ParseArgs(options):
qyearsley 2014/03/06 23:40:45 This function could be marked as private (_ParseAr
prasadv 2014/03/07 01:07:44 Done.
+ """Parse common options passed to PostTryJob."""
qyearsley 2014/03/06 23:40:45 Style consistency note: In most places (including
prasadv 2014/03/07 01:07:44 Done.
+ values = {'host': options.host,
+ 'port': options.port,
+ 'user': options.user,
+ 'name': options.name
+ }
+ if options.email:
+ values['email'] = options.email
+ if options.revision:
+ values['revision'] = options.revision
+ if options.root:
+ values['root'] = options.root
+ if options.bot:
+ values['bot'] = options.bot
+ if options.patch:
+ values['patch'] = options.patch
+ return values
+
+
+def PostTryJob(url_params):
+ """Send a build request to the server using the HTTP protocol."""
qyearsley 2014/03/06 23:40:45 This docstring could be more detailed: - Which p
prasadv 2014/03/07 01:07:44 Done.
+ # Parse url parameters to be sent to Try server.
+ if not url_params.get('host'):
+ raise ServerAccessError('Hostname of server to connect is missing.')
+ if not url_params.get('port'):
+ raise ServerAccessError('Port of server to connect is missing.')
+ if not url_params.get('revision'):
+ raise ServerAccessError('Missing revision details. Please specify revision'
+ ' information.')
+ if not url_params.get('bot'):
+ raise ServerAccessError('Missing bot details. Please specify bot'
+ ' information.')
+
+ url = 'http://%s:%s/send_try_patch' % (url_params['host'], url_params['port'])
+
+ print 'Sending by HTTP'
+ query_params = '&'.join('%s=%s' % (k, v) for k, v in url_params.iteritems())
+ print 'url: %s?%s' % (url, query_params)
+
+ connection = None
+ try:
+ print 'Opening connection...'
+ connection = urllib2.urlopen(url, urllib.urlencode(url_params))
+ print 'Done, request sent to server to produce build.'
+ except IOError, e:
+ raise ServerAccessError('%s is unaccessible. Reason: %s' % (url, e))
+ if not connection:
+ raise ServerAccessError('%s is unaccessible.' % url)
+ response = connection.read()
+ print 'Received %s from server' % response
+ if response != 'OK':
+ raise ServerAccessError('%s is unaccessible. Got:\n%s' % (url, response))
+ return True
+
+
+def gen_parser():
qyearsley 2014/03/06 23:40:45 Style: Should be GenParser (or _GenParser). Maybe
prasadv 2014/03/07 01:07:44 Done.
+ # Parse argv
qyearsley 2014/03/06 23:40:45 Should have a docstring with a sentence saying wha
prasadv 2014/03/07 01:07:44 Done.
+ usage = ('%prog [options]\n'
+ 'Post a build request to the try server for the given revision.\n')
+ parser = optparse.OptionParser(usage=usage)
+ parser.add_option('-H', '--host',
+ help='Host address')
+ parser.add_option('-P', '--port', type='int',
+ help='HTTP port')
+ 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=('IMPORTANT: specify ONE builder per run is supported.'
+ 'Run script for each builders separately.'))
+ parser.add_option('-r', '--revision',
+ help='Revision to use for the try job; default: the '
+ 'revision will 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
+
qyearsley 2014/03/06 23:40:45 Style: Should have two blank lines here.
prasadv 2014/03/07 01:07:44 Done.
+def Main(argv):
+ parser = gen_parser()
+ options, args = parser.parse_args()
+ if not options.host:
+ raise ServerAccessError('Please use the --host option to specify the try '
+ 'server host to connect to.')
+ if not options.port:
+ raise ServerAccessError('Please use the --port option to specify the try '
+ 'server port to connect to.')
+ params = ParseArgs(options)
+ PostTryJob(params)
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
« tools/bisect-perf-regression.py ('K') | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698