| 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 | 5 from testing_utils import testing |
| 6 | 6 |
| 7 from common import buildbucket_client | 7 from common import buildbucket_client |
| 8 from model.wf_try_job import WfTryJob | 8 from model.wf_try_job import WfTryJob |
| 9 from waterfall import waterfall_config | 9 from waterfall import waterfall_config |
| 10 from waterfall.schedule_try_job_pipeline import ScheduleTryJobPipeline | 10 from waterfall.schedule_try_job_pipeline import ScheduleTryJobPipeline |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 buildbucket_client.BuildbucketError(response['error']), None)) | 27 buildbucket_client.BuildbucketError(response['error']), None)) |
| 28 else: | 28 else: |
| 29 results.append(( | 29 results.append(( |
| 30 None, buildbucket_client.BuildbucketBuild(response['build']))) | 30 None, buildbucket_client.BuildbucketBuild(response['build']))) |
| 31 return results | 31 return results |
| 32 self.mock(buildbucket_client, 'TriggerTryJobs', Mocked_TriggerTryJobs) | 32 self.mock(buildbucket_client, 'TriggerTryJobs', Mocked_TriggerTryJobs) |
| 33 | 33 |
| 34 def testGetBuildPropertiesWithCompileTargets(self): | 34 def testGetBuildPropertiesWithCompileTargets(self): |
| 35 master_name = 'm' | 35 master_name = 'm' |
| 36 builder_name = 'b' | 36 builder_name = 'b' |
| 37 recipe = 'a/b/recipe' | |
| 38 compile_targets = ['a.exe'] | 37 compile_targets = ['a.exe'] |
| 39 | 38 |
| 40 expected_properties = { | 39 expected_properties = { |
| 41 'recipe': recipe, | 40 'recipe': 'findit/chromium/compile', |
| 42 'good_revision': 1, | 41 'good_revision': 1, |
| 43 'bad_revision': 2, | 42 'bad_revision': 2, |
| 44 'target_mastername': master_name, | 43 'target_mastername': master_name, |
| 45 'target_buildername': 'b', | 44 'target_buildername': 'b', |
| 46 'compile_targets': compile_targets | 45 'compile_targets': compile_targets |
| 47 } | 46 } |
| 48 try_job_pipeline = ScheduleTryJobPipeline() | 47 try_job_pipeline = ScheduleTryJobPipeline() |
| 49 properties = try_job_pipeline._getBuildProperties( | 48 properties = try_job_pipeline._getBuildProperties( |
| 50 recipe, master_name, builder_name, 1, 2, compile_targets) | 49 master_name, builder_name, 1, 2, 'compile', compile_targets, None) |
| 51 | 50 |
| 52 self.assertEqual(properties, expected_properties) | 51 self.assertEqual(properties, expected_properties) |
| 53 | 52 |
| 53 def testGetBuildPropertiesForTestFailure(self): |
| 54 master_name = 'm' |
| 55 builder_name = 'b' |
| 56 targeted_tests = {'a':[]} |
| 57 |
| 58 expected_properties = { |
| 59 'recipe': 'findit/chromium/test', |
| 60 'good_revision': 1, |
| 61 'bad_revision': 2, |
| 62 'target_mastername': master_name, |
| 63 'target_testername': 'b', |
| 64 'tests': targeted_tests |
| 65 } |
| 66 try_job_pipeline = ScheduleTryJobPipeline() |
| 67 properties = try_job_pipeline._getBuildProperties( |
| 68 master_name, builder_name, 1, 2, 'test', None, targeted_tests) |
| 69 |
| 70 self.assertEqual(properties, expected_properties) |
| 71 |
| 54 def testSuccessfullyScheduleNewTryJobForCompile(self): | 72 def testSuccessfullyScheduleNewTryJobForCompile(self): |
| 55 master_name = 'm' | 73 master_name = 'm' |
| 56 builder_name = 'b' | 74 builder_name = 'b' |
| 57 build_number = 223 | 75 build_number = 223 |
| 58 good_revision = 'rev1' | 76 good_revision = 'rev1' |
| 59 bad_revision = 'rev2' | 77 bad_revision = 'rev2' |
| 60 | 78 |
| 61 responses = [ | 79 responses = [ |
| 62 { | 80 { |
| 63 'build': { | 81 'build': { |
| 64 'id': '1', | 82 'id': '1', |
| 65 'url': 'url', | 83 'url': 'url', |
| 66 'status': 'SCHEDULED', | 84 'status': 'SCHEDULED', |
| 67 } | 85 } |
| 68 } | 86 } |
| 69 ] | 87 ] |
| 70 self._Mock_GetTrybotForWaterfallBuilder(master_name, builder_name) | 88 self._Mock_GetTrybotForWaterfallBuilder(master_name, builder_name) |
| 71 self._Mock_TriggerTryJobs(responses) | 89 self._Mock_TriggerTryJobs(responses) |
| 72 | 90 |
| 73 WfTryJob.Create(master_name, builder_name, build_number).put() | 91 WfTryJob.Create(master_name, builder_name, build_number).put() |
| 74 | 92 |
| 75 try_job_pipeline = ScheduleTryJobPipeline() | 93 try_job_pipeline = ScheduleTryJobPipeline() |
| 76 try_job_id = try_job_pipeline.run( | 94 try_job_id = try_job_pipeline.run( |
| 77 master_name, builder_name, build_number, good_revision, bad_revision, | 95 master_name, builder_name, build_number, good_revision, bad_revision, |
| 78 []) | 96 'compile', None) |
| 79 | 97 |
| 80 try_job = WfTryJob.Get(master_name, builder_name, build_number) | 98 try_job = WfTryJob.Get(master_name, builder_name, build_number) |
| 81 self.assertEqual('1', try_job_id) | 99 self.assertEqual('1', try_job_id) |
| 82 self.assertEqual('1', try_job.compile_results[-1]['try_job_id']) | 100 self.assertEqual('1', try_job.compile_results[-1]['try_job_id']) |
| 101 |
| 102 |
| 103 def testSuccessfullyScheduleNewTryJobForTest(self): |
| 104 master_name = 'm' |
| 105 builder_name = 'b' |
| 106 build_number = 223 |
| 107 good_revision = 'rev1' |
| 108 bad_revision = 'rev2' |
| 109 |
| 110 responses = [ |
| 111 { |
| 112 'build': { |
| 113 'id': '1', |
| 114 'url': 'url', |
| 115 'status': 'SCHEDULED', |
| 116 } |
| 117 } |
| 118 ] |
| 119 self._Mock_GetTrybotForWaterfallBuilder(master_name, builder_name) |
| 120 self._Mock_TriggerTryJobs(responses) |
| 121 |
| 122 WfTryJob.Create(master_name, builder_name, build_number).put() |
| 123 |
| 124 try_job_pipeline = ScheduleTryJobPipeline() |
| 125 try_job_id = try_job_pipeline.run( |
| 126 master_name, builder_name, build_number, good_revision, bad_revision, |
| 127 'test', None) |
| 128 |
| 129 try_job = WfTryJob.Get(master_name, builder_name, build_number) |
| 130 self.assertEqual('1', try_job_id) |
| 131 self.assertEqual('1', try_job.test_results[-1]['try_job_id']) |
| OLD | NEW |