| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 threads = [ | 181 threads = [ |
| 182 reraiser_thread.ReraiserThread( | 182 reraiser_thread.ReraiserThread( |
| 183 _RunTestsFromQueue, | 183 _RunTestsFromQueue, |
| 184 [r, tc, results, watcher, num_retries, tag_results_with_device], | 184 [r, tc, results, watcher, num_retries, tag_results_with_device], |
| 185 name=r.device_serial[-4:]) | 185 name=r.device_serial[-4:]) |
| 186 for r, tc in zip(runners, test_collections)] | 186 for r, tc in zip(runners, test_collections)] |
| 187 | 187 |
| 188 workers = reraiser_thread.ReraiserThreadGroup(threads) | 188 workers = reraiser_thread.ReraiserThreadGroup(threads) |
| 189 workers.StartAll() | 189 workers.StartAll() |
| 190 | 190 |
| 191 # Catch DeviceUnreachableErrors and set a warning exit code | |
| 192 try: | 191 try: |
| 193 workers.JoinAll(watcher) | 192 workers.JoinAll(watcher) |
| 194 except device_errors.DeviceUnreachableError as e: | 193 except device_errors.CommandFailedError: |
| 195 logging.error(e) | 194 logging.exception('Command failed on device.') |
| 195 except device_errors.CommandFailedError: |
| 196 logging.exception('Command timed out on device.') |
| 197 except device_errors.DeviceUnreachableError: |
| 198 logging.exception('Device became unreachable.') |
| 196 | 199 |
| 197 if not all((len(tc) == 0 for tc in test_collections)): | 200 if not all((len(tc) == 0 for tc in test_collections)): |
| 198 logging.error('Only ran %d tests (all devices are likely offline).' % | 201 logging.error('Only ran %d tests (all devices are likely offline).' % |
| 199 len(results)) | 202 len(results)) |
| 200 for tc in test_collections: | 203 for tc in test_collections: |
| 201 run_results.AddResults(base_test_result.BaseTestResult( | 204 run_results.AddResults(base_test_result.BaseTestResult( |
| 202 t, base_test_result.ResultType.UNKNOWN) for t in tc.test_names()) | 205 t, base_test_result.ResultType.UNKNOWN) for t in tc.test_names()) |
| 203 | 206 |
| 204 for r in results: | 207 for r in results: |
| 205 run_results.AddTestRunResults(r) | 208 run_results.AddTestRunResults(r) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 try: | 326 try: |
| 324 return _RunAllTests(runners, test_collection_factory, | 327 return _RunAllTests(runners, test_collection_factory, |
| 325 num_retries, test_timeout, tag_results_with_device) | 328 num_retries, test_timeout, tag_results_with_device) |
| 326 finally: | 329 finally: |
| 327 try: | 330 try: |
| 328 _TearDownRunners(runners, setup_timeout) | 331 _TearDownRunners(runners, setup_timeout) |
| 329 except device_errors.DeviceUnreachableError as e: | 332 except device_errors.DeviceUnreachableError as e: |
| 330 logging.warning('Device unresponsive during TearDown: [%s]', e) | 333 logging.warning('Device unresponsive during TearDown: [%s]', e) |
| 331 except Exception as e: | 334 except Exception as e: |
| 332 logging.error('Unexpected exception caught during TearDown: %s' % str(e)) | 335 logging.error('Unexpected exception caught during TearDown: %s' % str(e)) |
| OLD | NEW |