| 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 testing_utils import testing | |
| 6 | |
| 7 from common import buildbucket_client | 5 from common import buildbucket_client |
| 8 from model.wf_try_job import WfTryJob | 6 from model.wf_try_job import WfTryJob |
| 9 from waterfall import waterfall_config | |
| 10 from waterfall.schedule_try_job_pipeline import ScheduleTryJobPipeline | 7 from waterfall.schedule_try_job_pipeline import ScheduleTryJobPipeline |
| 8 from waterfall.test import wf_configured_test_case |
| 11 from waterfall.try_job_type import TryJobType | 9 from waterfall.try_job_type import TryJobType |
| 12 | 10 |
| 13 | 11 |
| 14 class ScheduleTryjobPipelineTest(testing.AppengineTestCase): | 12 class ScheduleTryjobPipelineTest( |
| 15 | 13 wf_configured_test_case.WaterfallConfiguredTestCase): |
| 16 def _Mock_GetTrybotForWaterfallBuilder(self, *_): | |
| 17 def MockedGetTrybotForWaterfallBuilder(*_): | |
| 18 return 'linux_chromium_variable', 'master.tryserver.chromium.linux' | |
| 19 self.mock(waterfall_config, 'GetTrybotForWaterfallBuilder', | |
| 20 MockedGetTrybotForWaterfallBuilder) | |
| 21 | 14 |
| 22 def _Mock_TriggerTryJobs(self, responses): | 15 def _Mock_TriggerTryJobs(self, responses): |
| 23 def MockedTriggerTryJobs(*_): | 16 def MockedTriggerTryJobs(*_): |
| 24 results = [] | 17 results = [] |
| 25 for response in responses: | 18 for response in responses: |
| 26 if response.get('error'): # pragma: no cover | 19 if response.get('error'): # pragma: no cover |
| 27 results.append(( | 20 results.append(( |
| 28 buildbucket_client.BuildbucketError(response['error']), None)) | 21 buildbucket_client.BuildbucketError(response['error']), None)) |
| 29 else: | 22 else: |
| 30 results.append(( | 23 results.append(( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 82 |
| 90 responses = [ | 83 responses = [ |
| 91 { | 84 { |
| 92 'build': { | 85 'build': { |
| 93 'id': '1', | 86 'id': '1', |
| 94 'url': 'url', | 87 'url': 'url', |
| 95 'status': 'SCHEDULED', | 88 'status': 'SCHEDULED', |
| 96 } | 89 } |
| 97 } | 90 } |
| 98 ] | 91 ] |
| 99 self._Mock_GetTrybotForWaterfallBuilder(master_name, builder_name) | 92 |
| 100 self._Mock_TriggerTryJobs(responses) | 93 self._Mock_TriggerTryJobs(responses) |
| 101 | 94 |
| 102 WfTryJob.Create(master_name, builder_name, build_number).put() | 95 WfTryJob.Create(master_name, builder_name, build_number).put() |
| 103 | 96 |
| 104 try_job_pipeline = ScheduleTryJobPipeline() | 97 try_job_pipeline = ScheduleTryJobPipeline() |
| 105 try_job_id = try_job_pipeline.run( | 98 try_job_id = try_job_pipeline.run( |
| 106 master_name, builder_name, build_number, good_revision, bad_revision, | 99 master_name, builder_name, build_number, good_revision, bad_revision, |
| 107 TryJobType.COMPILE, None, None) | 100 TryJobType.COMPILE, None, None) |
| 108 | 101 |
| 109 try_job = WfTryJob.Get(master_name, builder_name, build_number) | 102 try_job = WfTryJob.Get(master_name, builder_name, build_number) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 123 | 116 |
| 124 responses = [ | 117 responses = [ |
| 125 { | 118 { |
| 126 'build': { | 119 'build': { |
| 127 'id': '1', | 120 'id': '1', |
| 128 'url': 'url', | 121 'url': 'url', |
| 129 'status': 'SCHEDULED', | 122 'status': 'SCHEDULED', |
| 130 } | 123 } |
| 131 } | 124 } |
| 132 ] | 125 ] |
| 133 self._Mock_GetTrybotForWaterfallBuilder(master_name, builder_name) | |
| 134 self._Mock_TriggerTryJobs(responses) | 126 self._Mock_TriggerTryJobs(responses) |
| 135 | 127 |
| 136 WfTryJob.Create(master_name, builder_name, build_number).put() | 128 WfTryJob.Create(master_name, builder_name, build_number).put() |
| 137 | 129 |
| 138 try_job_pipeline = ScheduleTryJobPipeline() | 130 try_job_pipeline = ScheduleTryJobPipeline() |
| 139 try_job_id = try_job_pipeline.run( | 131 try_job_id = try_job_pipeline.run( |
| 140 master_name, builder_name, build_number, good_revision, bad_revision, | 132 master_name, builder_name, build_number, good_revision, bad_revision, |
| 141 TryJobType.TEST, None, targeted_tests) | 133 TryJobType.TEST, None, targeted_tests) |
| 142 | 134 |
| 143 try_job = WfTryJob.Get(master_name, builder_name, build_number) | 135 try_job = WfTryJob.Get(master_name, builder_name, build_number) |
| 144 self.assertEqual('1', try_job_id) | 136 self.assertEqual('1', try_job_id) |
| 145 self.assertEqual('1', try_job.test_results[-1]['try_job_id']) | 137 self.assertEqual('1', try_job.test_results[-1]['try_job_id']) |
| OLD | NEW |