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

Side by Side Diff: build/android/bb_run_sharded_steps.py

Issue 20824008: Reland r212020: Move Python setup/tear down logic into Forwarder ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Close unused FDs Created 7 years, 4 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/adb_reverse_forwarder.py ('k') | build/android/pylib/base/base_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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Helper script to shard build bot steps and save results to disk. 7 """Helper script to shard build bot steps and save results to disk.
8 8
9 Our buildbot infrastructure requires each slave to run steps serially. 9 Our buildbot infrastructure requires each slave to run steps serially.
10 This is sub-optimal for android, where these steps can run independently on 10 This is sub-optimal for android, where these steps can run independently on
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 with file(steps, 'r') as f: 158 with file(steps, 'r') as f:
159 steps = json.load(f) 159 steps = json.load(f)
160 ret = 0 160 ret = 0
161 for step_name in steps.keys(): 161 for step_name in steps.keys():
162 ret |= _PrintStepOutput(step_name) 162 ret |= _PrintStepOutput(step_name)
163 return ret 163 return ret
164 164
165 165
166 def _KillPendingServers(): 166 def _KillPendingServers():
167 for retry in range(5): 167 for retry in range(5):
168 forwarder.Forwarder.KillHost()
169 for server in ['lighttpd', 'web-page-replay']: 168 for server in ['lighttpd', 'web-page-replay']:
170 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) 169 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server])
171 pids = [pid.strip() for pid in pids.split('\n') if pid.strip()] 170 pids = [pid.strip() for pid in pids.split('\n') if pid.strip()]
172 for pid in pids: 171 for pid in pids:
173 try: 172 try:
174 logging.warning('Killing %s %s', server, pid) 173 logging.warning('Killing %s %s', server, pid)
175 os.kill(int(pid), signal.SIGQUIT) 174 os.kill(int(pid), signal.SIGQUIT)
176 except Exception as e: 175 except Exception as e:
177 logging.warning('Failed killing %s %s %s', server, pid, e) 176 logging.warning('Failed killing %s %s %s', server, pid, e)
178 177
(...skipping 15 matching lines...) Expand all
194 options, urls = parser.parse_args(argv) 193 options, urls = parser.parse_args(argv)
195 if options.print_results: 194 if options.print_results:
196 return _PrintStepOutput(options.print_results) 195 return _PrintStepOutput(options.print_results)
197 if options.print_all: 196 if options.print_all:
198 return _PrintAllStepsOutput(options.print_all) 197 return _PrintAllStepsOutput(options.print_all)
199 198
200 # At this point, we should kill everything that may have been left over from 199 # At this point, we should kill everything that may have been left over from
201 # previous runs. 200 # previous runs.
202 _KillPendingServers() 201 _KillPendingServers()
203 202
203 forwarder.Forwarder.UseMultiprocessing()
204
204 # Reset the test port allocation. It's important to do it before starting 205 # Reset the test port allocation. It's important to do it before starting
205 # to dispatch any step. 206 # to dispatch any step.
206 if not ports.ResetTestServerPortAllocation(): 207 if not ports.ResetTestServerPortAllocation():
207 raise Exception('Failed to reset test server port.') 208 raise Exception('Failed to reset test server port.')
208 209
209 # Sort the devices so that we'll try to always run a step in the same device. 210 # Sort the devices so that we'll try to always run a step in the same device.
210 devices = sorted(android_commands.GetAttachedDevices()) 211 devices = sorted(android_commands.GetAttachedDevices())
211 if not devices: 212 if not devices:
212 print 'You must attach a device' 213 print 'You must attach a device'
213 return 1 214 return 1
214 215
215 with file(options.steps, 'r') as f: 216 with file(options.steps, 'r') as f:
216 steps = json.load(f) 217 steps = json.load(f)
217 flaky_steps = [] 218 flaky_steps = []
218 if options.flaky_steps: 219 if options.flaky_steps:
219 with file(options.flaky_steps, 'r') as f: 220 with file(options.flaky_steps, 'r') as f:
220 flaky_steps = json.load(f) 221 flaky_steps = json.load(f)
221 return _RunShardedSteps(steps, flaky_steps, devices) 222 return _RunShardedSteps(steps, flaky_steps, devices)
222 223
223 224
224 if __name__ == '__main__': 225 if __name__ == '__main__':
225 sys.exit(main(sys.argv)) 226 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/adb_reverse_forwarder.py ('k') | build/android/pylib/base/base_test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698