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: |
151 out_runners.append(runner) | 151 runner.SetUp() |
| 152 out_runners.append(runner) |
| 153 else: |
| 154 logging.info('Device %s is not active. Will not create shard %s.', |
| 155 str(device), index) |
152 except (device_errors.CommandFailedError, | 156 except (device_errors.CommandFailedError, |
153 device_errors.CommandTimeoutError, | 157 device_errors.CommandTimeoutError, |
154 device_errors.DeviceUnreachableError): | 158 device_errors.DeviceUnreachableError): |
155 logging.exception('Failed to create shard for %s', str(device)) | 159 logging.exception('Failed to create shard for %s', str(device)) |
156 | 160 |
157 | 161 |
158 def _RunAllTests(runners, test_collection_factory, num_retries, timeout=None, | 162 def _RunAllTests(runners, test_collection_factory, num_retries, timeout=None, |
159 tag_results_with_device=False): | 163 tag_results_with_device=False): |
160 """Run all tests using the given TestRunners. | 164 """Run all tests using the given TestRunners. |
161 | 165 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 try: | 334 try: |
331 return _RunAllTests(runners, test_collection_factory, | 335 return _RunAllTests(runners, test_collection_factory, |
332 num_retries, test_timeout, tag_results_with_device) | 336 num_retries, test_timeout, tag_results_with_device) |
333 finally: | 337 finally: |
334 try: | 338 try: |
335 _TearDownRunners(runners, setup_timeout) | 339 _TearDownRunners(runners, setup_timeout) |
336 except device_errors.DeviceUnreachableError as e: | 340 except device_errors.DeviceUnreachableError as e: |
337 logging.warning('Device unresponsive during TearDown: [%s]', e) | 341 logging.warning('Device unresponsive during TearDown: [%s]', e) |
338 except Exception: # pylint: disable=broad-except | 342 except Exception: # pylint: disable=broad-except |
339 logging.exception('Unexpected exception caught during TearDown') | 343 logging.exception('Unexpected exception caught during TearDown') |
OLD | NEW |