| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 | 5 |
| 6 import logging | 6 import logging |
| 7 import multiprocessing | 7 import multiprocessing |
| 8 | 8 |
| 9 from pylib import android_commands | 9 from pylib import android_commands |
| 10 from pylib.base.test_result import TestResults | 10 from pylib.base.test_result import TestResults |
| 11 from pylib.forwarder import Forwarder | 11 from pylib.forwarder import Forwarder |
| 12 | 12 |
| 13 | 13 |
| 14 # Number of times we retry a test suite in case of failure. |
| 15 NUM_RETRIES = 3 |
| 16 |
| 17 |
| 14 def _ShardedTestRunnable(test): | 18 def _ShardedTestRunnable(test): |
| 15 """Standalone function needed by multiprocessing.Pool.""" | 19 """Standalone function needed by multiprocessing.Pool.""" |
| 16 log_format = '[' + test.device + '] # %(asctime)-15s: %(message)s' | 20 log_format = '[' + test.device + '] # %(asctime)-15s: %(message)s' |
| 17 if logging.getLogger().handlers: | 21 if logging.getLogger().handlers: |
| 18 logging.getLogger().handlers[0].setFormatter(logging.Formatter(log_format)) | 22 logging.getLogger().handlers[0].setFormatter(logging.Formatter(log_format)) |
| 19 else: | 23 else: |
| 20 logging.basicConfig(format=log_format) | 24 logging.basicConfig(format=log_format) |
| 21 # Handle SystemExit here since python has a bug to exit current process | 25 # Handle SystemExit here since python has a bug to exit current process |
| 22 try: | 26 try: |
| 23 return test.Run() | 27 return test.Run() |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 self.attached_devices = attached_devices | 51 self.attached_devices = attached_devices |
| 48 # Worst case scenario: a device will drop offline per run, so we need | 52 # Worst case scenario: a device will drop offline per run, so we need |
| 49 # to retry until we're out of devices. | 53 # to retry until we're out of devices. |
| 50 | 54 |
| 51 # TODO(frankf): There are two sources of flakiness: | 55 # TODO(frankf): There are two sources of flakiness: |
| 52 # 1. Device flakiness | 56 # 1. Device flakiness |
| 53 # 2. Test/product flakiness | 57 # 2. Test/product flakiness |
| 54 # We should differentiate between these. Otherwise, blindly retrying tests | 58 # We should differentiate between these. Otherwise, blindly retrying tests |
| 55 # might mask test/product flakiness. For type 2, we should follow the | 59 # might mask test/product flakiness. For type 2, we should follow the |
| 56 # general chrome best practices. | 60 # general chrome best practices. |
| 57 self.retries = len(self.attached_devices) | 61 self.retries = NUM_RETRIES |
| 58 self.tests = [] | 62 self.tests = [] |
| 59 self.build_type = build_type | 63 self.build_type = build_type |
| 60 | 64 |
| 61 def CreateShardedTestRunner(self, device, index): | 65 def CreateShardedTestRunner(self, device, index): |
| 62 """Factory function to create a suite-specific test runner. | 66 """Factory function to create a suite-specific test runner. |
| 63 | 67 |
| 64 Args: | 68 Args: |
| 65 device: Device serial where this shard will run | 69 device: Device serial where this shard will run |
| 66 index: Index of this device in the pool. | 70 index: Index of this device in the pool. |
| 67 | 71 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 for t in test_results.GetAllBroken(): | 151 for t in test_results.GetAllBroken(): |
| 148 self.tests += [t.name] | 152 self.tests += [t.name] |
| 149 if not self.tests: | 153 if not self.tests: |
| 150 break | 154 break |
| 151 else: | 155 else: |
| 152 # We ran out retries, possibly out of healthy devices. | 156 # We ran out retries, possibly out of healthy devices. |
| 153 # There's no recovery at this point. | 157 # There's no recovery at this point. |
| 154 raise Exception('Unrecoverable error while retrying test runs.') | 158 raise Exception('Unrecoverable error while retrying test runs.') |
| 155 self._KillHostForwarder() | 159 self._KillHostForwarder() |
| 156 return final_results | 160 return final_results |
| OLD | NEW |