| 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 |  | 
| 58 | 57 | 
| 59 from pylib import android_commands | 58 from pylib import android_commands | 
| 60 from pylib import cmd_helper | 59 from pylib import cmd_helper | 
| 61 from pylib import constants | 60 from pylib import constants | 
| 62 from pylib import forwarder | 61 from pylib import forwarder | 
| 63 from pylib import ports | 62 from pylib import ports | 
| 64 | 63 | 
| 65 | 64 | 
| 66 _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') | 
| 67 | 66 | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 168   for retry in range(5): | 167   for retry in range(5): | 
| 169     for server in ['lighttpd', 'web-page-replay']: | 168     for server in ['lighttpd', 'web-page-replay']: | 
| 170       pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) | 169       pids = cmd_helper.GetCmdOutput(['pgrep', '-f', server]) | 
| 171       pids = [pid.strip() for pid in pids.split('\n') if pid.strip()] | 170       pids = [pid.strip() for pid in pids.split('\n') if pid.strip()] | 
| 172       for pid in pids: | 171       for pid in pids: | 
| 173         try: | 172         try: | 
| 174           logging.warning('Killing %s %s', server, pid) | 173           logging.warning('Killing %s %s', server, pid) | 
| 175           os.kill(int(pid), signal.SIGQUIT) | 174           os.kill(int(pid), signal.SIGQUIT) | 
| 176         except Exception as e: | 175         except Exception as e: | 
| 177           logging.warning('Failed killing %s %s %s', server, pid, e) | 176           logging.warning('Failed killing %s %s %s', server, pid, e) | 
| 178   # Restart the adb server with full trace, and redirect stderr to stdout |  | 
| 179   # so the extra tracing won't confuse higher up layers. |  | 
| 180   os.environ['ADB_TRACE'] = 'all' |  | 
| 181   cmd_helper.RunCmd(['adb', 'kill-server']) |  | 
| 182   cmd_helper.RunCmd(['adb', 'start-server']) |  | 
| 183   cmd_helper.RunCmd(['adb', 'root']) |  | 
| 184   i = 1 |  | 
| 185   while not android_commands.GetAttachedDevices(): |  | 
| 186     time.sleep(i) |  | 
| 187     i *= 2 |  | 
| 188     if i > 10: |  | 
| 189       break |  | 
| 190 | 177 | 
| 191 | 178 | 
| 192 def main(argv): | 179 def main(argv): | 
| 193   parser = optparse.OptionParser() | 180   parser = optparse.OptionParser() | 
| 194   parser.add_option('-s', '--steps', | 181   parser.add_option('-s', '--steps', | 
| 195                     help='A JSON file containing all the steps to be ' | 182                     help='A JSON file containing all the steps to be ' | 
| 196                          'sharded.') | 183                          'sharded.') | 
| 197   parser.add_option('--flaky_steps', | 184   parser.add_option('--flaky_steps', | 
| 198                     help='A JSON file containing steps that are flaky and ' | 185                     help='A JSON file containing steps that are flaky and ' | 
| 199                          'will have its exit code ignored.') | 186                          'will have its exit code ignored.') | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 230     steps = json.load(f) | 217     steps = json.load(f) | 
| 231   flaky_steps = [] | 218   flaky_steps = [] | 
| 232   if options.flaky_steps: | 219   if options.flaky_steps: | 
| 233     with file(options.flaky_steps, 'r') as f: | 220     with file(options.flaky_steps, 'r') as f: | 
| 234       flaky_steps = json.load(f) | 221       flaky_steps = json.load(f) | 
| 235   return _RunShardedSteps(steps, flaky_steps, devices) | 222   return _RunShardedSteps(steps, flaky_steps, devices) | 
| 236 | 223 | 
| 237 | 224 | 
| 238 if __name__ == '__main__': | 225 if __name__ == '__main__': | 
| 239   sys.exit(main(sys.argv)) | 226   sys.exit(main(sys.argv)) | 
| OLD | NEW | 
|---|