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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 import json | 47 import json |
48 import logging | 48 import logging |
49 import multiprocessing | 49 import multiprocessing |
50 import optparse | 50 import optparse |
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 import time |
57 | 58 |
58 from pylib import android_commands | 59 from pylib import android_commands |
59 from pylib import cmd_helper | 60 from pylib import cmd_helper |
60 from pylib import constants | 61 from pylib import constants |
61 from pylib import forwarder | 62 from pylib import forwarder |
62 from pylib import ports | 63 from pylib import ports |
63 | 64 |
64 | 65 |
65 _OUTPUT_DIR = os.path.join(constants.DIR_SOURCE_ROOT, 'out', 'step_results') | 66 _OUTPUT_DIR = os.path.join(constants.DIR_SOURCE_ROOT, 'out', 'step_results') |
66 | 67 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 for retry in range(5): | 168 for retry in range(5): |
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) |
| 178 # Restart the adb server with taskset to set a single CPU affinity. |
| 179 cmd_helper.RunCmd(['adb', 'kill-server']) |
| 180 cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'start-server']) |
| 181 cmd_helper.RunCmd(['taskset', '-c', '0', 'adb', 'root']) |
| 182 i = 1 |
| 183 while not android_commands.GetAttachedDevices(): |
| 184 time.sleep(i) |
| 185 i *= 2 |
| 186 if i > 10: |
| 187 break |
177 | 188 |
178 | 189 |
179 def main(argv): | 190 def main(argv): |
180 parser = optparse.OptionParser() | 191 parser = optparse.OptionParser() |
181 parser.add_option('-s', '--steps', | 192 parser.add_option('-s', '--steps', |
182 help='A JSON file containing all the steps to be ' | 193 help='A JSON file containing all the steps to be ' |
183 'sharded.') | 194 'sharded.') |
184 parser.add_option('--flaky_steps', | 195 parser.add_option('--flaky_steps', |
185 help='A JSON file containing steps that are flaky and ' | 196 help='A JSON file containing steps that are flaky and ' |
186 'will have its exit code ignored.') | 197 'will have its exit code ignored.') |
(...skipping 30 matching lines...) Expand all Loading... |
217 steps = json.load(f) | 228 steps = json.load(f) |
218 flaky_steps = [] | 229 flaky_steps = [] |
219 if options.flaky_steps: | 230 if options.flaky_steps: |
220 with file(options.flaky_steps, 'r') as f: | 231 with file(options.flaky_steps, 'r') as f: |
221 flaky_steps = json.load(f) | 232 flaky_steps = json.load(f) |
222 return _RunShardedSteps(steps, flaky_steps, devices) | 233 return _RunShardedSteps(steps, flaky_steps, devices) |
223 | 234 |
224 | 235 |
225 if __name__ == '__main__': | 236 if __name__ == '__main__': |
226 sys.exit(main(sys.argv)) | 237 sys.exit(main(sys.argv)) |
OLD | NEW |