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

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

Issue 2302223002: [Findit] Change the criteria of sending notification to code review. (Closed)
Patch Set: . Created 4 years, 3 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
« no previous file with comments | « no previous file | appengine/findit/waterfall/send_notification_for_culprit_pipeline.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 collections import defaultdict 5 from collections import defaultdict
6 import logging 6 import logging
7 7
8 from google.appengine.ext import ndb 8 from google.appengine.ext import ndb
9 9
10 from common.git_repository import GitRepository 10 from common.git_repository import GitRepository
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 for failed_test in test_result['failures']: 175 for failed_test in test_result['failures']:
176 # Swarming tests, gets first failed revision for each test. 176 # Swarming tests, gets first failed revision for each test.
177 if failed_test not in culprit_map[step]['tests']: 177 if failed_test not in culprit_map[step]['tests']:
178 culprit_map[step]['tests'][failed_test] = { 178 culprit_map[step]['tests'][failed_test] = {
179 'revision': revision 179 'revision': revision
180 } 180 }
181 181
182 return culprit_map, list(failed_revisions) 182 return culprit_map, list(failed_revisions)
183 183
184 184
185 def _NotifyCulprits(master_name, builder_name, build_number, culprits): 185 def _GetSuspectedCLFoundByHeuristicForCompile(analysis):
186 """For compile failure, gets the suspected revision found by heuristic."""
187 if not analysis or not analysis.result:
188 return None
189
190 for failure in analysis.result.get('failures', []):
191 if (failure['step_name'].lower() == 'compile' and
192 len(failure['suspected_cls']) == 1):
193 # Based on confidence calculation, suspected_cl found by heuristic for
194 # compile is very likely to be the culprit.
195 # Since the current confidence calculation is for results with single
196 # suspected_cl, we might need to have the same regulation here.
197 return failure['suspected_cls'][0]
198 return None
199
200
201 def _GetHeuristicSuspectedCLs(analysis):
202 """Gets revisions of suspected cls found by heuristic approach."""
203 if analysis and analysis.suspected_cls:
204 return [(cl['repo_name'], cl['revision']) for cl in analysis.suspected_cls]
205 return []
206
207
208 def _StartSendNotificationPipeline(
209 master_name, builder_name, build_number, repo_name, revision,
210 send_notification_right_now):
211 try:
212 pipeline = SendNotificationForCulpritPipeline(
213 master_name, builder_name, build_number, repo_name, revision,
214 send_notification_right_now)
215 pipeline.start()
216 except Exception: # pragma: no cover.
217 logging.exception('Failed to notify culprit.')
218
219
220 def _NotifyCulprits(master_name, builder_name, build_number, culprits,
221 heuristic_cls, compile_suspected_cl):
186 """Sends notifications to the identified culprits.""" 222 """Sends notifications to the identified culprits."""
187 try: 223
188 for culprit in (culprits or {}).itervalues(): 224 if culprits:
189 pipeline = SendNotificationForCulpritPipeline( 225 # There is a try job result, so check if any of the culprits
226 # was also found by heuristic analysis.
227 for culprit in culprits.itervalues():
228 send_notification_right_now = False
229 send_notification_right_now = (
230 culprit['repo_name'], culprit['revision']) in heuristic_cls
231 _StartSendNotificationPipeline(
190 master_name, builder_name, build_number, 232 master_name, builder_name, build_number,
191 culprit['repo_name'], culprit['revision']) 233 culprit['repo_name'], culprit['revision'],
192 pipeline.start() 234 send_notification_right_now)
193 except Exception: # pragma: no cover. 235 elif compile_suspected_cl:
194 logging.exception('Failed to notify culprits.') 236 # A special case where try job didn't find any suspected cls, but
237 # heuristic found a suspected_cl.
238 _StartSendNotificationPipeline(
239 master_name, builder_name, build_number,
240 compile_suspected_cl['repo_name'], compile_suspected_cl['revision'],
241 send_notification_right_now=True)
195 242
196 243
197 class IdentifyTryJobCulpritPipeline(BasePipeline): 244 class IdentifyTryJobCulpritPipeline(BasePipeline):
198 """A pipeline to identify culprit CL info based on try job compile results.""" 245 """A pipeline to identify culprit CL info based on try job compile results."""
199 246
200 def _GetCulpritInfo(self, failed_revisions): 247 def _GetCulpritInfo(self, failed_revisions):
201 """Gets commit_positions and review urls for revisions.""" 248 """Gets commit_positions and review urls for revisions."""
202 culprits = {} 249 culprits = {}
203 # TODO(lijeffrey): remove hard-coded 'chromium' when DEPS file parsing is 250 # TODO(lijeffrey): remove hard-coded 'chromium' when DEPS file parsing is
204 # supported. 251 # supported.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 else: # pragma: no cover 362 else: # pragma: no cover
316 result_to_update.append(result) 363 result_to_update.append(result)
317 try_job_result.status = analysis_status.COMPLETED 364 try_job_result.status = analysis_status.COMPLETED
318 try_job_result.put() 365 try_job_result.put()
319 366
320 @ndb.transactional 367 @ndb.transactional
321 def UpdateWfAnalysisWithTryJobResult(): 368 def UpdateWfAnalysisWithTryJobResult():
322 if not culprits: 369 if not culprits:
323 return 370 return
324 371
372 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
325 # Update analysis result and suspected CLs with results of this try job if 373 # Update analysis result and suspected CLs with results of this try job if
326 # culprits were found. 374 # culprits were found.
327 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
328 updated_result_status = _GetResultAnalysisStatus(analysis, result) 375 updated_result_status = _GetResultAnalysisStatus(analysis, result)
329 updated_suspected_cls = _GetSuspectedCLs(analysis, result) 376 updated_suspected_cls = _GetSuspectedCLs(analysis, result)
330 377
331 if (analysis.result_status != updated_result_status or 378 if (analysis.result_status != updated_result_status or
332 analysis.suspected_cls != updated_suspected_cls): 379 analysis.suspected_cls != updated_suspected_cls):
333 analysis.result_status = updated_result_status 380 analysis.result_status = updated_result_status
334 analysis.suspected_cls = updated_suspected_cls 381 analysis.suspected_cls = updated_suspected_cls
335 analysis.put() 382 analysis.put()
336 383
337 # Store try-job results. 384 # Store try-job results.
338 UpdateTryJobResult() 385 UpdateTryJobResult()
386
387 # Saves cls found by heuristic approach for later use.
388 # This part must be before UpdateWfAnalysisWithTryJobResult().
389 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
390 heuristic_cls = _GetHeuristicSuspectedCLs(analysis)
391 compile_suspected_cl = (
392 _GetSuspectedCLFoundByHeuristicForCompile(analysis)
393 if try_job_type == failure_type.COMPILE else None)
394
339 # Add try-job results to WfAnalysis. 395 # Add try-job results to WfAnalysis.
340 UpdateWfAnalysisWithTryJobResult() 396 UpdateWfAnalysisWithTryJobResult()
341 397
342 _NotifyCulprits(master_name, builder_name, build_number, culprits) 398 _NotifyCulprits(master_name, builder_name, build_number, culprits,
343 return result.get('culprit') if result else None 399 heuristic_cls, compile_suspected_cl)
400 return result.get('culprit') if result else None
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/waterfall/send_notification_for_culprit_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698