| 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 copy | 5 import copy |
| 6 import logging | 6 import logging |
| 7 import time | 7 import time |
| 8 | 8 |
| 9 from common.http_client_appengine import HttpClientAppengine as HttpClient | 9 from common.http_client_appengine import HttpClientAppengine as HttpClient |
| 10 from common.pipeline_wrapper import BasePipeline | 10 from common.pipeline_wrapper import BasePipeline |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 """ | 22 """ |
| 23 | 23 |
| 24 def _GetSwarmingTaskName(self, ref_task_id): # pragma: no cover. | 24 def _GetSwarmingTaskName(self, ref_task_id): # pragma: no cover. |
| 25 return 'findit/deflake/ref_task_id/%s/%s' % ( | 25 return 'findit/deflake/ref_task_id/%s/%s' % ( |
| 26 ref_task_id, time_util.GetUTCNow().strftime('%Y-%m-%d %H:%M:%S %f')) | 26 ref_task_id, time_util.GetUTCNow().strftime('%Y-%m-%d %H:%M:%S %f')) |
| 27 | 27 |
| 28 def _CreateNewSwarmingTaskRequest(self, ref_task_id, ref_request, master_name, | 28 def _CreateNewSwarmingTaskRequest(self, ref_task_id, ref_request, master_name, |
| 29 builder_name, build_number, step_name, | 29 builder_name, build_number, step_name, |
| 30 tests, iterations): | 30 tests, iterations): |
| 31 """Returns a SwarmingTaskRequest instance to run the given tests only.""" | 31 """Returns a SwarmingTaskRequest instance to run the given tests only.""" |
| 32 | |
| 33 # Make a copy of the referred request and drop or overwrite some fields. | 32 # Make a copy of the referred request and drop or overwrite some fields. |
| 34 new_request = copy.deepcopy(ref_request) | 33 new_request = copy.deepcopy(ref_request) |
| 35 new_request.name = self._GetSwarmingTaskName(ref_task_id) | 34 new_request.name = self._GetSwarmingTaskName(ref_task_id) |
| 36 new_request.parent_task_id = '' | 35 new_request.parent_task_id = '' |
| 37 new_request.user = '' | 36 new_request.user = '' |
| 38 | 37 |
| 39 # To force a fresh re-run and ignore cached result of any equivalent run. | 38 # To force a fresh re-run and ignore cached result of any equivalent run. |
| 40 new_request.idempotent = False | 39 new_request.idempotent = False |
| 41 | 40 |
| 42 # Set the gtest_filter to run the given tests only. | 41 # Set the gtest_filter to run the given tests only. |
| 43 # Remove existing test filter first. | 42 # Remove existing test filter first. |
| 44 new_request.extra_args = [ | 43 new_request.extra_args = [ |
| 45 a for a in new_request.extra_args if ( | 44 a for a in new_request.extra_args if ( |
| 46 not a.startswith('--gtest_filter') and | 45 not a.startswith('--gtest_filter') and |
| 47 not a.startswith('--test-launcher-filter-file')) | 46 not a.startswith('--test-launcher-filter-file')) |
| 48 ] | 47 ] |
| 49 new_request.extra_args.append('--gtest_filter=%s' % ':'.join(tests)) | 48 new_request.extra_args.append('--gtest_filter=%s' % ':'.join(tests)) |
| 49 |
| 50 # On Android, --gtest_repeat is only supported for gtest, but not for other |
| 51 # test types. E.g. instrumentation tests currently support it via |
| 52 # --test-repeat. |
| 53 # |
| 54 # Here we blindly treat all tests on Android as gtest, and let other test |
| 55 # types fail out, because it is hard to distinguish them programmatically |
| 56 # while the majority is gtest. |
| 57 # |
| 58 # https://crbug.com/669632 tracks the effort to unify the command switches |
| 59 # of the Android test runner that are used here. |
| 50 new_request.extra_args.append('--gtest_repeat=%s' % iterations) | 60 new_request.extra_args.append('--gtest_repeat=%s' % iterations) |
| 51 new_request.extra_args.append('--test-launcher-retry-limit=0') | 61 |
| 62 ref_os = swarming_util.GetTagValue(ref_request.tags, 'os') or '' |
| 63 if ref_os.lower() == 'android': # Workaround. pragma: no cover. |
| 64 new_request.extra_args.append('--num_retries=0') |
| 65 else: |
| 66 new_request.extra_args.append('--test-launcher-retry-limit=0') |
| 52 | 67 |
| 53 # Also rerun disabled tests. Scenario: the test was disabled before Findit | 68 # Also rerun disabled tests. Scenario: the test was disabled before Findit |
| 54 # runs any analysis. One possible case: | 69 # runs any analysis. One possible case: |
| 55 # 1. A gtest became flaky on CQ, but Findit was not automatically | 70 # 1. A gtest became flaky on CQ, but Findit was not automatically |
| 56 # triggered to run any analysis because: | 71 # triggered to run any analysis because: |
| 57 # * the test is not flaky enough | 72 # * the test is not flaky enough |
| 58 # * chromium-try-flakes has filed/updated too many bugs | 73 # * chromium-try-flakes has filed/updated too many bugs |
| 59 # 2. The test got disabled, but no culprit was identified. | 74 # 2. The test got disabled, but no culprit was identified. |
| 60 # 3. Some developer starts the investigation and requests Findit to | 75 # 3. Some developer starts the investigation and requests Findit to |
| 61 # analyze the flaky test. | 76 # analyze the flaky test. |
| 62 # 4. Findit picks the latest Waterfall build of the matching configuration | 77 # 4. Findit picks the latest Waterfall build of the matching configuration |
| 63 # for the CQ build in which the flaky test is found. | 78 # for the CQ build in which the flaky test is found. |
| 64 # 5. In the picked Waterfall build, the test is already disabled. | 79 # 5. In the picked Waterfall build, the test is already disabled. |
| 80 # |
| 81 # Note: test runner on Android ignores this flag because it is not supported |
| 82 # yet even though it exists. |
| 65 new_request.extra_args.append('--gtest_also_run_disabled_tests') | 83 new_request.extra_args.append('--gtest_also_run_disabled_tests') |
| 66 | 84 |
| 67 # Remove the env setting for sharding. | 85 # Remove the env setting for sharding. |
| 68 sharding_settings = ['GTEST_SHARD_INDEX', 'GTEST_TOTAL_SHARDS'] | 86 sharding_settings = ['GTEST_SHARD_INDEX', 'GTEST_TOTAL_SHARDS'] |
| 69 new_request.env = [ | 87 new_request.env = [ |
| 70 e for e in new_request.env if e['key'] not in sharding_settings | 88 e for e in new_request.env if e['key'] not in sharding_settings |
| 71 ] | 89 ] |
| 72 | 90 |
| 73 # Reset tags for searching and monitoring. | 91 # Reset tags for searching and monitoring. |
| 74 ref_name = swarming_util.GetTagValue(ref_request.tags, 'name') | 92 ref_name = swarming_util.GetTagValue(ref_request.tags, 'name') |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 swarming_task.error = error | 221 swarming_task.error = error |
| 204 else: | 222 else: |
| 205 logging.info('A Swarming task was triggered:%s', task_id) | 223 logging.info('A Swarming task was triggered:%s', task_id) |
| 206 | 224 |
| 207 swarming_task.put() | 225 swarming_task.put() |
| 208 | 226 |
| 209 # Call the hook function after the task is triggered. | 227 # Call the hook function after the task is triggered. |
| 210 self._OnTaskTriggered() | 228 self._OnTaskTriggered() |
| 211 | 229 |
| 212 return task_id | 230 return task_id |
| OLD | NEW |