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