| OLD | NEW |
| 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 Loading... |
| 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() |
| 168 for server in ['lighttpd', 'web-page-replay']: | 169 for server in ['lighttpd', 'web-page-replay']: |
| 169 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) | 170 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) |
| 170 pids = [pid.strip() for pid in pids.split('\n') if pid.strip()] | 171 pids = [pid.strip() for pid in pids.split('\n') if pid.strip()] |
| 171 for pid in pids: | 172 for pid in pids: |
| 172 try: | 173 try: |
| 173 logging.warning('Killing %s %s', server, pid) | 174 logging.warning('Killing %s %s', server, pid) |
| 174 os.kill(int(pid), signal.SIGQUIT) | 175 os.kill(int(pid), signal.SIGQUIT) |
| 175 except Exception as e: | 176 except Exception as e: |
| 176 logging.warning('Failed killing %s %s %s', server, pid, e) | 177 logging.warning('Failed killing %s %s %s', server, pid, e) |
| 177 | 178 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 193 options, urls = parser.parse_args(argv) | 194 options, urls = parser.parse_args(argv) |
| 194 if options.print_results: | 195 if options.print_results: |
| 195 return _PrintStepOutput(options.print_results) | 196 return _PrintStepOutput(options.print_results) |
| 196 if options.print_all: | 197 if options.print_all: |
| 197 return _PrintAllStepsOutput(options.print_all) | 198 return _PrintAllStepsOutput(options.print_all) |
| 198 | 199 |
| 199 # At this point, we should kill everything that may have been left over from | 200 # At this point, we should kill everything that may have been left over from |
| 200 # previous runs. | 201 # previous runs. |
| 201 _KillPendingServers() | 202 _KillPendingServers() |
| 202 | 203 |
| 203 forwarder.Forwarder.UseMultiprocessing() | |
| 204 | |
| 205 # Reset the test port allocation. It's important to do it before starting | 204 # Reset the test port allocation. It's important to do it before starting |
| 206 # to dispatch any step. | 205 # to dispatch any step. |
| 207 if not ports.ResetTestServerPortAllocation(): | 206 if not ports.ResetTestServerPortAllocation(): |
| 208 raise Exception('Failed to reset test server port.') | 207 raise Exception('Failed to reset test server port.') |
| 209 | 208 |
| 210 # Sort the devices so that we'll try to always run a step in the same device. | 209 # Sort the devices so that we'll try to always run a step in the same device. |
| 211 devices = sorted(android_commands.GetAttachedDevices()) | 210 devices = sorted(android_commands.GetAttachedDevices()) |
| 212 if not devices: | 211 if not devices: |
| 213 print 'You must attach a device' | 212 print 'You must attach a device' |
| 214 return 1 | 213 return 1 |
| 215 | 214 |
| 216 with file(options.steps, 'r') as f: | 215 with file(options.steps, 'r') as f: |
| 217 steps = json.load(f) | 216 steps = json.load(f) |
| 218 flaky_steps = [] | 217 flaky_steps = [] |
| 219 if options.flaky_steps: | 218 if options.flaky_steps: |
| 220 with file(options.flaky_steps, 'r') as f: | 219 with file(options.flaky_steps, 'r') as f: |
| 221 flaky_steps = json.load(f) | 220 flaky_steps = json.load(f) |
| 222 return _RunShardedSteps(steps, flaky_steps, devices) | 221 return _RunShardedSteps(steps, flaky_steps, devices) |
| 223 | 222 |
| 224 | 223 |
| 225 if __name__ == '__main__': | 224 if __name__ == '__main__': |
| 226 sys.exit(main(sys.argv)) | 225 sys.exit(main(sys.argv)) |
| OLD | NEW |