| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 result_status | 11 from model import result_status |
| 11 from model.wf_analysis import WfAnalysis | 12 from model.wf_analysis import WfAnalysis |
| 12 from model.wf_try_job import WfTryJob | 13 from model.wf_try_job import WfTryJob |
| 14 from waterfall import send_notification_for_culprit_pipeline |
| 13 from waterfall import swarming_util | 15 from waterfall import swarming_util |
| 14 from waterfall import trigger_swarming_task_pipeline | 16 from waterfall import trigger_swarming_task_pipeline |
| 15 from waterfall.swarming_task_request import SwarmingTaskRequest | 17 from waterfall.swarming_task_request import SwarmingTaskRequest |
| 16 from waterfall.swarming_tasks_to_try_job_pipeline import ( | 18 from waterfall.swarming_tasks_to_try_job_pipeline import ( |
| 17 SwarmingTasksToTryJobPipeline) | 19 SwarmingTasksToTryJobPipeline) |
| 18 from waterfall.test import wf_testcase | 20 from waterfall.test import wf_testcase |
| 19 from waterfall.try_job_type import TryJobType | 21 from waterfall.try_job_type import TryJobType |
| 20 | 22 |
| 21 | 23 |
| 22 _ISOLATED_SERVER = 'https://isolateserver.appspot.com' | 24 _ISOLATED_SERVER = 'https://isolateserver.appspot.com' |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 def __init__(self, commit_position, code_review_url): | 179 def __init__(self, commit_position, code_review_url): |
| 178 self.commit_position = commit_position | 180 self.commit_position = commit_position |
| 179 self.code_review_url = code_review_url | 181 self.code_review_url = code_review_url |
| 180 | 182 |
| 181 mock_change_logs = {} | 183 mock_change_logs = {} |
| 182 mock_change_logs['rev1'] = MockedChangeLog('1', 'url_1') | 184 mock_change_logs['rev1'] = MockedChangeLog('1', 'url_1') |
| 183 mock_change_logs['rev2'] = MockedChangeLog('2', 'url_2') | 185 mock_change_logs['rev2'] = MockedChangeLog('2', 'url_2') |
| 184 return mock_change_logs.get(revision) | 186 return mock_change_logs.get(revision) |
| 185 self.mock(GitRepository, 'GetChangeLog', MockedGetChangeLog) | 187 self.mock(GitRepository, 'GetChangeLog', MockedGetChangeLog) |
| 186 | 188 |
| 189 def _Mock_SendNotificationForCulpritPipeline(self): |
| 190 class Mocked_Pipeline(BasePipeline): |
| 191 def run(self, *args, **kwargs): # unused arg - pylint: disable=W0612 |
| 192 pass |
| 193 self.mock(send_notification_for_culprit_pipeline, |
| 194 'SendNotificationForCulpritPipeline', Mocked_Pipeline) |
| 195 |
| 187 def testSuccessfullyScheduleNewTryJobForCompile(self): | 196 def testSuccessfullyScheduleNewTryJobForCompile(self): |
| 188 master_name = 'm' | 197 master_name = 'm' |
| 189 builder_name = 'b' | 198 builder_name = 'b' |
| 190 build_number = 1 | 199 build_number = 1 |
| 191 | 200 |
| 192 responses = [ | 201 responses = [ |
| 193 { | 202 { |
| 194 'build': { | 203 'build': { |
| 195 'id': '1', | 204 'id': '1', |
| 196 'url': 'url', | 205 'url': 'url', |
| 197 'status': 'SCHEDULED', | 206 'status': 'SCHEDULED', |
| 198 } | 207 } |
| 199 } | 208 } |
| 200 ] | 209 ] |
| 201 self._MockTriggerTryJobs(responses) | 210 self._MockTriggerTryJobs(responses) |
| 202 self._MockGetTryJobs('1') | 211 self._MockGetTryJobs('1') |
| 203 self._MockGetChangeLog('rev2') | 212 self._MockGetChangeLog('rev2') |
| 213 self._Mock_SendNotificationForCulpritPipeline() |
| 204 | 214 |
| 205 WfTryJob.Create(master_name, builder_name, build_number).put() | 215 WfTryJob.Create(master_name, builder_name, build_number).put() |
| 206 analysis = WfAnalysis.Create(master_name, builder_name, build_number) | 216 analysis = WfAnalysis.Create(master_name, builder_name, build_number) |
| 207 analysis.put() | 217 analysis.put() |
| 208 | 218 |
| 209 root_pipeline = SwarmingTasksToTryJobPipeline( | 219 root_pipeline = SwarmingTasksToTryJobPipeline( |
| 210 master_name, builder_name, build_number, 'rev1', 'rev2', ['rev2'], | 220 master_name, builder_name, build_number, 'rev1', 'rev2', ['rev2'], |
| 211 TryJobType.COMPILE) | 221 TryJobType.COMPILE) |
| 212 root_pipeline.start() | 222 root_pipeline.start() |
| 213 self.execute_queued_tasks() | 223 self.execute_queued_tasks() |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 'build': { | 340 'build': { |
| 331 'id': '2', | 341 'id': '2', |
| 332 'url': 'url', | 342 'url': 'url', |
| 333 'status': 'SCHEDULED', | 343 'status': 'SCHEDULED', |
| 334 } | 344 } |
| 335 } | 345 } |
| 336 ] | 346 ] |
| 337 self._MockTriggerTryJobs(responses) | 347 self._MockTriggerTryJobs(responses) |
| 338 self._MockGetTryJobs('2') | 348 self._MockGetTryJobs('2') |
| 339 self._MockGetChangeLog('rev1') | 349 self._MockGetChangeLog('rev1') |
| 350 self._Mock_SendNotificationForCulpritPipeline() |
| 340 | 351 |
| 341 WfTryJob.Create(master_name, builder_name, build_number).put() | 352 WfTryJob.Create(master_name, builder_name, build_number).put() |
| 342 analysis = WfAnalysis.Create(master_name, builder_name, build_number) | 353 analysis = WfAnalysis.Create(master_name, builder_name, build_number) |
| 343 analysis.put() | 354 analysis.put() |
| 344 | 355 |
| 345 root_pipeline = SwarmingTasksToTryJobPipeline( | 356 root_pipeline = SwarmingTasksToTryJobPipeline( |
| 346 master_name, builder_name, build_number, 'rev0', 'rev1', ['rev1'], | 357 master_name, builder_name, build_number, 'rev0', 'rev1', ['rev1'], |
| 347 TryJobType.TEST, None, targeted_tests) | 358 TryJobType.TEST, None, targeted_tests) |
| 348 root_pipeline.start() | 359 root_pipeline.start() |
| 349 self.execute_queued_tasks() | 360 self.execute_queued_tasks() |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 399 } |
| 389 } | 400 } |
| 390 } | 401 } |
| 391 } | 402 } |
| 392 ] | 403 ] |
| 393 | 404 |
| 394 self.assertEqual(expected_try_job_results, try_job.test_results) | 405 self.assertEqual(expected_try_job_results, try_job.test_results) |
| 395 self.assertEqual(analysis.result_status, | 406 self.assertEqual(analysis.result_status, |
| 396 result_status.FOUND_UNTRIAGED) | 407 result_status.FOUND_UNTRIAGED) |
| 397 self.assertEqual(analysis.suspected_cls, [expected_suspected_cl]) | 408 self.assertEqual(analysis.suspected_cls, [expected_suspected_cl]) |
| OLD | NEW |