| 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 json | 5 import json |
| 6 | 6 |
| 7 from common.git_repository import GitRepository | 7 from common.git_repository import GitRepository |
| 8 from common.pipeline_wrapper import BasePipeline |
| 8 from common.pipeline_wrapper import pipeline_handlers | 9 from common.pipeline_wrapper import pipeline_handlers |
| 9 from common.waterfall import buildbucket_client | 10 from common.waterfall import buildbucket_client |
| 10 from model import analysis_status | 11 from model import analysis_status |
| 11 from model import result_status | 12 from model import result_status |
| 12 from model.wf_analysis import WfAnalysis | 13 from model.wf_analysis import WfAnalysis |
| 13 from model.wf_try_job import WfTryJob | 14 from model.wf_try_job import WfTryJob |
| 15 from waterfall import send_notification_for_culprit_pipeline |
| 14 from waterfall.test import wf_testcase | 16 from waterfall.test import wf_testcase |
| 15 from waterfall.try_job_pipeline import TryJobPipeline | 17 from waterfall.try_job_pipeline import TryJobPipeline |
| 16 from waterfall.try_job_type import TryJobType | 18 from waterfall.try_job_type import TryJobType |
| 17 | 19 |
| 18 | 20 |
| 19 class TryJobPipelineTest(wf_testcase.WaterfallTestCase): | 21 class TryJobPipelineTest(wf_testcase.WaterfallTestCase): |
| 20 app_module = pipeline_handlers._APP | 22 app_module = pipeline_handlers._APP |
| 21 | 23 |
| 22 def _Mock_TriggerTryJobs(self, responses): | 24 def _Mock_TriggerTryJobs(self, responses): |
| 23 def MockedTriggerTryJobs(*_): | 25 def MockedTriggerTryJobs(*_): |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 81 |
| 80 def __init__(self, commit_position, code_review_url): | 82 def __init__(self, commit_position, code_review_url): |
| 81 self.commit_position = commit_position | 83 self.commit_position = commit_position |
| 82 self.code_review_url = code_review_url | 84 self.code_review_url = code_review_url |
| 83 | 85 |
| 84 mock_change_logs = {} | 86 mock_change_logs = {} |
| 85 mock_change_logs['rev2'] = MockedChangeLog('2', 'url_2') | 87 mock_change_logs['rev2'] = MockedChangeLog('2', 'url_2') |
| 86 return mock_change_logs.get(revision) | 88 return mock_change_logs.get(revision) |
| 87 self.mock(GitRepository, 'GetChangeLog', MockedGetChangeLog) | 89 self.mock(GitRepository, 'GetChangeLog', MockedGetChangeLog) |
| 88 | 90 |
| 91 def _Mock_SendNotificationForCulpritPipeline(self): |
| 92 class Mocked_Pipeline(BasePipeline): |
| 93 def run(self, *args, **kwargs): # unused arg - pylint: disable=W0612 |
| 94 pass |
| 95 self.mock(send_notification_for_culprit_pipeline, |
| 96 'SendNotificationForCulpritPipeline', Mocked_Pipeline) |
| 97 |
| 89 def testSuccessfullyScheduleNewTryJobForCompile(self): | 98 def testSuccessfullyScheduleNewTryJobForCompile(self): |
| 90 master_name = 'm' | 99 master_name = 'm' |
| 91 builder_name = 'b' | 100 builder_name = 'b' |
| 92 build_number = 1 | 101 build_number = 1 |
| 93 | 102 |
| 94 responses = [ | 103 responses = [ |
| 95 { | 104 { |
| 96 'build': { | 105 'build': { |
| 97 'id': '1', | 106 'id': '1', |
| 98 'url': 'url', | 107 'url': 'url', |
| 99 'status': 'SCHEDULED', | 108 'status': 'SCHEDULED', |
| 100 } | 109 } |
| 101 } | 110 } |
| 102 ] | 111 ] |
| 103 | 112 |
| 104 self._Mock_TriggerTryJobs(responses) | 113 self._Mock_TriggerTryJobs(responses) |
| 105 self._Mock_GetTryJobs('1') | 114 self._Mock_GetTryJobs('1') |
| 106 self._Mock_GetChangeLog('rev2') | 115 self._Mock_GetChangeLog('rev2') |
| 116 self._Mock_SendNotificationForCulpritPipeline() |
| 107 | 117 |
| 108 WfTryJob.Create(master_name, builder_name, build_number).put() | 118 WfTryJob.Create(master_name, builder_name, build_number).put() |
| 109 analysis = WfAnalysis.Create(master_name, builder_name, build_number) | 119 analysis = WfAnalysis.Create(master_name, builder_name, build_number) |
| 110 analysis.put() | 120 analysis.put() |
| 111 | 121 |
| 112 root_pipeline = TryJobPipeline( | 122 root_pipeline = TryJobPipeline( |
| 113 master_name, builder_name, build_number, 'rev1', 'rev2', ['rev2'], | 123 master_name, builder_name, build_number, 'rev1', 'rev2', ['rev2'], |
| 114 TryJobType.COMPILE, []) | 124 TryJobType.COMPILE, []) |
| 115 root_pipeline.start() | 125 root_pipeline.start() |
| 116 self.execute_queued_tasks() | 126 self.execute_queued_tasks() |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 build_number = 1 | 179 build_number = 1 |
| 170 | 180 |
| 171 root_pipeline = TryJobPipeline( | 181 root_pipeline = TryJobPipeline( |
| 172 master_name, builder_name, build_number, 'rev1', 'rev2', ['rev2'], | 182 master_name, builder_name, build_number, 'rev1', 'rev2', ['rev2'], |
| 173 TryJobType.COMPILE, []) | 183 TryJobType.COMPILE, []) |
| 174 root_pipeline._LogUnexpectedAbort(True) | 184 root_pipeline._LogUnexpectedAbort(True) |
| 175 | 185 |
| 176 try_job = WfTryJob.Get(master_name, builder_name, build_number) | 186 try_job = WfTryJob.Get(master_name, builder_name, build_number) |
| 177 | 187 |
| 178 self.assertIsNone(try_job) | 188 self.assertIsNone(try_job) |
| OLD | NEW |