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

Side by Side Diff: build/android/pylib/base_test_sharder.py

Issue 11232037: Retry tests on other bots if the device is unresponsive/offline (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: small improvement 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/single_test_runner.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) 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 logging 7 import logging
7 import multiprocessing 8 import multiprocessing
8 9
9 from test_result import TestResults 10 from test_result import TestResults
10 11
11 12
12 def _ShardedTestRunnable(test): 13 def _ShardedTestRunnable(test):
13 """Standalone function needed by multiprocessing.Pool.""" 14 """Standalone function needed by multiprocessing.Pool."""
14 log_format = '[' + test.device + '] # %(asctime)-15s: %(message)s' 15 log_format = '[' + test.device + '] # %(asctime)-15s: %(message)s'
15 if logging.getLogger().handlers: 16 if logging.getLogger().handlers:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 logging.warning('*' * 80) 80 logging.warning('*' * 80)
80 final_results = TestResults() 81 final_results = TestResults()
81 for retry in xrange(self.retries): 82 for retry in xrange(self.retries):
82 logging.warning('Try %d of %d', retry + 1, self.retries) 83 logging.warning('Try %d of %d', retry + 1, self.retries)
83 self.SetupSharding(self.tests) 84 self.SetupSharding(self.tests)
84 test_runners = [] 85 test_runners = []
85 for index, device in enumerate(self.attached_devices): 86 for index, device in enumerate(self.attached_devices):
86 logging.warning('*' * 80) 87 logging.warning('*' * 80)
87 logging.warning('Creating shard %d for %s', index, device) 88 logging.warning('Creating shard %d for %s', index, device)
88 logging.warning('*' * 80) 89 logging.warning('*' * 80)
89 test_runner = self.CreateShardedTestRunner(device, index) 90 test_runner = self.CreateShardedTestRunner(device, index)
Yaron 2012/10/26 18:48:44 Based on: http://build.chromium.org/p/chromium.lin
yongsheng 2012/10/28 01:41:03 yes, i don't try to catch exceptions here for i'm
bulach 2012/10/29 14:45:42 yaron: just to clarify, I kindly asked Yongsheng (
bulach 2012/10/29 14:51:23 btw, the issue mentioned above I guess is in run_t
90 test_runners += [test_runner] 91 test_runners += [test_runner]
91 logging.warning('Starting...') 92 logging.warning('Starting...')
92 pool = multiprocessing.Pool(len(self.attached_devices), 93 pool = multiprocessing.Pool(len(self.attached_devices),
93 SetTestsContainer, 94 SetTestsContainer,
94 [BaseTestSharder.tests_container]) 95 [BaseTestSharder.tests_container])
95 # map can't handle KeyboardInterrupt exception. It's a python bug. 96 # map can't handle KeyboardInterrupt exception. It's a python bug.
96 # So use map_async instead. 97 # So use map_async instead.
97 async_results = pool.map_async(_ShardedTestRunnable, test_runners) 98 async_results = pool.map_async(_ShardedTestRunnable, test_runners)
98 results_lists = async_results.get(999999) 99 results_lists = async_results.get(999999)
100
99 test_results = TestResults.FromTestResults(results_lists) 101 test_results = TestResults.FromTestResults(results_lists)
100 if retry == self.retries - 1: 102 # Re-check the attached devices for some devices may
103 # become offline
104 retry_devices = set(android_commands.GetAttachedDevices())
105 # Remove devices that had exceptions.
106 retry_devices -= TestResults.DeviceExceptions(results_lists)
107 # Retry on devices that didn't have any exception.
108 self.attached_devices = list(retry_devices)
109 if (retry == self.retries - 1 or
110 len(self.attached_devices) == 0):
101 all_passed = final_results.ok + test_results.ok 111 all_passed = final_results.ok + test_results.ok
102 final_results = test_results 112 final_results = test_results
103 final_results.ok = all_passed 113 final_results.ok = all_passed
104 break 114 break
105 else: 115 else:
106 final_results.ok += test_results.ok 116 final_results.ok += test_results.ok
107 self.tests = [] 117 self.tests = []
108 for t in test_results.GetAllBroken(): 118 for t in test_results.GetAllBroken():
109 self.tests += [t.name] 119 self.tests += [t.name]
110 if not self.tests: 120 if not self.tests:
111 break 121 break
112 self.OnTestsCompleted(test_runners, final_results) 122 self.OnTestsCompleted(test_runners, final_results)
113 return final_results 123 return final_results
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/single_test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698