| OLD | NEW |
| (Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from collections import defaultdict |
| 6 import logging |
| 7 |
| 8 from common.waterfall import failure_type |
| 9 from model.wf_try_job import WfTryJob |
| 10 from waterfall.schedule_try_job_pipeline import ScheduleTryJobPipeline |
| 11 |
| 12 |
| 13 def _GetTargetedTests(reliable_tests): |
| 14 targeted_tests = defaultdict(list) |
| 15 for step_reliable_tests in reliable_tests.itervalues(): |
| 16 step_name_no_platform = step_reliable_tests[0] |
| 17 tests = step_reliable_tests[1] |
| 18 if tests: |
| 19 targeted_tests[step_name_no_platform].extend(tests) |
| 20 return targeted_tests |
| 21 |
| 22 |
| 23 class ScheduleTestTryJobPipeline(ScheduleTryJobPipeline): |
| 24 """A pipeline for scheduling a new try job for failed test build.""" |
| 25 |
| 26 def _GetBuildProperties( |
| 27 self, master_name, builder_name, build_number, good_revision, |
| 28 bad_revision, try_job_type, suspected_revisions): |
| 29 properties = super(ScheduleTestTryJobPipeline, self)._GetBuildProperties( |
| 30 master_name, builder_name, build_number, good_revision, |
| 31 bad_revision, try_job_type, suspected_revisions) |
| 32 properties['target_testername'] = builder_name |
| 33 |
| 34 return properties |
| 35 |
| 36 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 37 def run( |
| 38 self, master_name, builder_name, build_number, good_revision, |
| 39 bad_revision, try_job_type, suspected_revisions, *reliable_tests): |
| 40 |
| 41 properties = self._GetBuildProperties( |
| 42 master_name, builder_name, build_number, good_revision, bad_revision, |
| 43 try_job_type, suspected_revisions) |
| 44 |
| 45 targeted_tests = _GetTargetedTests(dict(reliable_tests)) |
| 46 if not targeted_tests: # pragma: no cover |
| 47 logging.info('All tests are flaky, no try job will be triggered.') |
| 48 return |
| 49 |
| 50 additional_parameters = {'tests': targeted_tests} |
| 51 |
| 52 build_id = self._TriggerTryJob( |
| 53 master_name, builder_name, properties, additional_parameters) |
| 54 |
| 55 try_job_result = WfTryJob.Get(master_name, builder_name, build_number) |
| 56 try_job_result.test_results.append({'try_job_id': build_id}) |
| 57 try_job_result.try_job_ids.append(build_id) |
| 58 try_job_result.put() |
| 59 |
| 60 # Create a corresponding WfTryJobData entity to capture as much metadata as |
| 61 # early as possible. |
| 62 self._CreateTryJobData( |
| 63 build_id, master_name, builder_name, build_number, |
| 64 failure_type.GetDescriptionForFailureType(try_job_type), |
| 65 False, bool(suspected_revisions)) |
| 66 |
| 67 return build_id |
| OLD | NEW |