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

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

Issue 17616008: Android: adds an option to print all sharded steps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « no previous file | no next file » | 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 file_name = os.path.join(_OUTPUT_DIR, step_name) 146 file_name = os.path.join(_OUTPUT_DIR, step_name)
147 if not os.path.exists(file_name): 147 if not os.path.exists(file_name):
148 print 'File not found ', file_name 148 print 'File not found ', file_name
149 return 1 149 return 1
150 with file(file_name, 'r') as f: 150 with file(file_name, 'r') as f:
151 result = pickle.loads(f.read()) 151 result = pickle.loads(f.read())
152 print result['output'] 152 print result['output']
153 return result['exit_code'] 153 return result['exit_code']
154 154
155 155
156 def _PrintAllStepsOutput(steps):
157 with file(steps, 'r') as f:
158 steps = json.load(f)
159 ret = 0
160 for step_name in steps.keys():
161 ret += _PrintStepOutput(step_name)
iannucci 2013/06/25 02:16:33 what's the meaning of adding the retcodes together
bulach 2013/06/28 01:54:27 good point! done.
162 return ret
163
164
156 def _KillPendingServers(): 165 def _KillPendingServers():
157 for retry in range(5): 166 for retry in range(5):
158 for server in ['lighttpd', 'web-page-replay']: 167 for server in ['lighttpd', 'web-page-replay']:
159 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) 168 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server])
160 pids = [pid.strip() for pid in pids.split('\n') if pid.strip()] 169 pids = [pid.strip() for pid in pids.split('\n') if pid.strip()]
161 for pid in pids: 170 for pid in pids:
162 try: 171 try:
163 logging.warning('Killing %s %s', server, pid) 172 logging.warning('Killing %s %s', server, pid)
164 os.kill(int(pid), signal.SIGQUIT) 173 os.kill(int(pid), signal.SIGQUIT)
165 except Exception as e: 174 except Exception as e:
166 logging.warning('Failed killing %s %s %s', server, pid, e) 175 logging.warning('Failed killing %s %s %s', server, pid, e)
167 176
168 177
169 def main(argv): 178 def main(argv):
170 parser = optparse.OptionParser() 179 parser = optparse.OptionParser()
171 parser.add_option('-s', '--steps', 180 parser.add_option('-s', '--steps',
172 help='A JSON file containing all the steps to be ' 181 help='A JSON file containing all the steps to be '
173 'sharded.') 182 'sharded.')
174 parser.add_option('--flaky_steps', 183 parser.add_option('--flaky_steps',
175 help='A JSON file containing steps that are flaky and ' 184 help='A JSON file containing steps that are flaky and '
176 'will have its exit code ignored.') 185 'will have its exit code ignored.')
177 parser.add_option('-p', '--print_results', 186 parser.add_option('-p', '--print_results',
178 help='Only prints the results for the previously ' 187 help='Only prints the results for the previously '
179 'executed step, do not run it again.') 188 'executed step, do not run it again.')
189 parser.add_option('-P', '--print_all',
190 help='Only prints the results for the previously '
191 'executed steps, do not run them again.')
180 options, urls = parser.parse_args(argv) 192 options, urls = parser.parse_args(argv)
181 if options.print_results: 193 if options.print_results:
182 return _PrintStepOutput(options.print_results) 194 return _PrintStepOutput(options.print_results)
195 if options.print_all:
196 return _PrintAllStepsOutput(options.print_all)
183 197
184 # At this point, we should kill everything that may have been left over from 198 # At this point, we should kill everything that may have been left over from
185 # previous runs. 199 # previous runs.
186 _KillPendingServers() 200 _KillPendingServers()
187 201
188 # Reset the test port allocation. It's important to do it before starting 202 # Reset the test port allocation. It's important to do it before starting
189 # to dispatch any step. 203 # to dispatch any step.
190 if not ports.ResetTestServerPortAllocation(): 204 if not ports.ResetTestServerPortAllocation():
191 raise Exception('Failed to reset test server port.') 205 raise Exception('Failed to reset test server port.')
192 206
193 # Sort the devices so that we'll try to always run a step in the same device. 207 # Sort the devices so that we'll try to always run a step in the same device.
194 devices = sorted(android_commands.GetAttachedDevices()) 208 devices = sorted(android_commands.GetAttachedDevices())
195 if not devices: 209 if not devices:
196 print 'You must attach a device' 210 print 'You must attach a device'
197 return 1 211 return 1
198 212
199 with file(options.steps, 'r') as f: 213 with file(options.steps, 'r') as f:
200 steps = json.load(f) 214 steps = json.load(f)
201 flaky_steps = [] 215 flaky_steps = []
202 if options.flaky_steps: 216 if options.flaky_steps:
203 with file(options.flaky_steps, 'r') as f: 217 with file(options.flaky_steps, 'r') as f:
204 flaky_steps = json.load(f) 218 flaky_steps = json.load(f)
205 return _RunShardedSteps(steps, flaky_steps, devices) 219 return _RunShardedSteps(steps, flaky_steps, devices)
206 220
207 221
208 if __name__ == '__main__': 222 if __name__ == '__main__':
209 sys.exit(main(sys.argv)) 223 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698