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 """Takes care of sharding the python-drive tests in multiple devices.""" | 5 """Takes care of sharding the python-drive tests in multiple devices.""" |
6 | 6 |
7 import copy | 7 import copy |
8 import logging | 8 import logging |
9 import multiprocessing | 9 import multiprocessing |
10 | 10 |
11 from pylib.base import base_test_result | 11 from pylib.base import base_test_result |
12 from pylib.base import sharded_tests_queue | 12 from pylib.base import sharded_tests_queue |
| 13 from pylib.forwarder import Forwarder |
13 | 14 |
14 from python_test_caller import CallPythonTest | 15 from python_test_caller import CallPythonTest |
15 | 16 |
16 | 17 |
17 def SetTestsContainer(tests_container): | 18 def SetTestsContainer(tests_container): |
18 """Sets PythonTestSharder as a top-level field. | 19 """Sets PythonTestSharder as a top-level field. |
19 | 20 |
20 PythonTestSharder uses multiprocessing.Pool, which creates a pool of | 21 PythonTestSharder uses multiprocessing.Pool, which creates a pool of |
21 processes. This is used to initialize each worker in the pool, ensuring that | 22 processes. This is used to initialize each worker in the pool, ensuring that |
22 each worker has access to this shared pool of tests. | 23 each worker has access to this shared pool of tests. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 A list of test results aggregated from all test runs. | 114 A list of test results aggregated from all test runs. |
114 """ | 115 """ |
115 logging.warning('*' * 80) | 116 logging.warning('*' * 80) |
116 logging.warning('Sharding in ' + str(len(self.attached_devices)) + | 117 logging.warning('Sharding in ' + str(len(self.attached_devices)) + |
117 ' devices.') | 118 ' devices.') |
118 logging.warning('Note that the output is not synchronized.') | 119 logging.warning('Note that the output is not synchronized.') |
119 logging.warning('Look for the "Final result" banner in the end.') | 120 logging.warning('Look for the "Final result" banner in the end.') |
120 logging.warning('*' * 80) | 121 logging.warning('*' * 80) |
121 final_results = base_test_result.TestRunResults() | 122 final_results = base_test_result.TestRunResults() |
122 tests_to_run = self.tests | 123 tests_to_run = self.tests |
| 124 |
| 125 Forwarder.KillHost() |
| 126 |
123 for retry in xrange(self.retries): | 127 for retry in xrange(self.retries): |
124 logging.warning('Try %d of %d', retry + 1, self.retries) | 128 logging.warning('Try %d of %d', retry + 1, self.retries) |
125 self._SetupSharding(self.tests) | 129 self._SetupSharding(self.tests) |
126 test_runners = self._MakeTestRunners(self.attached_devices) | 130 test_runners = self._MakeTestRunners(self.attached_devices) |
127 logging.warning('Starting...') | 131 logging.warning('Starting...') |
128 pool = multiprocessing.Pool(len(self.attached_devices), | 132 pool = multiprocessing.Pool(len(self.attached_devices), |
129 SetTestsContainer, | 133 SetTestsContainer, |
130 [PythonTestSharder.tests_container]) | 134 [PythonTestSharder.tests_container]) |
131 | 135 |
132 # List of TestRunResults objects from each test execution. | 136 # List of TestRunResults objects from each test execution. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 available_tests: a list of tests which subclass PythonTestBase. | 194 available_tests: a list of tests which subclass PythonTestBase. |
191 failed_test_names: a list of failed test names. | 195 failed_test_names: a list of failed test names. |
192 | 196 |
193 Returns: | 197 Returns: |
194 A list of test objects which correspond to test names found in | 198 A list of test objects which correspond to test names found in |
195 failed_test_names, or an empty list if there is no correspondence. | 199 failed_test_names, or an empty list if there is no correspondence. |
196 """ | 200 """ |
197 tests_to_retry = [t for t in available_tests | 201 tests_to_retry = [t for t in available_tests |
198 if t.qualified_name in failed_test_names] | 202 if t.qualified_name in failed_test_names] |
199 return tests_to_retry | 203 return tests_to_retry |
OLD | NEW |