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

Side by Side Diff: tools/post_perf_builder_job.py

Issue 295133002: Check build status by parsing tryserver buildbot JSON. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Post a try job request via HTTP to the Tryserver to produce build.""" 5 """Post a try job request via HTTP to the Tryserver to produce build."""
6 6
7 import getpass 7 import getpass
8 import json 8 import json
9 import optparse 9 import optparse
10 import os 10 import os
11 import sys 11 import sys
12 import urllib 12 import urllib
13 import urllib2 13 import urllib2
14 14
15 # Link to get JSON data of builds 15 # Link to get JSON data of builds
16 BUILDER_JSON_URL = ('%(server_url)s/json/builders/%(bot_name)s/builds/' 16 BUILDER_JSON_URL = ('%(server_url)s/json/builders/%(bot_name)s/builds/'
17 '%(build_num)s?as_text=1&filter=0') 17 '%(build_num)s?as_text=1&filter=0')
18 18
19 # Link to display build steps 19 # Link to display build steps
20 BUILDER_HTML_URL = ('%(server_url)s/builders/%(bot_name)s/builds/%(build_num)s') 20 BUILDER_HTML_URL = ('%(server_url)s/builders/%(bot_name)s/builds/%(build_num)s')
21 21
22 # Tryserver buildbots status page 22 # Tryserver buildbots status page
23 TRY_SERVER_URL = 'http://build.chromium.org/p/tryserver.chromium' 23 TRY_SERVER_URL = 'http://build.chromium.org/p/tryserver.chromium'
24 24
25 # Hostname of the tryserver where perf bisect builders are hosted. This is used 25 # Hostname of the tryserver where perf bisect builders are hosted. This is used
26 # for posting build request to tryserver. 26 # for posting build request to tryserver.
27 BISECT_BUILDER_HOST = 'master4.golo.chromium.org' 27 BISECT_BUILDER_HOST = 'master4.golo.chromium.org'
28 # 'try_job_port' on tryserver to post build request. 28 # 'try_job_port' on tryserver to post build request.
29 BISECT_BUILDER_PORT = '8328' 29 BISECT_BUILDER_PORT = 8328
30 30
31 31
32 # From buildbot.status.builder. 32 # From buildbot.status.builder.
33 # See: http://docs.buildbot.net/current/developer/results.html 33 # See: http://docs.buildbot.net/current/developer/results.html
34 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, TRYPENDING = range(7) 34 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, TRYPENDING = range(7)
35 35
36 # Status codes that can be returned by the GetBuildStatus method. 36 # Status codes that can be returned by the GetBuildStatus method.
37 OK = (SUCCESS, WARNINGS) 37 OK = (SUCCESS, WARNINGS)
38 # Indicates build failure. 38 # Indicates build failure.
39 FAILED = (FAILURE, EXCEPTION, SKIPPED) 39 FAILED = (FAILURE, EXCEPTION, SKIPPED)
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 Args: 227 Args:
228 build_num: A build number on tryserver to determine its status. 228 build_num: A build number on tryserver to determine its status.
229 bot_name: Name of the bot where the build information is scanned. 229 bot_name: Name of the bot where the build information is scanned.
230 builder_host: Hostname of the server where the builder is hosted. 230 builder_host: Hostname of the server where the builder is hosted.
231 builder_port: Port number of ther server where the builder is hosted. 231 builder_port: Port number of ther server where the builder is hosted.
232 232
233 Returns: 233 Returns:
234 A tuple consists of build status (SUCCESS, FAILED or PENDING) and a link 234 A tuple consists of build status (SUCCESS, FAILED or PENDING) and a link
235 to build status page on the waterfall. 235 to build status page on the waterfall.
236 """ 236 """
237 # Gets the buildbot url for the given host and port.
238 server_url = _GetBuildBotUrl(builder_host, builder_port)
239 buildbot_url = BUILDER_JSON_URL % {'server_url': server_url,
240 'bot_name': bot_name,
241 'build_num': build_num
242 }
243 build_data = _GetBuildData(buildbot_url)
244 results_url = None 237 results_url = None
245 if build_data: 238 if build_num:
246 # Link to build on the buildbot showing status of build steps. 239 # Gets the buildbot url for the given host and port.
247 results_url = BUILDER_HTML_URL % {'server_url': server_url, 240 server_url = _GetBuildBotUrl(builder_host, builder_port)
248 'bot_name': bot_name, 241 buildbot_url = BUILDER_JSON_URL % {'server_url': server_url,
249 'build_num': build_num 242 'bot_name': bot_name,
250 } 243 'build_num': build_num
251 if _IsBuildFailed(build_data): 244 }
252 return (FAILED, results_url) 245 build_data = _GetBuildData(buildbot_url)
246 if build_data:
247 # Link to build on the buildbot showing status of build steps.
248 results_url = BUILDER_HTML_URL % {'server_url': server_url,
249 'bot_name': bot_name,
250 'build_num': build_num
251 }
252 if _IsBuildFailed(build_data):
253 return (FAILED, results_url)
253 254
254 elif _IsBuildSuccessful(build_data): 255 elif _IsBuildSuccessful(build_data):
255 return (OK, results_url) 256 return (OK, results_url)
256 return (PENDING, results_url) 257 return (PENDING, results_url)
257 258
258 259
259 def GetBuildNumFromBuilder(build_reason, bot_name, builder_host, builder_port): 260 def GetBuildNumFromBuilder(build_reason, bot_name, builder_host, builder_port):
260 """Gets build number on build status page for a given build reason. 261 """Gets build number on build status page for a given build reason.
261 262
262 It parses the JSON data from buildbot page and collect basic information 263 It parses the JSON data from buildbot page and collect basic information
263 about the all the builds and then this uniquely identifies the build based 264 about the all the builds and then this uniquely identifies the build based
264 on the 'reason' attribute in builds's JSON data. 265 on the 'reason' attribute in builds's JSON data.
265 The 'reason' attribute set while a build request is posted, and same is used 266 The 'reason' attribute set while a build request is posted, and same is used
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if not options.port: 363 if not options.port:
363 raise ServerAccessError('Please use the --port option to specify the try ' 364 raise ServerAccessError('Please use the --port option to specify the try '
364 'server port to connect to.') 365 'server port to connect to.')
365 params = _GetQueryParams(options) 366 params = _GetQueryParams(options)
366 PostTryJob(params) 367 PostTryJob(params)
367 368
368 369
369 if __name__ == '__main__': 370 if __name__ == '__main__':
370 sys.exit(Main(sys.argv)) 371 sys.exit(Main(sys.argv))
371 372
OLDNEW
« no previous file with comments | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698