Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 import logging | 5 import logging |
| 6 | 6 |
| 7 from common.pipeline_wrapper import BasePipeline | 7 from common.pipeline_wrapper import BasePipeline |
| 8 from waterfall.process_swarming_task_result_pipeline import ( | 8 from waterfall.process_swarming_task_result_pipeline import ( |
| 9 ProcessSwarmingTaskResultPipeline) | 9 ProcessSwarmingTaskResultPipeline) |
| 10 from waterfall.run_try_job_for_reliable_failure_pipeline import ( | 10 from waterfall.run_try_job_for_reliable_failure_pipeline import ( |
| 11 RunTryJobForReliableFailurePipeline) | 11 RunTryJobForReliableFailurePipeline) |
| 12 from waterfall.trigger_swarming_task_pipeline import TriggerSwarmingTaskPipeline | 12 from waterfall.trigger_swarming_task_pipeline import TriggerSwarmingTaskPipeline |
| 13 from waterfall.try_job_type import TryJobType | 13 from waterfall.try_job_type import TryJobType |
| 14 | 14 |
| 15 | 15 |
| 16 _PRE_TEST_PREFIX = 'PRE_' | |
| 17 | |
| 18 | |
| 19 def _RemoveAnyPrefixes(tests): | |
| 20 """Remove prefixes from test names. | |
| 21 | |
| 22 Args: | |
| 23 tests (list): A list of tests, eg: ['suite1.PRE_test1', 'suite2.test2']. | |
| 24 | |
| 25 Returns: | |
| 26 base_tests (list): A list of base tests, eg: | |
| 27 ['suite1.test1', 'suite2.test2']. | |
| 28 """ | |
| 29 base_tests = [] | |
| 30 for test in tests: | |
| 31 test_name_start = test.find('.') if test.find('.') > -1 else 0 | |
| 32 test_suite = test[ : test_name_start] | |
| 33 test_name = test[test_name_start + 1 : ] | |
| 34 pre_position = test_name.find(_PRE_TEST_PREFIX) | |
| 35 while pre_position == 0: | |
| 36 test_name = test_name[len(_PRE_TEST_PREFIX):] | |
| 37 pre_position = test_name.find(_PRE_TEST_PREFIX) | |
| 38 base_tests.append(test_suite + '.' + test_name) | |
| 39 return base_tests | |
| 40 | |
| 41 | |
| 42 class SwarmingTasksToTryJobPipeline(BasePipeline): | 16 class SwarmingTasksToTryJobPipeline(BasePipeline): |
| 43 """Root Pipeline to start swarming tasks and possible try job on the build.""" | 17 """Root Pipeline to start swarming tasks and possible try job on the build.""" |
| 44 | 18 |
| 45 # Arguments number differs from overridden method - pylint: disable=W0221 | 19 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 46 def run( | 20 def run( |
| 47 self, master_name, builder_name, build_number, good_revision, | 21 self, master_name, builder_name, build_number, good_revision, |
| 48 bad_revision, blame_list, try_job_type, compile_targets=None, | 22 bad_revision, blame_list, try_job_type, compile_targets=None, |
| 49 targeted_tests=None, suspected_cls=None, force_try_job=False): | 23 targeted_tests=None, suspected_cls=None, force_try_job=False): |
| 50 | 24 |
| 51 # A list contains tuples of step_names and classified_tests from | 25 # A list contains tuples of step_names and classified_tests from |
| 52 # ProcessSwarmingTaskResultPipeline. | 26 # ProcessSwarmingTaskResultPipeline. |
| 53 # The format would be [('step1', {'flaky_tests': ['test1', ..], ..}), ..] | 27 # The format would be [('step1', {'flaky_tests': ['test1', ..], ..}), ..] |
| 54 classified_tests_by_step = [] | 28 classified_tests_by_step = [] |
| 55 targeted_base_tests = {} | |
| 56 | 29 |
| 57 if try_job_type == TryJobType.TEST: | 30 if try_job_type == TryJobType.TEST: |
| 58 for step_name, tests in targeted_tests.iteritems(): | 31 for step_name, base_tests in targeted_tests.iteritems(): |
| 59 base_tests = _RemoveAnyPrefixes(tests) | 32 if not base_tests: # Skip non-swarming tests. |
| 60 targeted_base_tests[step_name] = base_tests | |
| 61 | |
| 62 if not tests: # Skip non-swarming tests. | |
| 63 continue | 33 continue |
| 64 # Triggers swarming task for the base_tests. | 34 # Gets the swarming tasks' results. |
|
stgao
2016/07/12 17:47:49
nit: Also wait, right?
chanli
2016/07/12 20:04:52
Done.
| |
| 65 task_id = yield TriggerSwarmingTaskPipeline( | |
| 66 master_name, builder_name, build_number, step_name, base_tests) | |
| 67 step_future = yield ProcessSwarmingTaskResultPipeline( | 35 step_future = yield ProcessSwarmingTaskResultPipeline( |
| 68 master_name, builder_name, build_number, step_name, task_id) | 36 master_name, builder_name, build_number, step_name) |
| 69 logging_str = ( | |
| 70 'Swarming task was scheduled for build %s/%s/%s step %s') % ( | |
| 71 master_name, builder_name, build_number, step_name) | |
| 72 logging.info(logging_str) | |
| 73 classified_tests_by_step.append(step_future) | 37 classified_tests_by_step.append(step_future) |
| 74 | 38 |
| 75 # Waits until classified_tests_by_step are ready. | 39 # Waits until classified_tests_by_step are ready. |
| 76 yield RunTryJobForReliableFailurePipeline( | 40 yield RunTryJobForReliableFailurePipeline( |
| 77 master_name, builder_name, build_number, good_revision, | 41 master_name, builder_name, build_number, good_revision, |
| 78 bad_revision, blame_list, try_job_type, compile_targets, | 42 bad_revision, blame_list, try_job_type, compile_targets, |
| 79 targeted_base_tests, suspected_cls, force_try_job, | 43 targeted_tests, suspected_cls, force_try_job, |
| 80 *classified_tests_by_step) | 44 *classified_tests_by_step) |
| OLD | NEW |