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 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, this is only supported for gtest, but not for other test | |
|
chanli
2016/11/29 23:11:49
Nit: 'this' is a little ambiguous here, maybe chan
stgao
2016/11/30 00:26:27
Good catch. Done.
| |
| 51 # types. E.g. instrumentation tests currently support it via --test-repeat. | |
| 52 # Here we blindly treat all tests on Android as gtest, and let other test | |
| 53 # types fail out, because it is hard to distinguish them programmatically. | |
| 54 # | |
| 55 # https://crbug.com/669632 tracks the effort to unify the command switches | |
| 56 # of the Android test runner that are used here. | |
| 50 new_request.extra_args.append('--gtest_repeat=%s' % iterations) | 57 new_request.extra_args.append('--gtest_repeat=%s' % iterations) |
| 51 new_request.extra_args.append('--test-launcher-retry-limit=0') | 58 |
| 59 ref_os = swarming_util.GetTagValue(ref_request.tags, 'os') or '' | |
| 60 if ref_os.lower() == 'android': # Workaround. pragma: no cover. | |
| 61 new_request.extra_args.append('--num_retries=0') | |
| 62 else: | |
| 63 new_request.extra_args.append('--test-launcher-retry-limit=0') | |
| 52 | 64 |
| 53 # Also rerun disabled tests. Scenario: the test was disabled before Findit | 65 # Also rerun disabled tests. Scenario: the test was disabled before Findit |
| 54 # runs any analysis. One possible case: | 66 # runs any analysis. One possible case: |
| 55 # 1. A gtest became flaky on CQ, but Findit was not automatically | 67 # 1. A gtest became flaky on CQ, but Findit was not automatically |
| 56 # triggered to run any analysis because: | 68 # triggered to run any analysis because: |
| 57 # * the test is not flaky enough | 69 # * the test is not flaky enough |
| 58 # * chromium-try-flakes has filed/updated too many bugs | 70 # * chromium-try-flakes has filed/updated too many bugs |
| 59 # 2. The test got disabled, but no culprit was identified. | 71 # 2. The test got disabled, but no culprit was identified. |
| 60 # 3. Some developer starts the investigation and requests Findit to | 72 # 3. Some developer starts the investigation and requests Findit to |
| 61 # analyze the flaky test. | 73 # analyze the flaky test. |
| 62 # 4. Findit picks the latest Waterfall build of the matching configuration | 74 # 4. Findit picks the latest Waterfall build of the matching configuration |
| 63 # for the CQ build in which the flaky test is found. | 75 # for the CQ build in which the flaky test is found. |
| 64 # 5. In the picked Waterfall build, the test is already disabled. | 76 # 5. In the picked Waterfall build, the test is already disabled. |
| 77 # | |
| 78 # Note: test runner on Android doesn't support this flag yet even though it | |
| 79 # exists. | |
|
chanli
2016/11/29 23:11:49
Question: If this flag is not supported on Android
stgao
2016/11/30 00:26:27
Ignored. Comments updated.
| |
| 65 new_request.extra_args.append('--gtest_also_run_disabled_tests') | 80 new_request.extra_args.append('--gtest_also_run_disabled_tests') |
| 66 | 81 |
| 67 # Remove the env setting for sharding. | 82 # Remove the env setting for sharding. |
| 68 sharding_settings = ['GTEST_SHARD_INDEX', 'GTEST_TOTAL_SHARDS'] | 83 sharding_settings = ['GTEST_SHARD_INDEX', 'GTEST_TOTAL_SHARDS'] |
| 69 new_request.env = [ | 84 new_request.env = [ |
| 70 e for e in new_request.env if e['key'] not in sharding_settings | 85 e for e in new_request.env if e['key'] not in sharding_settings |
| 71 ] | 86 ] |
| 72 | 87 |
| 73 # Reset tags for searching and monitoring. | 88 # Reset tags for searching and monitoring. |
| 74 ref_name = swarming_util.GetTagValue(ref_request.tags, 'name') | 89 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 | 218 swarming_task.error = error |
| 204 else: | 219 else: |
| 205 logging.info('A Swarming task was triggered:%s', task_id) | 220 logging.info('A Swarming task was triggered:%s', task_id) |
| 206 | 221 |
| 207 swarming_task.put() | 222 swarming_task.put() |
| 208 | 223 |
| 209 # Call the hook function after the task is triggered. | 224 # Call the hook function after the task is triggered. |
| 210 self._OnTaskTriggered() | 225 self._OnTaskTriggered() |
| 211 | 226 |
| 212 return task_id | 227 return task_id |
| OLD | NEW |