OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 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 import collections | 7 import collections |
8 import copy | 8 import copy |
9 import json | 9 import json |
10 import optparse | 10 import optparse |
11 import os | 11 import os |
12 import pipes | 12 import pipes |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
17 from pylib import buildbot_report | 17 from pylib import buildbot_report |
18 | 18 |
19 CHROME_SRC = os.path.abspath( | 19 CHROME_SRC = os.path.abspath( |
20 os.path.join(os.path.dirname(__file__), '..', '..', '..')) | 20 os.path.join(os.path.dirname(__file__), '..', '..', '..')) |
21 | 21 |
22 GLOBAL_SLAVE_PROPS = {} | 22 GLOBAL_SLAVE_PROPS = {} |
23 | 23 |
24 BotConfig = collections.namedtuple( | 24 BotConfig = collections.namedtuple( |
25 'BotConfig', ['bot_id', 'bash_funs', 'test_obj', 'slave_props']) | 25 'BotConfig', ['bot_id', 'bash_funs', 'host_obj', 'test_obj', 'slave_props']) |
| 26 HostConfig = collections.namedtuple('HostConfig', ['steps', 'extra_args']) |
26 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args']) | 27 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args']) |
27 Command = collections.namedtuple( | 28 Command = collections.namedtuple( |
28 'Command', ['step_name', 'command', 'testing_cmd']) | 29 'Command', ['step_name', 'command', 'testing_cmd']) |
29 | 30 |
30 | 31 |
31 def GetCommands(options, bot_config): | 32 def GetCommands(options, bot_config): |
32 """Get a formatted list of commands. | 33 """Get a formatted list of commands. |
33 | 34 |
34 Args: | 35 Args: |
35 options: Options object. | 36 options: Options object. |
36 bot_config: A BotConfig named tuple. | 37 bot_config: A BotConfig named tuple. |
37 Returns: | 38 Returns: |
38 list of Command objects. | 39 list of Command objects. |
39 """ | 40 """ |
40 slave_props = dict(GLOBAL_SLAVE_PROPS) | 41 slave_props = dict(GLOBAL_SLAVE_PROPS) |
41 if bot_config.slave_props: | 42 if bot_config.slave_props: |
42 slave_props.update(bot_config.slave_props) | 43 slave_props.update(bot_config.slave_props) |
43 | 44 |
44 property_args = [ | 45 property_args = [ |
45 '--factory-properties=%s' % json.dumps(options.factory_properties), | 46 '--factory-properties=%s' % json.dumps(options.factory_properties), |
46 '--build-properties=%s' % json.dumps(options.build_properties), | 47 '--build-properties=%s' % json.dumps(options.build_properties), |
47 '--slave-properties=%s' % json.dumps(slave_props)] | 48 '--slave-properties=%s' % json.dumps(slave_props)] |
48 | 49 |
49 commands = [] | 50 common_cmd = ['; '.join(['. build/android/buildbot/buildbot_functions.sh', |
50 def WrapWithBash(command): | 51 'bb_baseline_setup %s %s' % ( |
51 """Wrap a bash command string with envsetup scripts.""" | 52 CHROME_SRC, |
52 return ['bash', '-exc', '; '.join([ | 53 ' '.join(map(pipes.quote, property_args)))])] |
53 '. build/android/buildbot/buildbot_functions.sh', | 54 |
54 'bb_baseline_setup %s %s' % ( | 55 commands = [Command('Preparation', common_cmd, None)] |
55 CHROME_SRC, | |
56 ' '.join(map(pipes.quote, property_args))), | |
57 command]) | |
58 ] | |
59 | 56 |
60 if bot_config.bash_funs: | 57 if bot_config.bash_funs: |
61 # bash_funs command does not have a testing mode. | 58 # bash_funs command does not have a testing mode. |
62 commands.append( | 59 commands.append(Command(None, ['; '.join(bot_config.bash_funs)], None)) |
63 Command(None, WrapWithBash('; '.join(bot_config.bash_funs)), None)) | 60 |
| 61 host_obj = bot_config.host_obj |
| 62 if host_obj: |
| 63 host_cmd = [ |
| 64 'build/android/buildbot/bb_host_steps.py'] + property_args[0:2] |
| 65 if host_obj.steps: |
| 66 host_cmd.append('--steps=%s' % ','.join(host_obj.steps)) |
| 67 if host_obj.extra_args: |
| 68 host_cmd += host_obj.extra_args |
| 69 cmd = ' '.join(map(pipes.quote, host_cmd)) |
| 70 commands.append(Command('Host steps', [cmd], [cmd])) |
64 | 71 |
65 test_obj = bot_config.test_obj | 72 test_obj = bot_config.test_obj |
66 if test_obj: | 73 if test_obj: |
67 run_test_cmd = [ | 74 run_test_cmd = [ |
68 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args | 75 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args |
69 for test in test_obj.tests: | 76 for test in test_obj.tests: |
70 run_test_cmd.extend(['-f', test]) | 77 run_test_cmd.extend(['-f', test]) |
71 if test_obj.extra_args: | 78 if test_obj.extra_args: |
72 run_test_cmd.extend(test_obj.extra_args) | 79 run_test_cmd.extend(test_obj.extra_args) |
73 commands.append(Command( | 80 cmd = ' '.join(map(pipes.quote, run_test_cmd)) |
74 'Run tests', | 81 commands.append(Command('Run tests', [cmd], [cmd])) |
75 WrapWithBash(' '.join(map(pipes.quote, run_test_cmd))), run_test_cmd)) | |
76 | 82 |
77 return commands | 83 return commands |
78 | 84 |
79 | 85 |
80 def GetBotStepMap(): | 86 def GetBotStepMap(): |
81 compile_step = ['bb_compile'] | 87 compile_step = ['bb_compile'] |
82 std_build_steps = ['bb_compile', 'bb_zip_build'] | 88 std_build_steps = ['bb_compile', 'bb_zip_build'] |
83 std_test_steps = ['bb_extract_build'] | 89 std_test_steps = ['bb_extract_build'] |
84 std_tests = ['ui', 'unit'] | 90 std_tests = ['ui', 'unit'] |
85 flakiness_server = '--upload-to-flakiness-server' | 91 flakiness_server = '--upload-to-flakiness-server' |
86 | 92 |
87 B = BotConfig | 93 B = BotConfig |
88 def T(tests, extra_args=None): | 94 def T(tests, extra_args=None): |
89 return TestConfig(tests, extra_args) | 95 return TestConfig(tests, extra_args) |
| 96 def H(steps, extra_args=None): |
| 97 return HostConfig(steps, extra_args) |
90 | 98 |
91 bot_configs = [ | 99 bot_configs = [ |
92 # Main builders | 100 # Main builders |
93 B('main-builder-dbg', | 101 B('main-builder-dbg', [], |
94 ['bb_check_webview_licenses', 'bb_compile', 'bb_run_findbugs', | 102 H(['check_webview_licenses', 'compile', 'findbugs', 'zip_build']), |
95 'bb_zip_build'], None, None), | 103 None, None), |
96 B('main-builder-rel', | 104 B('main-builder-rel', |
97 ['bb_compile', 'bb_zip_build'], None, None), | 105 ['bb_compile', 'bb_zip_build'], None, None, None), |
98 B('main-clang-builder', compile_step, None, None), | 106 B('main-clang-builder', compile_step, None, None, None), |
99 B('main-clobber', compile_step, None, None), | 107 B('main-clobber', compile_step, None, None, None), |
100 B('main-tests', std_test_steps, T(std_tests, [flakiness_server]), | 108 B('main-tests', std_test_steps, None, T(std_tests, [flakiness_server]), |
101 None), | 109 None), |
102 | 110 |
103 # Other waterfalls | 111 # Other waterfalls |
104 B('asan-builder-tests', compile_step + ['bb_asan_tests_setup'], | 112 B('asan-builder-tests', compile_step + ['bb_asan_tests_setup'], None, |
105 T(std_tests, ['--asan']), {'extra_gyp_defines': 'asan=1'}), | 113 T(std_tests, ['--asan']), {'extra_gyp_defines': 'asan=1'}), |
106 B('chromedriver-fyi-tests-dbg', std_test_steps, T(['chromedriver']), | 114 B('chromedriver-fyi-tests-dbg', std_test_steps, None, T(['chromedriver']), |
107 None), | 115 None), |
108 B('fyi-builder-dbg', | 116 B('fyi-builder-dbg', [], |
109 ['bb_check_webview_licenses', 'bb_compile', 'bb_compile_experimental', | 117 H(['check_webview_licenses', 'compile', 'compile_experimental', |
110 'bb_run_findbugs', 'bb_zip_build'], None, None), | 118 'findbugs', 'zip_build']), None, None), |
111 B('fyi-builder-rel', | 119 B('fyi-builder-rel', |
112 ['bb_compile', 'bb_compile_experimental', 'bb_zip_build'], None, None), | 120 ['bb_compile', 'bb_compile_experimental', 'bb_zip_build'], None, None, |
113 B('fyi-tests', std_test_steps, | 121 None), |
| 122 B('fyi-tests', std_test_steps, None, |
114 T(std_tests, ['--experimental', flakiness_server]), None), | 123 T(std_tests, ['--experimental', flakiness_server]), None), |
115 B('fyi-component-builder-tests-dbg', compile_step, | 124 B('fyi-component-builder-tests-dbg', compile_step, None, |
116 T(std_tests, ['--experimental', flakiness_server]), None), | 125 T(std_tests, ['--experimental', flakiness_server]), None), |
117 B('perf-tests-rel', std_test_steps, | 126 B('perf-tests-rel', std_test_steps, None, |
118 T([], ['--install=ContentShell']), | 127 T([], ['--install=ContentShell']), |
119 None), | 128 None), |
120 B('webkit-latest-webkit-tests', std_test_steps, | 129 B('webkit-latest-webkit-tests', std_test_steps, None, |
121 T(['webkit_layout', 'webkit']), None), | 130 T(['webkit_layout', 'webkit']), None), |
122 B('webkit-latest-contentshell', compile_step, T(['webkit_layout']), None), | 131 B('webkit-latest-contentshell', compile_step, None, T(['webkit_layout']), |
| 132 None), |
123 | 133 |
124 # Generic builder config (for substring match). | 134 # Generic builder config (for substring match). |
125 B('builder', std_build_steps, None, None), | 135 B('builder', std_build_steps, None, None, None), |
126 ] | 136 ] |
127 | 137 |
128 bot_map = dict((config.bot_id, config) for config in bot_configs) | 138 bot_map = dict((config.bot_id, config) for config in bot_configs) |
129 | 139 |
130 # These bots have identical configuration to ones defined earlier. | 140 # These bots have identical configuration to ones defined earlier. |
131 copy_map = [ | 141 copy_map = [ |
132 ('lkgr-clobber', 'main-clobber'), | 142 ('lkgr-clobber', 'main-clobber'), |
133 ('try-builder-dbg', 'main-builder-dbg'), | 143 ('try-builder-dbg', 'main-builder-dbg'), |
134 ('try-builder-rel', 'main-builder-rel'), | 144 ('try-builder-rel', 'main-builder-rel'), |
135 ('try-clang-builder', 'main-clang-builder'), | 145 ('try-clang-builder', 'main-clang-builder'), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 print 'Using config:', bot_config | 205 print 'Using config:', bot_config |
196 | 206 |
197 def CommandToString(command): | 207 def CommandToString(command): |
198 """Returns quoted command that can be run in bash shell.""" | 208 """Returns quoted command that can be run in bash shell.""" |
199 return ' '.join(map(pipes.quote, command)) | 209 return ' '.join(map(pipes.quote, command)) |
200 | 210 |
201 command_objs = GetCommands(options, bot_config) | 211 command_objs = GetCommands(options, bot_config) |
202 for command_obj in command_objs: | 212 for command_obj in command_objs: |
203 print 'Will run:', CommandToString(command_obj.command) | 213 print 'Will run:', CommandToString(command_obj.command) |
204 | 214 |
| 215 commands = [] |
205 for command_obj in command_objs: | 216 for command_obj in command_objs: |
206 if command_obj.step_name: | |
207 buildbot_report.PrintNamedStep(command_obj.step_name) | |
208 command = command_obj.command | |
209 print CommandToString(command) | |
210 sys.stdout.flush() | |
211 env = None | |
212 if options.TESTING: | 217 if options.TESTING: |
213 if not command_obj.testing_cmd: | 218 if command_obj.testing_cmd: |
214 continue | 219 commands += command_obj.testing_cmd |
215 return_code = subprocess.call( | |
216 command_obj.testing_cmd, | |
217 cwd=CHROME_SRC, | |
218 env=dict(os.environ, BUILDBOT_TESTING='1')) | |
219 else: | 220 else: |
220 return_code = subprocess.call(command, cwd=CHROME_SRC, env=env) | 221 commands += command_obj.command |
221 if return_code != 0: | 222 if options.TESTING: |
222 return return_code | 223 return_code = subprocess.call( |
| 224 ['bash', '-exc', '; '.join(commands)], cwd=CHROME_SRC, |
| 225 env=dict(os.environ, BUILDBOT_TESTING='1')) |
| 226 else: |
| 227 return_code = subprocess.call( |
| 228 ['bash', '-exc', '; '.join(commands)], cwd=CHROME_SRC) |
| 229 # for command_obj in command_objs: |
| 230 # if command_obj.step_name: |
| 231 # buildbot_report.PrintNamedStep(command_obj.step_name) |
| 232 # command = command_obj.command |
| 233 # print CommandToString(command) |
| 234 # sys.stdout.flush() |
| 235 # env = None |
| 236 # if options.TESTING: |
| 237 # if not command_obj.testing_cmd: |
| 238 # continue |
| 239 # return_code = subprocess.call( |
| 240 # command_obj.testing_cmd, |
| 241 # cwd=CHROME_SRC, |
| 242 # env=dict(os.environ, BUILDBOT_TESTING='1')) |
| 243 # else: |
| 244 # return_code = subprocess.call(command, cwd=CHROME_SRC, env=env) |
| 245 if return_code != 0: |
| 246 return return_code |
223 | 247 |
224 | 248 |
225 if __name__ == '__main__': | 249 if __name__ == '__main__': |
226 sys.exit(main(sys.argv)) | 250 sys.exit(main(sys.argv)) |
OLD | NEW |