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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 import pexpect | 51 import pexpect |
52 import pickle | 52 import pickle |
53 import os | 53 import os |
54 import signal | 54 import signal |
55 import shutil | 55 import shutil |
56 import sys | 56 import sys |
57 | 57 |
58 from pylib import android_commands | 58 from pylib import android_commands |
59 from pylib import cmd_helper | 59 from pylib import cmd_helper |
60 from pylib import constants | 60 from pylib import constants |
| 61 from pylib import forwarder |
61 from pylib import ports | 62 from pylib import ports |
62 | 63 |
63 | 64 |
64 _OUTPUT_DIR = os.path.join(constants.DIR_SOURCE_ROOT, 'out', 'step_results') | 65 _OUTPUT_DIR = os.path.join(constants.DIR_SOURCE_ROOT, 'out', 'step_results') |
65 | 66 |
66 | 67 |
67 def _SaveResult(result): | 68 def _SaveResult(result): |
68 with file(os.path.join(_OUTPUT_DIR, result['name']), 'w') as f: | 69 with file(os.path.join(_OUTPUT_DIR, result['name']), 'w') as f: |
69 f.write(pickle.dumps(result)) | 70 f.write(pickle.dumps(result)) |
70 | 71 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 with file(steps, 'r') as f: | 158 with file(steps, 'r') as f: |
158 steps = json.load(f) | 159 steps = json.load(f) |
159 ret = 0 | 160 ret = 0 |
160 for step_name in steps.keys(): | 161 for step_name in steps.keys(): |
161 ret |= _PrintStepOutput(step_name) | 162 ret |= _PrintStepOutput(step_name) |
162 return ret | 163 return ret |
163 | 164 |
164 | 165 |
165 def _KillPendingServers(): | 166 def _KillPendingServers(): |
166 for retry in range(5): | 167 for retry in range(5): |
| 168 forwarder.Forwarder.KillHost() |
167 for server in ['lighttpd', 'web-page-replay']: | 169 for server in ['lighttpd', 'web-page-replay']: |
168 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) | 170 pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) |
169 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()] |
170 for pid in pids: | 172 for pid in pids: |
171 try: | 173 try: |
172 logging.warning('Killing %s %s', server, pid) | 174 logging.warning('Killing %s %s', server, pid) |
173 os.kill(int(pid), signal.SIGQUIT) | 175 os.kill(int(pid), signal.SIGQUIT) |
174 except Exception as e: | 176 except Exception as e: |
175 logging.warning('Failed killing %s %s %s', server, pid, e) | 177 logging.warning('Failed killing %s %s %s', server, pid, e) |
176 | 178 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 steps = json.load(f) | 216 steps = json.load(f) |
215 flaky_steps = [] | 217 flaky_steps = [] |
216 if options.flaky_steps: | 218 if options.flaky_steps: |
217 with file(options.flaky_steps, 'r') as f: | 219 with file(options.flaky_steps, 'r') as f: |
218 flaky_steps = json.load(f) | 220 flaky_steps = json.load(f) |
219 return _RunShardedSteps(steps, flaky_steps, devices) | 221 return _RunShardedSteps(steps, flaky_steps, devices) |
220 | 222 |
221 | 223 |
222 if __name__ == '__main__': | 224 if __name__ == '__main__': |
223 sys.exit(main(sys.argv)) | 225 sys.exit(main(sys.argv)) |
OLD | NEW |