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

Side by Side Diff: appengine/findit/waterfall/buildbot.py

Issue 1149743002: [Findit] Use step level analysis to exclude flaky test failures. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 7 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
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 from datetime import datetime 5 from datetime import datetime
6 import json 6 import json
7 import re 7 import re
8 import urllib 8 import urllib
9 import gzip
stgao 2015/05/21 00:29:56 not in order.
10
11 import cloudstorage as gcs
9 12
10 from waterfall.build_info import BuildInfo 13 from waterfall.build_info import BuildInfo
11 14
12 _MASTER_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)' 15 _MASTER_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)'
13 '(/.*)?$') 16 '(/.*)?$')
14 17
15 _BUILD_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/' 18 _BUILD_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/'
16 'builders/([^/]+)/builds/([\d]+)(/.*)?$') 19 'builders/([^/]+)/builds/([\d]+)(/.*)?$')
17 20
18 _STEP_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/' 21 _STEP_URL_PATTERN = re.compile(r'^https?://build\.chromium\.org/p/([^/]+)/'
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 94
92 def CreateStdioLogUrl(master_name, builder_name, build_number, step_name): 95 def CreateStdioLogUrl(master_name, builder_name, build_number, step_name):
93 builder_name = urllib.quote(builder_name) 96 builder_name = urllib.quote(builder_name)
94 step_name = urllib.quote(step_name) 97 step_name = urllib.quote(step_name)
95 return ('https://build.chromium.org/p/%s/builders/%s/builds/%s/' 98 return ('https://build.chromium.org/p/%s/builders/%s/builds/%s/'
96 'steps/%s/logs/stdio/text') % ( 99 'steps/%s/logs/stdio/text') % (
97 master_name, builder_name, build_number, step_name) 100 master_name, builder_name, build_number, step_name)
98 101
99 102
100 def GetBuildDataFromBuildMaster(master_name, 103 def CreateStepLogPath(master_name, builder_name, build_number, step_name):
stgao 2015/05/21 00:29:56 "GtestResult" might be more clear than "StepLog".
104 return ('/chrome-gtest-results/buildbot/%s/%s/%s/%s.json.gz') % (
105 master_name, builder_name, build_number, step_name)
106
107
108 def GetBuildDataFromBuildMaster(master_name,
101 builder_name, build_number, http_client): 109 builder_name, build_number, http_client):
102 """Returns the json-format data of the build from buildbot json API.""" 110 """Returns the json-format data of the build from buildbot json API."""
103 status_code, data = http_client.Get( 111 status_code, data = http_client.Get(
104 CreateBuildUrl(master_name, builder_name, build_number, json_api=True)) 112 CreateBuildUrl(master_name, builder_name, build_number, json_api=True))
105 if status_code != 200: 113 if status_code != 200:
106 return None 114 return None
107 else: 115 else:
108 return data 116 return data
109 117
110 118
111 def GetBuildDataFromArchive(master_name, 119 def GetBuildDataFromArchive(master_name,
112 builder_name, build_number, http_client): 120 builder_name, build_number, http_client):
113 """Returns the json-format data of the build from build archive.""" 121 """Returns the json-format data of the build from build archive."""
114 status_code, data = http_client.Get( 122 status_code, data = http_client.Get(
115 CreateArchivedBuildUrl(master_name, builder_name, build_number)) 123 CreateArchivedBuildUrl(master_name, builder_name, build_number))
116 if status_code != 200: 124 if status_code != 200:
117 return None 125 return None
118 else: 126 else:
119 return data 127 return data
120 128
121 129
122 def GetStepStdio(master_name, builder_name, build_number, 130 def GetStepStdio(master_name, builder_name, build_number,
123 step_name, http_client): 131 step_name, http_client):
124 """Returns the raw string of stdio of the specified step.""" 132 """Returns the raw string of stdio of the specified step."""
125 status_code, data = http_client.Get( 133 status_code, data = http_client.Get(
126 CreateStdioLogUrl(master_name, builder_name, build_number, step_name)) 134 CreateStdioLogUrl(master_name, builder_name, build_number, step_name))
127 if status_code != 200: 135 if status_code != 200:
128 return None 136 return None
129 else: 137 else:
130 return data 138 return data
131 139
132 140
141 def GetGsStepLog(master_name,
142 builder_name, build_number, step_name): # pragma: no cover
143 """Returns the archived Step Log file."""
144 try:
145 step_log_file = gcs.open(CreateStepLogPath(
stgao 2015/05/21 00:29:56 Let us use "with" for the two opens here. It is cl
146 master_name, builder_name, build_number, step_name))
147 unzipped_step_log_file = gzip.open(step_log_file )
148 log_file_content = step_log_file.read()
149 unzipped_step_log_file.close()
150 step_log_file.close()
151 return log_file_content
152 except gcs.NotFoundError:
153 return None
154
155
133 def GetStepResult(step_data_json): 156 def GetStepResult(step_data_json):
134 """Returns the result of a step.""" 157 """Returns the result of a step."""
135 result = step_data_json.get('results') 158 result = step_data_json.get('results')
136 if result is None and step_data_json.get('isFinished'): 159 if result is None and step_data_json.get('isFinished'):
137 # Without parameter filter=0 in the http request to the buildbot json api, 160 # Without parameter filter=0 in the http request to the buildbot json api,
138 # the value of the result of a passed step won't be present. 161 # the value of the result of a passed step won't be present.
139 return SUCCESS 162 return SUCCESS
140 163
141 while isinstance(result, list): 164 while isinstance(result, list):
142 result = result[0] 165 result = result[0]
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 # Skip steps that haven't started yet or are still running. 219 # Skip steps that haven't started yet or are still running.
197 continue 220 continue
198 221
199 step_result = GetStepResult(step_data) 222 step_result = GetStepResult(step_data)
200 if step_result in (SUCCESS, WARNINGS): 223 if step_result in (SUCCESS, WARNINGS):
201 build_info.passed_steps.append(step_name) 224 build_info.passed_steps.append(step_name)
202 elif step_result == FAILURE: 225 elif step_result == FAILURE:
203 build_info.failed_steps.append(step_name) 226 build_info.failed_steps.append(step_name)
204 227
205 return build_info 228 return build_info
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698