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