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

Side by Side Diff: scripts/slave/recipe_modules/perf_try/build_state.py

Issue 2061893003: Build delegation for perf tryjobs (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Fix errors found by robertocn Created 4 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
OLDNEW
(Empty)
1 """
2 Most code in this class are copied or adapted from revision_state in
3 auto_bisect module. Future refactoring is needed.
4 """
5
6 import json
7
8 class BuildState(object):
9
10 SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION = range(5)
11
12 def __init__(self, api, commit_hash):
13 self.api = api
14 self.commit_hash = str(commit_hash)
15 self.build_file_path = self._get_build_file_path(commit_hash)
16 self.build_archived = False
17 self.build_number = None
18
19 def _get_build_file_path(self, commit_hash):
20 revision_suffix = '%s.zip' % commit_hash
21 return self._get_platform_gs_prefix() + revision_suffix
22
23 #Duplicate code from auto_bisect.revision_state._get_platform_gs_prefix
24 def _get_platform_gs_prefix(self):
prasadv 2016/06/15 17:55:14 I don't think we should store these perf tryjob bu
Ziqi Xiong 2016/06/21 22:21:26 Done.
25 bot_name = self.api.m.properties.get('buildername', '')
26 if 'win' in bot_name:
27 if any(b in bot_name for b in ['x64', 'gpu']):
28 return 'gs://chrome-perf/Win x64 Builder/full-build-win32_'
29 return 'gs://chrome-perf/Win Builder/full-build-win32_'
30 if 'android' in bot_name:
31 if 'nexus9' in bot_name:
32 return 'gs://chrome-perf/android_perf_rel_arm64/full-build-linux_'
33 return 'gs://chrome-perf/android_perf_rel/full-build-linux_'
34 if 'mac' in bot_name:
35 return 'gs://chrome-perf/Mac Builder/full-build-mac_'
36 return 'gs://chrome-perf/Linux Builder/full-build-linux'
37
38 #Duplicate code from auto_bisect.revision_state.api
39 def _gsutil_file_exists(self, path):
40 """Returns True if a file exists at the given GS path."""
41 api = self.api
42 try:
43 api.m.gsutil(['ls', path])
44 except api.m.step.StepFailure: # pragma: no cover
45 return False
46 return True
47
48 #Duplicate code from auto_bisect.revision_state.is_build_archived
49 def is_build_archived(self):
50 """Checks if the revision is already built and archived."""
51 if not self.build_archived:
52 api = self.api
53 self.build_archived = self._gsutil_file_exists(self.build_file_path)
54 return self.build_archived
55
56
57 #Duplicate code from auto_bisect.revision_state._fetch_build_info
58 def _fetch_build_info(self, base_url, build_number):
59 api = self.api
60 build_url = '%s/builds/%s?as_text=1' % (base_url, build_number)
61 fetch_result = api.m.url.fetch( build_url, step_name='fetch build details')
62 return json.loads(fetch_result or '{}')
63
64 #Duplicate code from auto_bisect.revision_state.is_build_failed
65 def is_build_failed(self):
prasadv 2016/06/15 17:55:14 I think we should use buildbucket apis to determin
Ziqi Xiong 2016/06/17 18:41:31 Done.
prasadv 2016/06/20 18:31:47 Can you please check the feasibility of using buil
Ziqi Xiong 2016/06/21 22:21:26 Done.
66 api = self.api
67 current_build = None
68 path = 'json/builders/' + api.get_builder_bot_for_this_platform()
69 base_url = api.m.properties.get('buildbotURL', 'http://localhost:8041/')
70 base_url += path
71 if self.build_number is None:
72 try:
73 # Get all the current builds.
74 builder_state_url = base_url + '?as_text=1'
75 builder_state = api.m.url.fetch(
76 builder_state_url, step_name='fetch builder state')
77 builder_state = json.loads(builder_state or '{}')
78 for build_number in builder_state.get('cachedBuilds', []):
79 build = self._fetch_build_info(base_url, build_number)
80 # Properties is a list of triples (key, value, source)
81 build_properties = dict([t[:2] for t in build.get('properties', [])])
82 if build_properties.get('build_archive_url') == self.build_url:
83 self.build_number = build_number
84 current_build = build
85 break
86 except (api.m.step.StepFailure, ValueError): # pragma: no cover
87 # If we cannot get json from buildbot, we cannot determine if a build is
88 # failed, hence we consider it in progress until it times out.
89 return False
90 if self.build_number is None:
91 # The build hasn't started yet, therefore it's not failed.
92 return False
93 if not current_build:
94 current_build = self._fetch_build_info(base_url, self.build_number)
95 return current_build.get('results') in [FAILURE, SKIPPED, EXCEPTION]
OLDNEW
« scripts/slave/recipe_modules/perf_try/api.py ('K') | « scripts/slave/recipe_modules/perf_try/api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698