Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: build/android/pylib/base/shard.py

Issue 13799010: [Android] Reduce test logging verbosity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/cmd_helper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 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 """Implements test sharding logic.""" 5 """Implements test sharding logic."""
6 6
7 import logging 7 import logging
8 import threading 8 import threading
9 9
10 from pylib import android_commands 10 from pylib import android_commands
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 msg = 'Device %s is unresponsive.' % runner.device 136 msg = 'Device %s is unresponsive.' % runner.device
137 logging.warning(msg) 137 logging.warning(msg)
138 raise android_commands.errors.DeviceUnresponsiveError(msg) 138 raise android_commands.errors.DeviceUnresponsiveError(msg)
139 result, retry = runner.RunTest(test.test) 139 result, retry = runner.RunTest(test.test)
140 test.tries += 1 140 test.tries += 1
141 if retry and test.tries <= 3: 141 if retry and test.tries <= 3:
142 # Retry non-passing results, only record passing results. 142 # Retry non-passing results, only record passing results.
143 pass_results = base_test_result.TestRunResults() 143 pass_results = base_test_result.TestRunResults()
144 pass_results.AddResults(result.GetPass()) 144 pass_results.AddResults(result.GetPass())
145 out_results.append(pass_results) 145 out_results.append(pass_results)
146 logging.warning('****Will retry test, try #%s.' % test.tries) 146 logging.warning('Will retry test, try #%s.' % test.tries)
147 test_collection.add(_Test(test=retry, tries=test.tries)) 147 test_collection.add(_Test(test=retry, tries=test.tries))
148 else: 148 else:
149 # All tests passed or retry limit reached. Either way, record results. 149 # All tests passed or retry limit reached. Either way, record results.
150 out_results.append(result) 150 out_results.append(result)
151 except android_commands.errors.DeviceUnresponsiveError: 151 except android_commands.errors.DeviceUnresponsiveError:
152 # Device is unresponsive, stop handling tests on this device and ensure 152 # Device is unresponsive, stop handling tests on this device and ensure
153 # current test gets runs by another device. Don't reraise this exception 153 # current test gets runs by another device. Don't reraise this exception
154 # on the main thread. 154 # on the main thread.
155 test_collection.add(test) 155 test_collection.add(test)
156 return 156 return
(...skipping 15 matching lines...) Expand all
172 172
173 Args: 173 Args:
174 runner_factory: callable that takes a device and index and returns a 174 runner_factory: callable that takes a device and index and returns a
175 TestRunner object. 175 TestRunner object.
176 device: the device serial number to set up. 176 device: the device serial number to set up.
177 out_runners: list to add the successfully set up TestRunner object. 177 out_runners: list to add the successfully set up TestRunner object.
178 threadsafe_counter: a _ThreadSafeCounter object used to get shard indices. 178 threadsafe_counter: a _ThreadSafeCounter object used to get shard indices.
179 """ 179 """
180 try: 180 try:
181 index = threadsafe_counter.GetAndIncrement() 181 index = threadsafe_counter.GetAndIncrement()
182 logging.warning('*****Creating shard %s for device %s.', index, device) 182 logging.warning('Creating shard %s for device %s.', index, device)
183 runner = runner_factory(device, index) 183 runner = runner_factory(device, index)
184 runner.SetUp() 184 runner.SetUp()
185 out_runners.append(runner) 185 out_runners.append(runner)
186 except android_commands.errors.DeviceUnresponsiveError as e: 186 except android_commands.errors.DeviceUnresponsiveError as e:
187 logging.warning('****Failed to create shard for %s: [%s]', device, e) 187 logging.warning('Failed to create shard for %s: [%s]', device, e)
188 188
189 189
190 def _RunAllTests(runners, tests, timeout=None): 190 def _RunAllTests(runners, tests, timeout=None):
191 """Run all tests using the given TestRunners. 191 """Run all tests using the given TestRunners.
192 192
193 Args: 193 Args:
194 runners: a list of TestRunner objects. 194 runners: a list of TestRunner objects.
195 tests: a list of Tests to run using the given TestRunners. 195 tests: a list of Tests to run using the given TestRunners.
196 timeout: watchdog timeout in seconds, defaults to the default timeout. 196 timeout: watchdog timeout in seconds, defaults to the default timeout.
197 197
198 Returns: 198 Returns:
199 A TestRunResults object. 199 A TestRunResults object.
200 """ 200 """
201 logging.warning('****Running %s tests with %s test runners.' % 201 logging.warning('Running %s tests with %s test runners.' %
202 (len(tests), len(runners))) 202 (len(tests), len(runners)))
203 tests_collection = _TestCollection([_Test(t) for t in tests]) 203 tests_collection = _TestCollection([_Test(t) for t in tests])
204 results = [] 204 results = []
205 watcher = watchdog_timer.WatchdogTimer(timeout) 205 watcher = watchdog_timer.WatchdogTimer(timeout)
206 workers = reraiser_thread.ReraiserThreadGroup( 206 workers = reraiser_thread.ReraiserThreadGroup(
207 [reraiser_thread.ReraiserThread(_RunTestsFromQueue, 207 [reraiser_thread.ReraiserThread(_RunTestsFromQueue,
208 [r, tests_collection, results, watcher], 208 [r, tests_collection, results, watcher],
209 name=r.device[-4:]) 209 name=r.device[-4:])
210 for r in runners]) 210 for r in runners])
211 workers.StartAll() 211 workers.StartAll()
(...skipping 12 matching lines...) Expand all
224 224
225 Args: 225 Args:
226 runner_factory: callable that takes a device and index and returns a 226 runner_factory: callable that takes a device and index and returns a
227 TestRunner object. 227 TestRunner object.
228 devices: list of device serial numbers as strings. 228 devices: list of device serial numbers as strings.
229 timeout: watchdog timeout in seconds, defaults to the default timeout. 229 timeout: watchdog timeout in seconds, defaults to the default timeout.
230 230
231 Returns: 231 Returns:
232 A list of TestRunner objects. 232 A list of TestRunner objects.
233 """ 233 """
234 logging.warning('****Creating %s test runners.' % len(devices)) 234 logging.warning('Creating %s test runners.' % len(devices))
235 runners = [] 235 runners = []
236 counter = _ThreadSafeCounter() 236 counter = _ThreadSafeCounter()
237 threads = reraiser_thread.ReraiserThreadGroup( 237 threads = reraiser_thread.ReraiserThreadGroup(
238 [reraiser_thread.ReraiserThread(_SetUp, 238 [reraiser_thread.ReraiserThread(_SetUp,
239 [runner_factory, d, runners, counter], 239 [runner_factory, d, runners, counter],
240 name=d[-4:]) 240 name=d[-4:])
241 for d in devices]) 241 for d in devices])
242 threads.StartAll() 242 threads.StartAll()
243 threads.JoinAll(watchdog_timer.WatchdogTimer(timeout)) 243 threads.JoinAll(watchdog_timer.WatchdogTimer(timeout))
244 return runners 244 return runners
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 A base_test_result.TestRunResults object. 277 A base_test_result.TestRunResults object.
278 """ 278 """
279 forwarder.Forwarder.KillHost(build_type) 279 forwarder.Forwarder.KillHost(build_type)
280 runners = _CreateRunners(runner_factory, devices, setup_timeout) 280 runners = _CreateRunners(runner_factory, devices, setup_timeout)
281 try: 281 try:
282 return _RunAllTests(runners, tests, test_timeout) 282 return _RunAllTests(runners, tests, test_timeout)
283 finally: 283 finally:
284 try: 284 try:
285 _TearDownRunners(runners, setup_timeout) 285 _TearDownRunners(runners, setup_timeout)
286 except android_commands.errors.DeviceUnresponsiveError as e: 286 except android_commands.errors.DeviceUnresponsiveError as e:
287 logging.warning('****Device unresponsive during TearDown: [%s]', e) 287 logging.warning('Device unresponsive during TearDown: [%s]', e)
288 finally: 288 finally:
289 forwarder.Forwarder.KillHost(build_type) 289 forwarder.Forwarder.KillHost(build_type)
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/cmd_helper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698