| 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 android_commands | 6 import android_commands |
| 7 import logging | 7 import logging |
| 8 import multiprocessing | 8 import multiprocessing |
| 9 | 9 |
| 10 from android_commands import errors | 10 from android_commands import errors |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 device: Device serial where this shard will run | 59 device: Device serial where this shard will run |
| 60 index: Index of this device in the pool. | 60 index: Index of this device in the pool. |
| 61 | 61 |
| 62 Returns: | 62 Returns: |
| 63 An object of BaseTestRunner type (that can provide a "Run()" method). | 63 An object of BaseTestRunner type (that can provide a "Run()" method). |
| 64 """ | 64 """ |
| 65 pass | 65 pass |
| 66 | 66 |
| 67 def SetupSharding(self, tests): | 67 def SetupSharding(self, tests): |
| 68 """Called before starting the shards.""" | 68 """Called before starting the shards.""" |
| 69 Forwarder.KillHost(self.build_type) | 69 pass |
| 70 | 70 |
| 71 def OnTestsCompleted(self, test_runners, test_results): | 71 def OnTestsCompleted(self, test_runners, test_results): |
| 72 """Notifies that we completed the tests.""" | 72 """Notifies that we completed the tests.""" |
| 73 pass |
| 74 |
| 75 def _KillHostForwarder(self): |
| 73 Forwarder.KillHost(self.build_type) | 76 Forwarder.KillHost(self.build_type) |
| 74 | 77 |
| 75 def RunShardedTests(self): | 78 def RunShardedTests(self): |
| 76 """Runs the tests in all connected devices. | 79 """Runs the tests in all connected devices. |
| 77 | 80 |
| 78 Returns: | 81 Returns: |
| 79 A TestResults object. | 82 A TestResults object. |
| 80 """ | 83 """ |
| 81 logging.warning('*' * 80) | 84 logging.warning('*' * 80) |
| 82 logging.warning('Sharding in ' + str(len(self.attached_devices)) + | 85 logging.warning('Sharding in ' + str(len(self.attached_devices)) + |
| 83 ' devices.') | 86 ' devices.') |
| 84 logging.warning('Note that the output is not synchronized.') | 87 logging.warning('Note that the output is not synchronized.') |
| 85 logging.warning('Look for the "Final result" banner in the end.') | 88 logging.warning('Look for the "Final result" banner in the end.') |
| 86 logging.warning('*' * 80) | 89 logging.warning('*' * 80) |
| 87 final_results = TestResults() | 90 final_results = TestResults() |
| 91 self._KillHostForwarder() |
| 88 for retry in xrange(self.retries): | 92 for retry in xrange(self.retries): |
| 89 logging.warning('Try %d of %d', retry + 1, self.retries) | 93 logging.warning('Try %d of %d', retry + 1, self.retries) |
| 90 self.SetupSharding(self.tests) | 94 self.SetupSharding(self.tests) |
| 91 test_runners = [] | 95 test_runners = [] |
| 92 | 96 |
| 93 # Try to create N shards, and retrying on failure. | 97 # Try to create N shards, and retrying on failure. |
| 94 try: | 98 try: |
| 95 for index, device in enumerate(self.attached_devices): | 99 for index, device in enumerate(self.attached_devices): |
| 96 logging.warning('*' * 80) | 100 logging.warning('*' * 80) |
| 97 logging.warning('Creating shard %d for %s', index, device) | 101 logging.warning('Creating shard %d for %s', index, device) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 self.tests = [] | 139 self.tests = [] |
| 136 for t in test_results.GetAllBroken(): | 140 for t in test_results.GetAllBroken(): |
| 137 self.tests += [t.name] | 141 self.tests += [t.name] |
| 138 if not self.tests: | 142 if not self.tests: |
| 139 break | 143 break |
| 140 else: | 144 else: |
| 141 # We ran out retries, possibly out of healthy devices. | 145 # We ran out retries, possibly out of healthy devices. |
| 142 # There's no recovery at this point. | 146 # There's no recovery at this point. |
| 143 raise Exception('Unrecoverable error while retrying test runs.') | 147 raise Exception('Unrecoverable error while retrying test runs.') |
| 144 self.OnTestsCompleted(test_runners, final_results) | 148 self.OnTestsCompleted(test_runners, final_results) |
| 149 self._KillHostForwarder() |
| 145 return final_results | 150 return final_results |
| OLD | NEW |