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

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
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 _GetHeuristicSuspectedCLs(analysis):
186 """Gets revisions of suspected cls found by heuristic approach."""
187 if analysis and analysis.suspected_cls:
188 return [(cl['repo_name'], cl['revision']) for cl in analysis.suspected_cls]
189 return []
190
191
192 def _NotifyCulprits(master_name, builder_name, build_number, culprits,
193 heuristic_cls):
186 """Sends notifications to the identified culprits.""" 194 """Sends notifications to the identified culprits."""
187 try: 195
188 for culprit in (culprits or {}).itervalues(): 196 for culprit in (culprits or {}).itervalues():
189 pipeline = SendNotificationForCulpritPipeline( 197 if ((culprit['repo_name'], culprit['revision']) in heuristic_cls):
lijeffrey 2016/09/02 06:37:34 nit: it looks like there are some unnecessary pare
chanli 2016/09/02 16:57:19 Done.
198 try:
199 pipeline = SendNotificationForCulpritPipeline(
190 master_name, builder_name, build_number, 200 master_name, builder_name, build_number,
191 culprit['repo_name'], culprit['revision']) 201 culprit['repo_name'], culprit['revision'])
192 pipeline.start() 202 pipeline.start()
193 except Exception: # pragma: no cover. 203 except Exception: # pragma: no cover.
194 logging.exception('Failed to notify culprits.') 204 logging.exception(
205 'Failed to notify culprits which was found by both approaches.')
195 206
196 207
197 class IdentifyTryJobCulpritPipeline(BasePipeline): 208 class IdentifyTryJobCulpritPipeline(BasePipeline):
198 """A pipeline to identify culprit CL info based on try job compile results.""" 209 """A pipeline to identify culprit CL info based on try job compile results."""
199 210
200 def _GetCulpritInfo(self, failed_revisions): 211 def _GetCulpritInfo(self, failed_revisions):
201 """Gets commit_positions and review urls for revisions.""" 212 """Gets commit_positions and review urls for revisions."""
202 culprits = {} 213 culprits = {}
203 # TODO(lijeffrey): remove hard-coded 'chromium' when DEPS file parsing is 214 # TODO(lijeffrey): remove hard-coded 'chromium' when DEPS file parsing is
204 # supported. 215 # supported.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 try_job_result.status = analysis_status.COMPLETED 328 try_job_result.status = analysis_status.COMPLETED
318 try_job_result.put() 329 try_job_result.put()
319 330
320 @ndb.transactional 331 @ndb.transactional
321 def UpdateWfAnalysisWithTryJobResult(): 332 def UpdateWfAnalysisWithTryJobResult():
322 if not culprits: 333 if not culprits:
323 return 334 return
324 335
325 # Update analysis result and suspected CLs with results of this try job if 336 # Update analysis result and suspected CLs with results of this try job if
326 # culprits were found. 337 # culprits were found.
327 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
328 updated_result_status = _GetResultAnalysisStatus(analysis, result) 338 updated_result_status = _GetResultAnalysisStatus(analysis, result)
329 updated_suspected_cls = _GetSuspectedCLs(analysis, result) 339 updated_suspected_cls = _GetSuspectedCLs(analysis, result)
330 340
331 if (analysis.result_status != updated_result_status or 341 if (analysis.result_status != updated_result_status or
332 analysis.suspected_cls != updated_suspected_cls): 342 analysis.suspected_cls != updated_suspected_cls):
333 analysis.result_status = updated_result_status 343 analysis.result_status = updated_result_status
334 analysis.suspected_cls = updated_suspected_cls 344 analysis.suspected_cls = updated_suspected_cls
335 analysis.put() 345 analysis.put()
336 346
337 # Store try-job results. 347 # Store try-job results.
338 UpdateTryJobResult() 348 UpdateTryJobResult()
349
350
351 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
352 heuristic_cls = _GetHeuristicSuspectedCLs(analysis)
353
339 # Add try-job results to WfAnalysis. 354 # Add try-job results to WfAnalysis.
340 UpdateWfAnalysisWithTryJobResult() 355 UpdateWfAnalysisWithTryJobResult()
341 356
342 _NotifyCulprits(master_name, builder_name, build_number, culprits) 357 _NotifyCulprits(master_name, builder_name, build_number, culprits,
358 heuristic_cls)
343 return result.get('culprit') if result else None 359 return result.get('culprit') if result else None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698