| 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 datetime import datetime | 5 from datetime import datetime |
| 6 | 6 |
| 7 from model import wf_analysis_result_status | 7 from model import result_status |
| 8 from model import wf_analysis_status | 8 from model import analysis_status |
| 9 from model.wf_analysis import WfAnalysis | 9 from model.wf_analysis import WfAnalysis |
| 10 from pipeline_wrapper import BasePipeline | 10 from pipeline_wrapper import BasePipeline |
| 11 from waterfall import build_failure_analysis | 11 from waterfall import build_failure_analysis |
| 12 | 12 |
| 13 | 13 |
| 14 def _GetResultAnalysisStatus(analysis_result): | 14 def _GetResultAnalysisStatus(analysis_result): |
| 15 """Returns the status of the analysis result. | 15 """Returns the status of the analysis result. |
| 16 | 16 |
| 17 We can decide the status based on: | 17 We can decide the status based on: |
| 18 1. whether we found any suspected CL(s). | 18 1. whether we found any suspected CL(s). |
| 19 2. whether we have triaged the failure. | 19 2. whether we have triaged the failure. |
| 20 3. whether our analysis result is the same as triaged result. | 20 3. whether our analysis result is the same as triaged result. |
| 21 """ | 21 """ |
| 22 # Now we can only set the status based on if we found any suspected CL(s). | 22 # Now we can only set the status based on if we found any suspected CL(s). |
| 23 # TODO: Add logic to decide the status after comparing with culprit CL(s). | 23 # TODO: Add logic to decide the status after comparing with culprit CL(s). |
| 24 if not analysis_result or not analysis_result['failures']: | 24 if not analysis_result or not analysis_result['failures']: |
| 25 return None | 25 return None |
| 26 | 26 |
| 27 for failure in analysis_result['failures']: | 27 for failure in analysis_result['failures']: |
| 28 if failure['suspected_cls']: | 28 if failure['suspected_cls']: |
| 29 return wf_analysis_result_status.FOUND_UNTRIAGED | 29 return result_status.FOUND_UNTRIAGED |
| 30 | 30 |
| 31 return wf_analysis_result_status.NOT_FOUND_UNTRIAGED | 31 return result_status.NOT_FOUND_UNTRIAGED |
| 32 | 32 |
| 33 | 33 |
| 34 def _GetSuspectedCLs(analysis_result): | 34 def _GetSuspectedCLs(analysis_result): |
| 35 """Returns the suspected CLs we found in analysis.""" | 35 """Returns the suspected CLs we found in analysis.""" |
| 36 suspected_cls = [] | 36 suspected_cls = [] |
| 37 if not analysis_result or not analysis_result['failures']: | 37 if not analysis_result or not analysis_result['failures']: |
| 38 return suspected_cls | 38 return suspected_cls |
| 39 | 39 |
| 40 for failure in analysis_result['failures']: | 40 for failure in analysis_result['failures']: |
| 41 for suspected_cl in failure['suspected_cls']: | 41 for suspected_cl in failure['suspected_cls']: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 68 """ | 68 """ |
| 69 master_name = failure_info['master_name'] | 69 master_name = failure_info['master_name'] |
| 70 builder_name = failure_info['builder_name'] | 70 builder_name = failure_info['builder_name'] |
| 71 build_number = failure_info['build_number'] | 71 build_number = failure_info['build_number'] |
| 72 | 72 |
| 73 analysis_result = build_failure_analysis.AnalyzeBuildFailure( | 73 analysis_result = build_failure_analysis.AnalyzeBuildFailure( |
| 74 failure_info, change_logs, deps_info, signals) | 74 failure_info, change_logs, deps_info, signals) |
| 75 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 75 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
| 76 analysis.build_completed = build_completed | 76 analysis.build_completed = build_completed |
| 77 analysis.result = analysis_result | 77 analysis.result = analysis_result |
| 78 analysis.status = wf_analysis_status.ANALYZED | 78 analysis.status = analysis_status.COMPLETED |
| 79 analysis.result_status = _GetResultAnalysisStatus(analysis_result) | 79 analysis.result_status = _GetResultAnalysisStatus(analysis_result) |
| 80 analysis.suspected_cls = _GetSuspectedCLs(analysis_result) | 80 analysis.suspected_cls = _GetSuspectedCLs(analysis_result) |
| 81 analysis.end_time = datetime.utcnow() | 81 analysis.end_time = datetime.utcnow() |
| 82 analysis.put() | 82 analysis.put() |
| 83 | 83 |
| 84 return analysis_result | 84 return analysis_result |
| OLD | NEW |