Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: build/android/buildbot/bb_run_bot.py

Issue 15261003: Add a new script bb_host_steps.py which handles all host side steps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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__), '..'))
17 from pylib import buildbot_report
18
19 CHROME_SRC = os.path.abspath( 16 CHROME_SRC = os.path.abspath(
20 os.path.join(os.path.dirname(__file__), '..', '..', '..')) 17 os.path.join(os.path.dirname(__file__), '..', '..', '..'))
21 18
22 GLOBAL_SLAVE_PROPS = {} 19 GLOBAL_SLAVE_PROPS = {}
23 20
24 BotConfig = collections.namedtuple( 21 BotConfig = collections.namedtuple(
25 'BotConfig', ['bot_id', 'bash_funs', 'test_obj', 'slave_props']) 22 'BotConfig', ['bot_id', 'host_opts', 'test_obj', 'slave_props'])
26 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args']) 23 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args'])
27 Command = collections.namedtuple( 24 Command = collections.namedtuple(
28 'Command', ['step_name', 'command', 'testing_cmd']) 25 'Command', ['step_name', 'command', 'testing_cmd'])
29 26
30 27
31 def GetCommands(options, bot_config): 28 def GetCommands(options, bot_config):
32 """Get a formatted list of commands. 29 """Get a formatted list of commands.
33 30
34 Args: 31 Args:
35 options: Options object. 32 options: Options object.
36 bot_config: A BotConfig named tuple. 33 bot_config: A BotConfig named tuple.
37 Returns: 34 Returns:
38 list of Command objects. 35 list of Command objects.
39 """ 36 """
40 slave_props = dict(GLOBAL_SLAVE_PROPS) 37 slave_props = dict(GLOBAL_SLAVE_PROPS)
41 if bot_config.slave_props: 38 if bot_config.slave_props:
42 slave_props.update(bot_config.slave_props) 39 slave_props.update(bot_config.slave_props)
43 40
44 property_args = [ 41 property_args = [
45 '--factory-properties=%s' % json.dumps(options.factory_properties), 42 '--factory-properties=%s' % json.dumps(options.factory_properties),
46 '--build-properties=%s' % json.dumps(options.build_properties), 43 '--build-properties=%s' % json.dumps(options.build_properties),
47 '--slave-properties=%s' % json.dumps(slave_props)] 44 '--slave-properties=%s' % json.dumps(slave_props)]
48 45
49 commands = [] 46 common_cmd = ['; '.join(['. build/android/buildbot/buildbot_functions.sh',
50 def WrapWithBash(command): 47 'bb_baseline_setup %s %s' % (
51 """Wrap a bash command string with envsetup scripts.""" 48 CHROME_SRC,
52 return ['bash', '-exc', '; '.join([ 49 ' '.join(map(pipes.quote, property_args)))])]
53 '. build/android/buildbot/buildbot_functions.sh',
54 'bb_baseline_setup %s %s' % (
55 CHROME_SRC,
56 ' '.join(map(pipes.quote, property_args))),
57 command])
58 ]
59 50
60 if bot_config.bash_funs: 51 commands = [Command('Preparation', common_cmd, None)]
Isaac (away) 2013/06/05 03:03:07 Why are you changing this?
Siva Chandra 2013/06/05 21:04:28 This reply is for this comment and for another com
61 # bash_funs command does not have a testing mode. 52
62 commands.append( 53 host_opts = bot_config.host_opts
63 Command(None, WrapWithBash('; '.join(bot_config.bash_funs)), None)) 54 if host_opts:
55 host_script = 'build/android/buildbot/bb_host_steps.py'
56 host_cmd = [host_script] + host_opts + property_args[0:2]
57 cmd = ' '.join(map(pipes.quote, host_cmd))
58 commands.append(Command('Host steps', [cmd], [cmd]))
64 59
65 test_obj = bot_config.test_obj 60 test_obj = bot_config.test_obj
66 if test_obj: 61 if test_obj:
67 run_test_cmd = [ 62 run_test_cmd = [
68 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args 63 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args
69 for test in test_obj.tests: 64 for test in test_obj.tests:
70 run_test_cmd.extend(['-f', test]) 65 run_test_cmd.extend(['-f', test])
71 if test_obj.extra_args: 66 if test_obj.extra_args:
72 run_test_cmd.extend(test_obj.extra_args) 67 run_test_cmd.extend(test_obj.extra_args)
73 commands.append(Command( 68 cmd = ' '.join(map(pipes.quote, run_test_cmd))
74 'Run tests', 69 commands.append(Command('Run tests', [cmd], [cmd]))
75 WrapWithBash(' '.join(map(pipes.quote, run_test_cmd))), run_test_cmd))
76 70
77 return commands 71 return commands
78 72
79 73
80 def GetBotStepMap(): 74 def GetBotStepMap():
81 compile_step = ['bb_compile'] 75 compile_opt = ['--compile']
82 std_build_steps = ['bb_compile', 'bb_zip_build'] 76 std_host_tests = ['--host-tests=check_webview_licenses,findbugs']
83 std_test_steps = ['bb_extract_build'] 77 std_build_opts = ['--compile', '--zipbuild']
78 std_test_opts = ['--extract-build']
84 std_tests = ['ui', 'unit'] 79 std_tests = ['ui', 'unit']
85 flakiness_server = '--upload-to-flakiness-server' 80 flakiness_server = '--upload-to-flakiness-server'
86 extra_gyp = 'extra_gyp_defines' 81 extra_gyp = 'extra_gyp_defines'
87 82
88 def B(bot_id, bash_funs, test_obj=None, slave_props=None): 83 def B(bot_id, bash_funs, test_obj=None, slave_props=None):
89 return BotConfig(bot_id, bash_funs, test_obj, slave_props) 84 return BotConfig(bot_id, bash_funs, test_obj, slave_props)
90 85
91 def T(tests, extra_args=None): 86 def T(tests, extra_args=None):
92 return TestConfig(tests, extra_args) 87 return TestConfig(tests, extra_args)
93 88
94 bot_configs = [ 89 bot_configs = [
95 # Main builders 90 # Main builders
96 B('main-builder-dbg', 91 B('main-builder-dbg', std_build_opts + std_host_tests),
97 ['bb_check_webview_licenses', 'bb_compile', 'bb_run_findbugs', 92 B('main-builder-rel', std_build_opts),
98 'bb_zip_build']), 93 B('main-clang-builder', compile_opt),
99 B('main-builder-rel', ['bb_compile', 'bb_zip_build']), 94 B('main-clobber', compile_opt),
100 B('main-clang-builder', compile_step, slave_props={extra_gyp: 'clang=1'}), 95 B('main-tests', std_test_opts, T(std_tests, [flakiness_server])),
101 B('main-clobber', compile_step),
102 B('main-tests', std_test_steps, T(std_tests, [flakiness_server])),
103 96
104 # Other waterfalls 97 # Other waterfalls
105 B('asan-builder-tests', compile_step + ['bb_asan_tests_setup'], 98 B('asan-builder-tests', compile_opt + ['--asan-tests-setup'],
106 T(std_tests, ['--asan']), {extra_gyp: 'asan=1'}), 99 T(std_tests, ['--asan']), {extra_gyp: 'asan=1'}),
107 B('chromedriver-fyi-tests-dbg', std_test_steps, 100 B('chromedriver-fyi-tests-dbg', std_test_opts,
108 T(['chromedriver'], ['--install=ChromiumTestShell'])), 101 T(['chromedriver'], ['--install=ChromiumTestShell'])),
109 B('fyi-builder-dbg', 102 B('fyi-builder-dbg',
110 ['bb_check_webview_licenses', 'bb_compile', 'bb_compile_experimental', 103 std_build_opts + std_host_tests + ['--experimental']),
111 'bb_run_findbugs', 'bb_zip_build']), 104 B('fyi-builder-rel', std_build_opts + ['--experimental']),
112 B('fyi-builder-rel', 105 B('fyi-tests-dbg-ics-gn', compile_opt + [ '--experimental'],
113 ['bb_compile', 'bb_compile_experimental', 'bb_zip_build']),
114 B('fyi-tests-dbg-ics-gn', ['bb_compile', 'bb_compile_experimental'],
115 T(std_tests, ['--experimental', flakiness_server])), 106 T(std_tests, ['--experimental', flakiness_server])),
116 B('fyi-tests', std_test_steps, 107 B('fyi-tests', std_test_opts,
117 T(std_tests, ['--experimental', flakiness_server])), 108 T(std_tests, ['--experimental', flakiness_server])),
118 B('fyi-component-builder-tests-dbg', compile_step, 109 B('fyi-component-builder-tests-dbg', compile_opt,
119 T(std_tests, ['--experimental', flakiness_server]), 110 T(std_tests, ['--experimental', flakiness_server])),
120 {extra_gyp: 'component=shared_library'}), 111 B('perf-tests-rel', std_test_opts, T([], ['--install=ContentShell'])),
121 B('perf-tests-rel', std_test_steps, T([], ['--install=ContentShell'])), 112 B('webkit-latest-webkit-tests', std_test_opts,
122 B('webkit-latest-webkit-tests', std_test_steps,
123 T(['webkit_layout', 'webkit'])), 113 T(['webkit_layout', 'webkit'])),
124 B('webkit-latest-contentshell', compile_step, T(['webkit_layout'])), 114 B('webkit-latest-contentshell', compile_opt, T(['webkit_layout'])),
125 B('builder-unit-tests', compile_step, T(['unit'])), 115 B('builder-unit-tests', compile_opt, T(['unit'])),
126 116
127 # Generic builder config (for substring match). 117 # Generic builder config (for substring match).
128 B('builder', std_build_steps), 118 B('builder', std_build_opts),
129 ] 119 ]
130 120
131 bot_map = dict((config.bot_id, config) for config in bot_configs) 121 bot_map = dict((config.bot_id, config) for config in bot_configs)
132 122
133 # These bots have identical configuration to ones defined earlier. 123 # These bots have identical configuration to ones defined earlier.
134 copy_map = [ 124 copy_map = [
135 ('lkgr-clobber', 'main-clobber'), 125 ('lkgr-clobber', 'main-clobber'),
136 ('try-builder-dbg', 'main-builder-dbg'), 126 ('try-builder-dbg', 'main-builder-dbg'),
137 ('try-builder-rel', 'main-builder-rel'), 127 ('try-builder-rel', 'main-builder-rel'),
138 ('try-clang-builder', 'main-clang-builder'), 128 ('try-clang-builder', 'main-clang-builder'),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if substring_matches: 180 if substring_matches:
191 max_id = max(substring_matches, key=len) 181 max_id = max(substring_matches, key=len)
192 print 'Using config from id="%s" (substring match).' % max_id 182 print 'Using config from id="%s" (substring match).' % max_id
193 bot_config = bot_map[max_id] 183 bot_config = bot_map[max_id]
194 if not bot_config: 184 if not bot_config:
195 print 'Error: config for id="%s" cannot be inferred.' % bot_id 185 print 'Error: config for id="%s" cannot be inferred.' % bot_id
196 return 1 186 return 1
197 187
198 print 'Using config:', bot_config 188 print 'Using config:', bot_config
199 189
200 def CommandToString(command): 190 def CommandToString(command):
Isaac (away) 2013/06/05 03:03:07 move this function to bb_utils
Siva Chandra 2013/06/05 21:04:28 Done.
201 """Returns quoted command that can be run in bash shell.""" 191 """Returns quoted command that can be run in bash shell."""
202 return ' '.join(map(pipes.quote, command)) 192 return ' '.join(map(pipes.quote, command))
203 193
204 command_objs = GetCommands(options, bot_config) 194 command_objs = GetCommands(options, bot_config)
205 for command_obj in command_objs: 195 for command_obj in command_objs:
206 print 'Will run:', CommandToString(command_obj.command) 196 print 'Will run "%s" step: %s' % (command_obj.step_name,
197 CommandToString(command_obj.command))
207 198
199 commands = []
208 for command_obj in command_objs: 200 for command_obj in command_objs:
209 if command_obj.step_name:
Isaac (away) 2013/06/05 03:03:07 why are you removing this?
210 buildbot_report.PrintNamedStep(command_obj.step_name)
211 command = command_obj.command
212 print CommandToString(command)
213 sys.stdout.flush()
214 env = None
215 if options.TESTING: 201 if options.TESTING:
216 if not command_obj.testing_cmd: 202 if command_obj.testing_cmd:
217 continue 203 commands += command_obj.testing_cmd
218 return_code = subprocess.call(
219 command_obj.testing_cmd,
220 cwd=CHROME_SRC,
221 env=dict(os.environ, BUILDBOT_TESTING='1'))
222 else: 204 else:
223 return_code = subprocess.call(command, cwd=CHROME_SRC, env=env) 205 commands += command_obj.command
224 if return_code != 0: 206 if options.TESTING:
225 return return_code 207 return_code = subprocess.call(
208 ['bash', '-exc', '; '.join(commands)], cwd=CHROME_SRC,
Isaac (away) 2013/06/05 03:03:07 why are you combining the commands?
209 env=dict(os.environ, BUILDBOT_TESTING='1'))
210 else:
211 return_code = subprocess.call(
212 ['bash', '-exc', '; '.join(commands)], cwd=CHROME_SRC)
213
214 if return_code != 0:
215 return return_code
226 216
227 217
228 if __name__ == '__main__': 218 if __name__ == '__main__':
229 sys.exit(main(sys.argv)) 219 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698