| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 logging | 5 import logging |
| 6 | 6 |
| 7 from testing_utils import testing | 7 from testing_utils import testing |
| 8 | 8 |
| 9 from common import constants | 9 from common import constants |
| 10 from common.pipeline_wrapper import pipeline_handlers | 10 from common.pipeline_wrapper import pipeline_handlers |
| 11 from model import analysis_status | 11 from model import analysis_status |
| 12 from model.wf_analysis import WfAnalysis | 12 from model.wf_analysis import WfAnalysis |
| 13 from waterfall import build_failure_analysis_pipelines | 13 from waterfall import build_failure_analysis_pipelines |
| 14 | 14 |
| 15 | 15 |
| 16 class _MockRootPipeline(object): | 16 class _MockRootPipeline(object): |
| 17 STARTED = False | 17 STARTED = False |
| 18 | 18 |
| 19 def __init__(self, master_name, builder_name, build_number, build_completed): | 19 def __init__(self, master_name, builder_name, build_number, build_completed, |
| 20 force_try_job): |
| 20 pass | 21 pass |
| 21 | 22 |
| 22 def pipeline_status_path(self): | 23 def pipeline_status_path(self): |
| 23 return '' | 24 return '' |
| 24 | 25 |
| 25 def start(self, queue_name): | 26 def start(self, queue_name): |
| 26 _MockRootPipeline.STARTED = True | 27 _MockRootPipeline.STARTED = True |
| 27 logging.info(queue_name) | 28 logging.info(queue_name) |
| 28 | 29 |
| 29 | 30 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 builder_name = 'b' | 160 builder_name = 'b' |
| 160 build_number = 124 | 161 build_number = 124 |
| 161 | 162 |
| 162 self.mock(build_failure_analysis_pipelines.analyze_build_failure_pipeline, | 163 self.mock(build_failure_analysis_pipelines.analyze_build_failure_pipeline, |
| 163 'AnalyzeBuildFailurePipeline', | 164 'AnalyzeBuildFailurePipeline', |
| 164 _MockRootPipeline) | 165 _MockRootPipeline) |
| 165 _MockRootPipeline.STARTED = False | 166 _MockRootPipeline.STARTED = False |
| 166 | 167 |
| 167 build_failure_analysis_pipelines.ScheduleAnalysisIfNeeded( | 168 build_failure_analysis_pipelines.ScheduleAnalysisIfNeeded( |
| 168 master_name, builder_name, build_number, failed_steps=['a'], | 169 master_name, builder_name, build_number, failed_steps=['a'], |
| 169 build_completed=False, force=False, queue_name=constants.DEFAULT_QUEUE) | 170 build_completed=False, force=False, force_try_job=False, |
| 171 queue_name=constants.DEFAULT_QUEUE) |
| 170 | 172 |
| 171 analysis = WfAnalysis.Get(master_name, builder_name, build_number) | 173 analysis = WfAnalysis.Get(master_name, builder_name, build_number) |
| 172 | 174 |
| 173 self.assertTrue(_MockRootPipeline.STARTED) | 175 self.assertTrue(_MockRootPipeline.STARTED) |
| 174 self.assertIsNotNone(analysis) | 176 self.assertIsNotNone(analysis) |
| 175 | 177 |
| 176 def testNotStartPipelineForNewAnalysis(self): | 178 def testNotStartPipelineForNewAnalysis(self): |
| 177 master_name = 'm' | 179 master_name = 'm' |
| 178 builder_name = 'b' | 180 builder_name = 'b' |
| 179 build_number = 123 | 181 build_number = 123 |
| 180 not_passed_steps = ['a'] | 182 not_passed_steps = ['a'] |
| 181 | 183 |
| 182 self._CreateAndSaveWfAnalysis( | 184 self._CreateAndSaveWfAnalysis( |
| 183 master_name, builder_name, build_number, | 185 master_name, builder_name, build_number, |
| 184 not_passed_steps, analysis_status.RUNNING) | 186 not_passed_steps, analysis_status.RUNNING) |
| 185 | 187 |
| 186 self.mock(build_failure_analysis_pipelines.analyze_build_failure_pipeline, | 188 self.mock(build_failure_analysis_pipelines.analyze_build_failure_pipeline, |
| 187 'AnalyzeBuildFailurePipeline', | 189 'AnalyzeBuildFailurePipeline', |
| 188 _MockRootPipeline) | 190 _MockRootPipeline) |
| 189 _MockRootPipeline.STARTED = False | 191 _MockRootPipeline.STARTED = False |
| 190 | 192 |
| 191 build_failure_analysis_pipelines.ScheduleAnalysisIfNeeded( | 193 build_failure_analysis_pipelines.ScheduleAnalysisIfNeeded( |
| 192 master_name, builder_name, build_number, failed_steps=['a'], | 194 master_name, builder_name, build_number, failed_steps=['a'], |
| 193 build_completed=True, force=False, queue_name=constants.DEFAULT_QUEUE) | 195 build_completed=True, force=False, queue_name=constants.DEFAULT_QUEUE) |
| 194 | 196 |
| 195 self.assertFalse(_MockRootPipeline.STARTED) | 197 self.assertFalse(_MockRootPipeline.STARTED) |
| OLD | NEW |