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

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

Issue 1870103003: [Findit] Adding Try Job suspected CLs and result status to analysis (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 8 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/test/identify_try_job_culprit_pipeline_test.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 common.git_repository import GitRepository 5 from common.git_repository import GitRepository
6 from common.http_client_appengine import HttpClientAppengine as HttpClient 6 from common.http_client_appengine import HttpClientAppengine as HttpClient
7 from model import wf_analysis_result_status
stgao 2016/04/11 19:50:12 you may want to rebase on the refactoring CL I com
7 from model import wf_analysis_status 8 from model import wf_analysis_status
9 from model.wf_analysis import WfAnalysis
8 from model.wf_try_job import WfTryJob 10 from model.wf_try_job import WfTryJob
9 from model.wf_try_job_data import WfTryJobData 11 from model.wf_try_job_data import WfTryJobData
10 from pipeline_wrapper import BasePipeline 12 from pipeline_wrapper import BasePipeline
11 from waterfall.try_job_type import TryJobType 13 from waterfall.try_job_type import TryJobType
12 14
13 15
14 GIT_REPO = GitRepository( 16 GIT_REPO = GitRepository(
15 'https://chromium.googlesource.com/chromium/src.git', HttpClient()) 17 'https://chromium.googlesource.com/chromium/src.git', HttpClient())
16 18
17 19
20 def _GetResultAnalysisStatus(analysis, result):
21 """Returns the analysis status based on existing status and try job result.
22
23 Args:
24 analysis: The WfAnalysis entity corresponding to this try job.
25 result: A result dict containing the result of this try job.
26
27 Returns:
28 A wf_analysis_result_status code.
29 """
30 # Only return an updated analysis result status if no results were already
31 # found (by the heuristic-based approach). Note it is possible the
32 # heuristic-based result was triaged before the completion of this try job.
33 analysis_result_status = analysis.result_status
34
35 if (analysis_result_status is None or
36 analysis_result_status == wf_analysis_result_status.NOT_FOUND_UNTRIAGED or
37 analysis_result_status == wf_analysis_result_status.NOT_FOUND_INCORRECT or
38 analysis_result_status == wf_analysis_result_status.NOT_FOUND_CORRECT):
39 if result and result.get('culprit'):
40 return wf_analysis_result_status.FOUND_UNTRIAGED
41 return wf_analysis_result_status.NOT_FOUND_UNTRIAGED
stgao 2016/04/11 19:50:12 Why we reset wf_analysis_result_status.NOT_FOUND_I
lijeffrey 2016/04/12 21:10:54 Done.
42
43 return analysis_result_status
44
45
46 def _GetSuspectedCLs(analysis, result):
47 """Returns a list of suspected CLs.
48
49 Args:
50 analysis: The WfAnalysis entity corresponding to this try job.
51 result: A result dict containing the culprit from the results of
52 this tryjob.
53
54 Returns:
55 A combined list of suspected CLs from those already in analysis and those
56 found by this try job.
57 """
58 suspected_cls = analysis.suspected_cls or []
stgao 2016/04/11 19:50:13 Should we do a copy of analysis.suspected_cls inst
lijeffrey 2016/04/12 21:10:54 Done.
59
60 if not result:
61 return suspected_cls
62
63 culprit = result.get('culprit')
64 if not culprit:
65 return suspected_cls
66
67 compile_cl_info = culprit.get('compile')
68 if compile_cl_info:
69 # Suspected CL is from compile failure.
70 if compile_cl_info not in suspected_cls:
71 suspected_cls.append(compile_cl_info)
72 return suspected_cls
stgao 2016/04/11 19:50:12 How about the "else" case of line #70?
lijeffrey 2016/04/12 21:10:54 Done.
73
74 # Suspected CLs are from test failures.
75 for results in culprit.itervalues():
76 if results.get('revision'):
77 # Non swarming test failures, only have step level failure info.
78 cl_info = {
79 'review_url': results.get('review_url'),
80 'repo_name': results.get('repo_name'),
81 'revision': results.get('revision'),
82 'commit_position': results.get('commit_position')
83 }
84 if cl_info not in suspected_cls:
85 suspected_cls.append(cl_info)
86 else:
87 for test_cl_info in results['tests'].values():
88 if test_cl_info not in suspected_cls:
89 suspected_cls.append(test_cl_info)
90
91 return suspected_cls
92
93
18 class IdentifyTryJobCulpritPipeline(BasePipeline): 94 class IdentifyTryJobCulpritPipeline(BasePipeline):
19 """A pipeline to identify culprit CL info based on try job compile results.""" 95 """A pipeline to identify culprit CL info based on try job compile results."""
20 96
21 def _GetCulpritInfo(self, failed_revisions): 97 def _GetCulpritInfo(self, failed_revisions):
22 """Gets commit_positions and review_urls for revisions.""" 98 """Gets commit_positions and review_urls for revisions."""
23 culprits = {} 99 culprits = {}
100 # TODO(lijeffrey): remove hard-coded 'chromium' when DEPS file parsing is
101 # supported.
24 for failed_revision in failed_revisions: 102 for failed_revision in failed_revisions:
25 culprits[failed_revision] = { 103 culprits[failed_revision] = {
26 'revision': failed_revision 104 'revision': failed_revision,
105 'repo_name': 'chromium'
27 } 106 }
28 change_log = GIT_REPO.GetChangeLog(failed_revision) 107 change_log = GIT_REPO.GetChangeLog(failed_revision)
29 if change_log: 108 if change_log:
30 culprits[failed_revision]['commit_position'] = ( 109 culprits[failed_revision]['commit_position'] = (
31 change_log.commit_position) 110 change_log.commit_position)
32 culprits[failed_revision]['review_url'] = change_log.code_review_url 111 culprits[failed_revision]['review_url'] = change_log.code_review_url
33 112
34 return culprits 113 return culprits
35 114
36 @staticmethod 115 @staticmethod
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 178
100 if step not in culprit_map: 179 if step not in culprit_map:
101 culprit_map[step] = { 180 culprit_map[step] = {
102 'tests': {} 181 'tests': {}
103 } 182 }
104 183
105 if (not test_result['failures'] and 184 if (not test_result['failures'] and
106 not culprit_map[step].get('revision')): 185 not culprit_map[step].get('revision')):
107 # Non swarming test failures, only have step level failure info. 186 # Non swarming test failures, only have step level failure info.
108 culprit_map[step]['revision'] = revision 187 culprit_map[step]['revision'] = revision
188 culprit_map[step]['repo_name'] = 'chromium'
109 189
110 for failed_test in test_result['failures']: 190 for failed_test in test_result['failures']:
111 # Swarming tests, gets first failed revision for each test. 191 # Swarming tests, gets first failed revision for each test.
112 if failed_test not in culprit_map[step]['tests']: 192 if failed_test not in culprit_map[step]['tests']:
113 culprit_map[step]['tests'][failed_test] = { 193 culprit_map[step]['tests'][failed_test] = {
114 'revision': revision 194 'revision': revision
115 } 195 }
116 196
117 return culprit_map, failed_revisions 197 return culprit_map, failed_revisions
118 198
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 try_job_result.test_results) 261 try_job_result.test_results)
182 if (result_to_update and 262 if (result_to_update and
183 result_to_update[-1]['try_job_id'] == try_job_id): 263 result_to_update[-1]['try_job_id'] == try_job_id):
184 result_to_update[-1].update(result) 264 result_to_update[-1].update(result)
185 else: # pragma: no cover 265 else: # pragma: no cover
186 result_to_update.append(result) 266 result_to_update.append(result)
187 267
188 try_job_result.status = wf_analysis_status.ANALYZED 268 try_job_result.status = wf_analysis_status.ANALYZED
189 try_job_result.put() 269 try_job_result.put()
190 270
271 # Update analysis result and suspected CLs with results of this try job.
272 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
273 analysis.result_status = _GetResultAnalysisStatus(analysis, result)
stgao 2016/04/11 19:50:13 If result is empty, no checking is needed in which
lijeffrey 2016/04/12 21:10:54 Done.
274 analysis.suspected_cls = _GetSuspectedCLs(analysis, result)
275 analysis.put()
276
191 return result.get('culprit') if result else None 277 return result.get('culprit') if result else None
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/waterfall/test/identify_try_job_culprit_pipeline_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698