| 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 import os | 5 import os |
| 6 | 6 |
| 7 from common import constants |
| 7 from common import chromium_deps | 8 from common import chromium_deps |
| 8 from model import wf_analysis_status | 9 from model import analysis_status |
| 9 from model.wf_analysis import WfAnalysis | 10 from model.wf_analysis import WfAnalysis |
| 10 from pipeline_wrapper import pipeline_handlers | 11 from pipeline_wrapper import pipeline_handlers |
| 11 from waterfall import buildbot | 12 from waterfall import buildbot |
| 12 from waterfall import lock_util | 13 from waterfall import lock_util |
| 13 from waterfall.analyze_build_failure_pipeline import AnalyzeBuildFailurePipeline | 14 from waterfall.analyze_build_failure_pipeline import AnalyzeBuildFailurePipeline |
| 14 from waterfall.test import wf_testcase | 15 from waterfall.test import wf_testcase |
| 15 | 16 |
| 16 | 17 |
| 17 class AnalyzeBuildFailurePipelineTest(wf_testcase.WaterfallTestCase): | 18 class AnalyzeBuildFailurePipelineTest(wf_testcase.WaterfallTestCase): |
| 18 app_module = pipeline_handlers._APP | 19 app_module = pipeline_handlers._APP |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 56 } |
| 56 """ | 57 """ |
| 57 commit_log = COMMIT_LOG_TEMPLATE.replace( | 58 commit_log = COMMIT_LOG_TEMPLATE.replace( |
| 58 'REVISION', revision).replace('USER_NAME', user_name).replace( | 59 'REVISION', revision).replace('USER_NAME', user_name).replace( |
| 59 'COMMIT_POSITION', str(commit_position)).replace( | 60 'COMMIT_POSITION', str(commit_position)).replace( |
| 60 'FILE_PATH', file_path) | 61 'FILE_PATH', file_path) |
| 61 urlfetch.register_handler(url, commit_log) | 62 urlfetch.register_handler(url, commit_log) |
| 62 | 63 |
| 63 def _Setup(self, master_name, builder_name, build_number): | 64 def _Setup(self, master_name, builder_name, build_number): |
| 64 analysis = WfAnalysis.Create(master_name, builder_name, build_number) | 65 analysis = WfAnalysis.Create(master_name, builder_name, build_number) |
| 65 analysis.status = wf_analysis_status.ANALYZING | 66 analysis.status = analysis_status.RUNNING |
| 66 analysis.put() | 67 analysis.put() |
| 67 | 68 |
| 68 def MockWaitUntilDownloadAllowed(*_): | 69 def MockWaitUntilDownloadAllowed(*_): |
| 69 return True | 70 return True |
| 70 self.mock( | 71 self.mock( |
| 71 lock_util, 'WaitUntilDownloadAllowed', MockWaitUntilDownloadAllowed) | 72 lock_util, 'WaitUntilDownloadAllowed', MockWaitUntilDownloadAllowed) |
| 72 | 73 |
| 73 with self.mock_urlfetch() as urlfetch: | 74 with self.mock_urlfetch() as urlfetch: |
| 74 # Mock build data. | 75 # Mock build data. |
| 75 for i in range(2): | 76 for i in range(2): |
| (...skipping 23 matching lines...) Expand all Loading... |
| 99 master_name = 'm' | 100 master_name = 'm' |
| 100 builder_name = 'b' | 101 builder_name = 'b' |
| 101 build_number = 124 | 102 build_number = 124 |
| 102 | 103 |
| 103 self._Setup(master_name, builder_name, build_number) | 104 self._Setup(master_name, builder_name, build_number) |
| 104 | 105 |
| 105 root_pipeline = AnalyzeBuildFailurePipeline(master_name, | 106 root_pipeline = AnalyzeBuildFailurePipeline(master_name, |
| 106 builder_name, | 107 builder_name, |
| 107 build_number, | 108 build_number, |
| 108 False) | 109 False) |
| 109 root_pipeline.start(queue_name='default') | 110 root_pipeline.start(queue_name=constants.DEFAULT_QUEUE) |
| 110 self.execute_queued_tasks() | 111 self.execute_queued_tasks() |
| 111 | 112 |
| 112 expected_analysis_result = { | 113 expected_analysis_result = { |
| 113 'failures': [ | 114 'failures': [ |
| 114 { | 115 { |
| 115 'step_name': 'a', | 116 'step_name': 'a', |
| 116 'supported': True, | 117 'supported': True, |
| 117 'first_failure': 124, | 118 'first_failure': 124, |
| 118 'last_pass': 123, | 119 'last_pass': 123, |
| 119 'suspected_cls': [ | 120 'suspected_cls': [ |
| 120 { | 121 { |
| 121 'build_number': 124, | 122 'build_number': 124, |
| 122 'repo_name': 'chromium', | 123 'repo_name': 'chromium', |
| 123 'revision': 'some_git_hash', | 124 'revision': 'some_git_hash', |
| 124 'commit_position': 8888, | 125 'commit_position': 8888, |
| 125 'url': ('https://chromium.googlesource.com/chromium' | 126 'url': ('https://chromium.googlesource.com/chromium' |
| 126 '/src.git/+/some_git_hash'), | 127 '/src.git/+/some_git_hash'), |
| 127 'score': 2, | 128 'score': 2, |
| 128 'hints': { | 129 'hints': { |
| 129 'modified x.cc (and it was in log)': 2, | 130 'modified x.cc (and it was in log)': 2, |
| 130 }, | 131 }, |
| 131 } | 132 } |
| 132 ], | 133 ], |
| 133 } | 134 } |
| 134 ] | 135 ] |
| 135 } | 136 } |
| 136 | 137 |
| 137 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 138 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
| 138 self.assertIsNotNone(analysis) | 139 self.assertIsNotNone(analysis) |
| 139 self.assertEqual(wf_analysis_status.ANALYZED, analysis.status) | 140 self.assertEqual(analysis_status.COMPLETED, analysis.status) |
| 140 self.assertEqual(expected_analysis_result, analysis.result) | 141 self.assertEqual(expected_analysis_result, analysis.result) |
| 141 self.assertIsNotNone(analysis.result_status) | 142 self.assertIsNotNone(analysis.result_status) |
| 142 | 143 |
| 143 def testBuildFailurePipelineStartWithNoneResultStatus(self): | 144 def testBuildFailurePipelineStartWithNoneResultStatus(self): |
| 144 master_name = 'm' | 145 master_name = 'm' |
| 145 builder_name = 'b' | 146 builder_name = 'b' |
| 146 build_number = 124 | 147 build_number = 124 |
| 147 | 148 |
| 148 self._Setup(master_name, builder_name, build_number) | 149 self._Setup(master_name, builder_name, build_number) |
| 149 | 150 |
| 150 root_pipeline = AnalyzeBuildFailurePipeline(master_name, | 151 root_pipeline = AnalyzeBuildFailurePipeline(master_name, |
| 151 builder_name, | 152 builder_name, |
| 152 build_number, | 153 build_number, |
| 153 False) | 154 False) |
| 154 root_pipeline._ResetAnalysis(master_name, builder_name, build_number) | 155 root_pipeline._ResetAnalysis(master_name, builder_name, build_number) |
| 155 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 156 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
| 156 self.assertIsNotNone(analysis) | 157 self.assertIsNotNone(analysis) |
| 157 self.assertEqual(wf_analysis_status.ANALYZING, analysis.status) | 158 self.assertEqual(analysis_status.RUNNING, analysis.status) |
| 158 self.assertIsNone(analysis.result_status) | 159 self.assertIsNone(analysis.result_status) |
| 159 | 160 |
| 160 def testAnalyzeBuildFailurePipelineAbortedWithAnalysis(self): | 161 def testAnalyzeBuildFailurePipelineAbortedWithAnalysis(self): |
| 161 master_name = 'm' | 162 master_name = 'm' |
| 162 builder_name = 'b' | 163 builder_name = 'b' |
| 163 build_number = 124 | 164 build_number = 124 |
| 164 | 165 |
| 165 self._Setup(master_name, builder_name, build_number) | 166 self._Setup(master_name, builder_name, build_number) |
| 166 | 167 |
| 167 root_pipeline = AnalyzeBuildFailurePipeline(master_name, | 168 root_pipeline = AnalyzeBuildFailurePipeline(master_name, |
| 168 builder_name, | 169 builder_name, |
| 169 build_number, | 170 build_number, |
| 170 False) | 171 False) |
| 171 root_pipeline._LogUnexpectedAborting(True) | 172 root_pipeline._LogUnexpectedAborting(True) |
| 172 | 173 |
| 173 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 174 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
| 174 self.assertIsNotNone(analysis) | 175 self.assertIsNotNone(analysis) |
| 175 self.assertEqual(wf_analysis_status.ERROR, analysis.status) | 176 self.assertEqual(analysis_status.ERROR, analysis.status) |
| 176 self.assertIsNone(analysis.result_status) | 177 self.assertIsNone(analysis.result_status) |
| 177 | 178 |
| 178 def testAnalyzeBuildFailurePipelineAbortedWithoutAnalysis(self): | 179 def testAnalyzeBuildFailurePipelineAbortedWithoutAnalysis(self): |
| 179 master_name = 'm' | 180 master_name = 'm' |
| 180 builder_name = 'b' | 181 builder_name = 'b' |
| 181 build_number = 124 | 182 build_number = 124 |
| 182 | 183 |
| 183 root_pipeline = AnalyzeBuildFailurePipeline(master_name, | 184 root_pipeline = AnalyzeBuildFailurePipeline(master_name, |
| 184 builder_name, | 185 builder_name, |
| 185 build_number, | 186 build_number, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 197 self._Setup(master_name, builder_name, build_number) | 198 self._Setup(master_name, builder_name, build_number) |
| 198 | 199 |
| 199 root_pipeline = AnalyzeBuildFailurePipeline(master_name, | 200 root_pipeline = AnalyzeBuildFailurePipeline(master_name, |
| 200 builder_name, | 201 builder_name, |
| 201 build_number, | 202 build_number, |
| 202 False) | 203 False) |
| 203 root_pipeline._LogUnexpectedAborting(False) | 204 root_pipeline._LogUnexpectedAborting(False) |
| 204 | 205 |
| 205 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 206 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
| 206 self.assertIsNotNone(analysis) | 207 self.assertIsNotNone(analysis) |
| 207 self.assertNotEqual(wf_analysis_status.ERROR, analysis.status) | 208 self.assertNotEqual(analysis_status.ERROR, analysis.status) |
| OLD | NEW |