OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Dispatches tests, either sharding or replicating them. | 5 """Dispatches tests, either sharding or replicating them. |
6 | 6 |
7 Performs the following steps: | 7 Performs the following steps: |
8 * Create a test collection factory, using the given tests | 8 * Create a test collection factory, using the given tests |
9 - If sharding: test collection factory returns the same shared test collection | 9 - If sharding: test collection factory returns the same shared test collection |
10 to all test runners | 10 to all test runners |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 runner_factory: Callable that takes a device and index and returns a | 140 runner_factory: Callable that takes a device and index and returns a |
141 TestRunner object. | 141 TestRunner object. |
142 device: The device serial number to set up. | 142 device: The device serial number to set up. |
143 out_runners: List to add the successfully set up TestRunner object. | 143 out_runners: List to add the successfully set up TestRunner object. |
144 threadsafe_counter: A _ThreadSafeCounter object used to get shard indices. | 144 threadsafe_counter: A _ThreadSafeCounter object used to get shard indices. |
145 """ | 145 """ |
146 try: | 146 try: |
147 index = threadsafe_counter.GetAndIncrement() | 147 index = threadsafe_counter.GetAndIncrement() |
148 logging.warning('Creating shard %s for device %s.', index, device) | 148 logging.warning('Creating shard %s for device %s.', index, device) |
149 runner = runner_factory(device, index) | 149 runner = runner_factory(device, index) |
150 runner.SetUp() | 150 if runner: |
jbudorick
2016/06/07 00:27:26
Nit: remove the logging from the runner_factory an
rnephew (Reviews Here)
2016/06/07 00:40:31
Done.
| |
151 out_runners.append(runner) | 151 runner.SetUp() |
152 out_runners.append(runner) | |
152 except (device_errors.CommandFailedError, | 153 except (device_errors.CommandFailedError, |
153 device_errors.CommandTimeoutError, | 154 device_errors.CommandTimeoutError, |
154 device_errors.DeviceUnreachableError): | 155 device_errors.DeviceUnreachableError): |
155 logging.exception('Failed to create shard for %s', str(device)) | 156 logging.exception('Failed to create shard for %s', str(device)) |
156 | 157 |
157 | 158 |
158 def _RunAllTests(runners, test_collection_factory, num_retries, timeout=None, | 159 def _RunAllTests(runners, test_collection_factory, num_retries, timeout=None, |
159 tag_results_with_device=False): | 160 tag_results_with_device=False): |
160 """Run all tests using the given TestRunners. | 161 """Run all tests using the given TestRunners. |
161 | 162 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 try: | 331 try: |
331 return _RunAllTests(runners, test_collection_factory, | 332 return _RunAllTests(runners, test_collection_factory, |
332 num_retries, test_timeout, tag_results_with_device) | 333 num_retries, test_timeout, tag_results_with_device) |
333 finally: | 334 finally: |
334 try: | 335 try: |
335 _TearDownRunners(runners, setup_timeout) | 336 _TearDownRunners(runners, setup_timeout) |
336 except device_errors.DeviceUnreachableError as e: | 337 except device_errors.DeviceUnreachableError as e: |
337 logging.warning('Device unresponsive during TearDown: [%s]', e) | 338 logging.warning('Device unresponsive during TearDown: [%s]', e) |
338 except Exception: # pylint: disable=broad-except | 339 except Exception: # pylint: disable=broad-except |
339 logging.exception('Unexpected exception caught during TearDown') | 340 logging.exception('Unexpected exception caught during TearDown') |
OLD | NEW |