OLD | NEW |
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 model.wf_analysis import WfAnalysis | 5 from model.wf_analysis import WfAnalysis |
6 from model import wf_analysis_status | 6 from model import wf_analysis_status |
7 from waterfall import build_failure_analysis | 7 from waterfall import build_failure_analysis |
8 from waterfall.base_pipeline import BasePipeline | 8 from waterfall.base_pipeline import BasePipeline |
9 from model import wf_analysis_result_status | 9 from model import wf_analysis_result_status |
10 | 10 |
11 | 11 |
12 def _GetResultAnalysisStatus(analysis_result): | 12 def _GetResultAnalysisStatus(analysis_result): |
13 """Returns the status of the analysis result. | 13 """Returns the status of the analysis result. |
14 | 14 |
15 We can dicide the status based on: | 15 We can dicide the status based on: |
16 1. whether we found any suspected CL(s). | 16 1. whether we found any suspected CL(s). |
17 2. whether we have triaged the failure. | 17 2. whether we have triaged the failure. |
18 3. whether our analysis result is the same as triaged result. | 18 3. whether our analysis result is the same as triaged result. |
19 """ | 19 """ |
20 # Now we can only set the status based on if we found any suspected CL(s). | 20 # Now we can only set the status based on if we found any suspected CL(s). |
21 # TODO: Add logic to decide the status after comparing with culprit CL(s). | 21 # TODO: Add logic to decide the status after comparing with culprit CL(s). |
22 if not analysis_result or not analysis_result['failures']: | 22 if not analysis_result or not analysis_result['failures']: |
23 return None | 23 return None |
24 | 24 |
25 for failure in analysis_result['failures']: | 25 for failure in analysis_result['failures']: |
26 if failure['suspected_cls']: | 26 if failure['suspected_cls']: |
27 return wf_analysis_result_status.FOUND_UNTRIAGED | 27 return wf_analysis_result_status.FOUND_UNTRIAGED |
28 | 28 |
29 return wf_analysis_result_status.NOT_FOUND_UNTRIAGED | 29 return wf_analysis_result_status.NOT_FOUND_UNTRIAGED |
30 | 30 |
31 | 31 |
32 def _GetSuspectedCLs(analysis_result): | 32 def _GetSuspectedCLs(analysis_result): |
33 """Returns the suspected CLs we found in analysis.""" | 33 """Returns the suspected CLs we found in analysis.""" |
34 suspected_cls = [] | 34 suspected_cls = [] |
35 if not analysis_result or not analysis_result['failures']: | 35 if not analysis_result or not analysis_result['failures']: |
36 return suspected_cls | 36 return suspected_cls |
37 | 37 |
38 for failure in analysis_result['failures']: | 38 for failure in analysis_result['failures']: |
39 for suspected_cl in failure['suspected_cls']: | 39 for suspected_cl in failure['suspected_cls']: |
40 cl_info = { | 40 cl_info = { |
41 'repo_name': suspected_cl['repo_name'], | 41 'repo_name': suspected_cl['repo_name'], |
42 'revision': suspected_cl['revision'], | 42 'revision': suspected_cl['revision'], |
43 'commit_position': suspected_cl['commit_position'], | 43 'commit_position': suspected_cl['commit_position'], |
44 'url': suspected_cl['url'] | 44 'url': suspected_cl['url'] |
45 } | 45 } |
46 if cl_info not in suspected_cls: | 46 if cl_info not in suspected_cls: |
47 suspected_cls.append(cl_info) | 47 suspected_cls.append(cl_info) |
48 return suspected_cls | 48 return suspected_cls |
49 | 49 |
50 | 50 |
51 class IdentifyCulpritPipeline(BasePipeline): | 51 class IdentifyCulpritPipeline(BasePipeline): |
52 """A pipeline to identify culprit CLs for a build failure.""" | 52 """A pipeline to identify culprit CLs for a build failure.""" |
53 | 53 |
54 # Arguments number differs from overridden method - pylint: disable=W0221 | 54 # Arguments number differs from overridden method - pylint: disable=W0221 |
55 def run(self, failure_info, change_logs, signals): | 55 def run(self, failure_info, change_logs, deps_info, signals): |
56 """ | 56 """ |
57 Args: | 57 Args: |
58 failure_info (dict): Output of pipeline DetectFirstFailurePipeline. | 58 failure_info (dict): Output of pipeline DetectFirstFailurePipeline. |
59 change_logs (dict): Output of pipeline PullChangelogPipeline. | 59 change_logs (dict): Output of pipeline PullChangelogPipeline. |
60 signals (dict): Output of pipeline ExtractSignalPipeline. | 60 signals (dict): Output of pipeline ExtractSignalPipeline. |
61 | 61 |
62 Returns: | 62 Returns: |
63 The same dict as the returned value of function | 63 The same dict as the returned value of function |
64 build_failure_analysis.AnalyzeBuildFailure. | 64 build_failure_analysis.AnalyzeBuildFailure. |
65 """ | 65 """ |
66 master_name = failure_info['master_name'] | 66 master_name = failure_info['master_name'] |
67 builder_name = failure_info['builder_name'] | 67 builder_name = failure_info['builder_name'] |
68 build_number = failure_info['build_number'] | 68 build_number = failure_info['build_number'] |
69 | 69 |
70 analysis_result = build_failure_analysis.AnalyzeBuildFailure( | 70 analysis_result = build_failure_analysis.AnalyzeBuildFailure( |
71 failure_info, change_logs, signals) | 71 failure_info, change_logs, deps_info, signals) |
72 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 72 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
73 analysis.result = analysis_result | 73 analysis.result = analysis_result |
74 analysis.status = wf_analysis_status.ANALYZED | 74 analysis.status = wf_analysis_status.ANALYZED |
75 analysis.result_status = _GetResultAnalysisStatus(analysis_result) | 75 analysis.result_status = _GetResultAnalysisStatus(analysis_result) |
76 analysis.suspected_cls = _GetSuspectedCLs(analysis_result) | 76 analysis.suspected_cls = _GetSuspectedCLs(analysis_result) |
77 analysis.put() | 77 analysis.put() |
78 | 78 |
79 return analysis_result | 79 return analysis_result |
OLD | NEW |