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

Unified Diff: build/android/pylib/base_test_sharder.py

Issue 11275078: Android: improves test sharding reliability. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/run_tests.py » ('j') | build/android/run_tests.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/base_test_sharder.py
diff --git a/build/android/pylib/base_test_sharder.py b/build/android/pylib/base_test_sharder.py
index 5306769155050ba032364650daeecaa1581e609b..1418cf0f6fd0d1b296ef3db41d0a6dd7b88c83a5 100644
--- a/build/android/pylib/base_test_sharder.py
+++ b/build/android/pylib/base_test_sharder.py
@@ -7,6 +7,7 @@ import android_commands
import logging
import multiprocessing
+from android_commands import errors
from test_result import TestResults
@@ -43,7 +44,9 @@ class BaseTestSharder(object):
def __init__(self, attached_devices):
self.attached_devices = attached_devices
- self.retries = 1
+ # Worst case scenario: a device will drop offline per run, so we need
+ # to retry until we're out of devices.
+ self.retries = len(self.attached_devices)
self.tests = []
def CreateShardedTestRunner(self, device, index):
@@ -83,12 +86,20 @@ class BaseTestSharder(object):
logging.warning('Try %d of %d', retry + 1, self.retries)
self.SetupSharding(self.tests)
test_runners = []
- for index, device in enumerate(self.attached_devices):
- logging.warning('*' * 80)
- logging.warning('Creating shard %d for %s', index, device)
- logging.warning('*' * 80)
- test_runner = self.CreateShardedTestRunner(device, index)
- test_runners += [test_runner]
+
+ # Try to create N shards, and retrying on failure.
+ try:
Yaron 2012/10/31 17:18:51 Shouldn't this try be in the for loop? |device| is
bulach 2012/10/31 18:10:35 not really.. we need to create all shards at once,
+ for index, device in enumerate(self.attached_devices):
+ logging.warning('*' * 80)
+ logging.warning('Creating shard %d for %s', index, device)
+ logging.warning('*' * 80)
+ test_runner = self.CreateShardedTestRunner(device, index)
+ test_runners += [test_runner]
+ except errors.DeviceUnresponsiveError as e:
+ logging.critical('****Failed to create a shard: [%s]', e)
+ self.attached_devices.remove(device)
+ continue
Yaron 2012/10/31 17:18:51 By continuing, we're not updating |final_results|.
bulach 2012/10/31 18:10:35 this continue here would be for the loop on 85, so
Yaron 2012/10/31 18:37:23 Yes. My point was though that it looks like it's d
bulach 2012/10/31 19:18:17 ahn, yes, good point! I added an else: clause to r
+
logging.warning('Starting...')
pool = multiprocessing.Pool(len(self.attached_devices),
SetTestsContainer,
@@ -96,8 +107,12 @@ class BaseTestSharder(object):
# map can't handle KeyboardInterrupt exception. It's a python bug.
# So use map_async instead.
async_results = pool.map_async(_ShardedTestRunnable, test_runners)
- results_lists = async_results.get(999999)
-
+ try:
+ results_lists = async_results.get(999999)
Yaron 2012/10/31 17:18:51 Will the exception get thrown while the other shar
bulach 2012/10/31 18:10:35 it's not clear from the python documentation if th
Yaron 2012/10/31 18:37:23 Ah, right. Thanks.
+ except errors.DeviceUnresponsiveError as e:
+ logging.critical('****Failed to run test: [%s]', e)
+ self.attached_devices = android_commands.GetAttachedDevices()
+ continue
test_results = TestResults.FromTestResults(results_lists)
# Re-check the attached devices for some devices may
# become offline
« no previous file with comments | « no previous file | build/android/run_tests.py » ('j') | build/android/run_tests.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698