Chromium Code Reviews| 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 common.pipeline_wrapper import BasePipeline | 5 from common.pipeline_wrapper import BasePipeline |
| 6 from common.pipeline_wrapper import pipeline | 6 from common.pipeline_wrapper import pipeline |
| 7 from common.waterfall import buildbucket_client | 7 from common.waterfall import buildbucket_client |
| 8 from model.wf_try_job import WfTryJob | 8 from model.wf_try_job import WfTryJob |
| 9 from model.wf_try_job_data import WfTryJobData | 9 from model.wf_try_job_data import WfTryJobData |
| 10 from waterfall import buildbot | 10 from waterfall import buildbot |
| 11 from waterfall import waterfall_config | 11 from waterfall import waterfall_config |
| 12 from waterfall.try_job_type import TryJobType | 12 from waterfall.try_job_type import TryJobType |
| 13 | 13 |
| 14 | 14 |
| 15 class ScheduleTryJobPipeline(BasePipeline): | 15 class ScheduleTryJobPipeline(BasePipeline): |
| 16 """A pipeline for scheduling a new try job for current build.""" | 16 """A pipeline for scheduling a new try job for current build.""" |
| 17 | 17 |
| 18 def _GetBuildProperties( | 18 def _GetBuildProperties( |
| 19 self, master_name, builder_name, build_number, good_revision, | 19 self, master_name, builder_name, build_number, good_revision, |
| 20 bad_revision, try_job_type, compile_targets, targeted_tests, | 20 bad_revision, try_job_type, compile_targets, suspected_revisions): |
| 21 suspected_revisions): | |
| 22 properties = { | 21 properties = { |
| 23 'recipe': 'findit/chromium/%s' % try_job_type, | 22 'recipe': 'findit/chromium/%s' % try_job_type, |
| 24 'good_revision': good_revision, | 23 'good_revision': good_revision, |
| 25 'bad_revision': bad_revision, | 24 'bad_revision': bad_revision, |
| 26 'target_mastername': master_name, | 25 'target_mastername': master_name, |
| 27 'referenced_build_url': buildbot.CreateBuildUrl( | 26 'referenced_build_url': buildbot.CreateBuildUrl( |
| 28 master_name, builder_name, build_number) | 27 master_name, builder_name, build_number) |
| 29 } | 28 } |
| 30 | 29 |
| 31 if try_job_type == TryJobType.COMPILE: | 30 if try_job_type == TryJobType.COMPILE: |
| 32 properties['target_buildername'] = builder_name | 31 properties['target_buildername'] = builder_name |
| 33 if compile_targets: | 32 if compile_targets: |
| 34 properties['compile_targets'] = compile_targets | 33 properties['compile_targets'] = compile_targets |
| 35 else: # try_job_type is 'test'. | 34 else: # try_job_type is 'test'. |
| 36 properties['target_testername'] = builder_name | 35 properties['target_testername'] = builder_name |
| 37 assert targeted_tests | |
| 38 properties['tests'] = targeted_tests | |
| 39 | 36 |
| 40 if suspected_revisions: | 37 if suspected_revisions: |
| 41 properties['suspected_revisions'] = suspected_revisions | 38 properties['suspected_revisions'] = suspected_revisions |
| 42 | 39 |
| 43 return properties | 40 return properties |
| 44 | 41 |
| 45 # Arguments number differs from overridden method - pylint: disable=W0221 | 42 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 46 def run( | 43 def run( |
| 47 self, master_name, builder_name, build_number, good_revision, | 44 self, master_name, builder_name, build_number, good_revision, |
| 48 bad_revision, try_job_type, compile_targets, targeted_tests, | 45 bad_revision, try_job_type, compile_targets, targeted_tests, |
| 49 suspected_revisions): | 46 suspected_revisions): |
| 50 tryserver_mastername, tryserver_buildername = ( | 47 tryserver_mastername, tryserver_buildername = ( |
| 51 waterfall_config.GetTrybotForWaterfallBuilder( | 48 waterfall_config.GetTrybotForWaterfallBuilder( |
| 52 master_name, builder_name)) | 49 master_name, builder_name)) |
| 53 | 50 |
| 54 properties = self._GetBuildProperties( | 51 properties = self._GetBuildProperties( |
| 55 master_name, builder_name, build_number, good_revision, bad_revision, | 52 master_name, builder_name, build_number, good_revision, bad_revision, |
| 56 try_job_type, compile_targets, targeted_tests, suspected_revisions) | 53 try_job_type, compile_targets, suspected_revisions) |
| 57 | 54 |
| 55 if try_job_type == TryJobType.COMPILE: | |
| 56 targeted_tests = {} | |
|
lijeffrey
2016/05/20 20:44:41
nit: add 1 newline after this
| |
| 58 try_job = buildbucket_client.TryJob( | 57 try_job = buildbucket_client.TryJob( |
| 59 tryserver_mastername, tryserver_buildername, None, properties, []) | 58 tryserver_mastername, tryserver_buildername, None, properties, |
| 59 targeted_tests, []) | |
| 60 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] | 60 error, build = buildbucket_client.TriggerTryJobs([try_job])[0] |
| 61 | 61 |
| 62 if error: # pragma: no cover | 62 if error: # pragma: no cover |
| 63 raise pipeline.Retry( | 63 raise pipeline.Retry( |
| 64 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) | 64 'Error "%s" occurred. Reason: "%s"' % (error.message, error.reason)) |
| 65 | 65 |
| 66 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) | 66 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) |
| 67 build_id = build.id | 67 build_id = build.id |
| 68 | 68 |
| 69 if try_job_type == TryJobType.COMPILE: | 69 if try_job_type == TryJobType.COMPILE: |
| 70 try_job_result.compile_results.append({'try_job_id': build_id}) | 70 try_job_result.compile_results.append({'try_job_id': build_id}) |
| 71 else: | 71 else: |
| 72 try_job_result.test_results.append({'try_job_id': build_id}) | 72 try_job_result.test_results.append({'try_job_id': build_id}) |
| 73 try_job_result.try_job_ids.append(build_id) | 73 try_job_result.try_job_ids.append(build_id) |
| 74 try_job_result.put() | 74 try_job_result.put() |
| 75 | 75 |
| 76 # Create a corresponding WfTryJobData entity to capture as much metadata as | 76 # Create a corresponding WfTryJobData entity to capture as much metadata as |
| 77 # early as possible. | 77 # early as possible. |
| 78 try_job_data = WfTryJobData.Create(build_id) | 78 try_job_data = WfTryJobData.Create(build_id) |
| 79 try_job_data.master_name = master_name | 79 try_job_data.master_name = master_name |
| 80 try_job_data.builder_name = builder_name | 80 try_job_data.builder_name = builder_name |
| 81 try_job_data.build_number = build_number | 81 try_job_data.build_number = build_number |
| 82 try_job_data.try_job_type = try_job_type | 82 try_job_data.try_job_type = try_job_type |
| 83 try_job_data.has_compile_targets = bool(compile_targets) | 83 try_job_data.has_compile_targets = bool(compile_targets) |
| 84 try_job_data.has_heuristic_results = bool(suspected_revisions) | 84 try_job_data.has_heuristic_results = bool(suspected_revisions) |
| 85 try_job_data.put() | 85 try_job_data.put() |
| 86 | 86 |
| 87 return build_id | 87 return build_id |
| OLD | NEW |