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

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: yet another 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
« no previous file with comments | « build/android/buildbot/bb_host_steps.py ('k') | build/android/buildbot/bb_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import bb_utils
17
16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 18 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
17 from pylib import buildbot_report 19 from pylib import buildbot_report
18 20
19 CHROME_SRC = os.path.abspath( 21 CHROME_SRC = os.path.abspath(
20 os.path.join(os.path.dirname(__file__), '..', '..', '..')) 22 os.path.join(os.path.dirname(__file__), '..', '..', '..'))
21 23
22 GLOBAL_SLAVE_PROPS = {} 24 GLOBAL_SLAVE_PROPS = {}
23 25
24 BotConfig = collections.namedtuple( 26 BotConfig = collections.namedtuple(
25 'BotConfig', ['bot_id', 'bash_funs', 'test_obj', 'slave_props']) 27 'BotConfig', ['bot_id', 'host_opts', 'test_obj', 'slave_props'])
26 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args']) 28 TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args'])
27 Command = collections.namedtuple( 29 Command = collections.namedtuple(
28 'Command', ['step_name', 'command', 'testing_cmd']) 30 'Command', ['step_name', 'command', 'testing_cmd'])
29 31
32 CommandToString = bb_utils.CommandToString
33
30 34
31 def GetCommands(options, bot_config): 35 def GetCommands(options, bot_config):
32 """Get a formatted list of commands. 36 """Get a formatted list of commands.
33 37
34 Args: 38 Args:
35 options: Options object. 39 options: Options object.
36 bot_config: A BotConfig named tuple. 40 bot_config: A BotConfig named tuple.
37 Returns: 41 Returns:
38 list of Command objects. 42 list of Command objects.
39 """ 43 """
40 slave_props = dict(GLOBAL_SLAVE_PROPS) 44 slave_props = dict(GLOBAL_SLAVE_PROPS)
41 if bot_config.slave_props: 45 if bot_config.slave_props:
42 slave_props.update(bot_config.slave_props) 46 slave_props.update(bot_config.slave_props)
43 47
48 slave_properties = json.dumps(slave_props)
44 property_args = [ 49 property_args = [
45 '--factory-properties=%s' % json.dumps(options.factory_properties), 50 '--factory-properties=%s' % json.dumps(options.factory_properties),
46 '--build-properties=%s' % json.dumps(options.build_properties), 51 '--build-properties=%s' % json.dumps(options.build_properties),
47 '--slave-properties=%s' % json.dumps(slave_props)] 52 '--slave-properties=%s' % slave_properties]
48 53
49 commands = [] 54 commands = []
50 def WrapWithBash(command): 55 def WrapWithBash(command):
51 """Wrap a bash command string with envsetup scripts.""" 56 """Wrap a bash command string with envsetup scripts."""
52 return ['bash', '-exc', '; '.join([ 57 return ['bash', '-exc', '; '.join([
53 '. build/android/buildbot/buildbot_functions.sh', 58 '. build/android/buildbot/buildbot_functions.sh',
54 'bb_baseline_setup %s %s' % ( 59 'bb_baseline_setup %s --slave-properties=%s' % (
55 CHROME_SRC, 60 CHROME_SRC, pipes.quote(slave_properties)),
56 ' '.join(map(pipes.quote, property_args))),
57 command]) 61 command])
58 ] 62 ]
59 63
60 if bot_config.bash_funs: 64 if bot_config.host_opts:
61 # bash_funs command does not have a testing mode. 65 host_cmd = (['build/android/buildbot/bb_host_steps.py'] +
62 commands.append( 66 bot_config.host_opts + property_args)
63 Command(None, WrapWithBash('; '.join(bot_config.bash_funs)), None)) 67 commands.append(Command(
68 'Host steps',
69 WrapWithBash(' '.join(map(pipes.quote, host_cmd))), host_cmd))
64 70
65 test_obj = bot_config.test_obj 71 test_obj = bot_config.test_obj
66 if test_obj: 72 if test_obj:
67 run_test_cmd = [ 73 run_test_cmd = [
68 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args 74 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args
69 for test in test_obj.tests: 75 for test in test_obj.tests:
70 run_test_cmd.extend(['-f', test]) 76 run_test_cmd.extend(['-f', test])
71 if test_obj.extra_args: 77 if test_obj.extra_args:
72 run_test_cmd.extend(test_obj.extra_args) 78 run_test_cmd.extend(test_obj.extra_args)
73 commands.append(Command( 79 commands.append(Command(
74 'Run tests', 80 'Run tests',
75 WrapWithBash(' '.join(map(pipes.quote, run_test_cmd))), run_test_cmd)) 81 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_opt = ['--compile']
82 std_build_steps = ['bb_compile', 'bb_zip_build'] 88 std_host_tests = ['--host-tests=check_webview_licenses,findbugs']
83 std_test_steps = ['bb_extract_build'] 89 std_build_opts = ['--compile', '--zip-build']
90 std_test_opts = ['--extract-build']
84 std_tests = ['ui', 'unit'] 91 std_tests = ['ui', 'unit']
85 flakiness_server = '--upload-to-flakiness-server' 92 flakiness_server = '--upload-to-flakiness-server'
86 extra_gyp = 'extra_gyp_defines' 93 extra_gyp = 'extra_gyp_defines'
87 94
88 def B(bot_id, bash_funs, test_obj=None, slave_props=None): 95 def B(bot_id, bash_funs, test_obj=None, slave_props=None):
89 return BotConfig(bot_id, bash_funs, test_obj, slave_props) 96 return BotConfig(bot_id, bash_funs, test_obj, slave_props)
90 97
91 def T(tests, extra_args=None): 98 def T(tests, extra_args=None):
92 return TestConfig(tests, extra_args) 99 return TestConfig(tests, extra_args)
93 100
94 bot_configs = [ 101 bot_configs = [
95 # Main builders 102 # Main builders
96 B('main-builder-dbg', 103 B('main-builder-dbg', std_build_opts + std_host_tests),
97 ['bb_check_webview_licenses', 'bb_compile', 'bb_run_findbugs', 104 B('main-builder-rel', std_build_opts),
98 'bb_zip_build']), 105 B('main-clang-builder', compile_opt, slave_props={extra_gyp: 'clang=1'}),
99 B('main-builder-rel', ['bb_compile', 'bb_zip_build']), 106 B('main-clobber', compile_opt),
100 B('main-clang-builder', compile_step, slave_props={extra_gyp: 'clang=1'}), 107 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 108
104 # Other waterfalls 109 # Other waterfalls
105 B('asan-builder-tests', compile_step + ['bb_asan_tests_setup'], 110 B('asan-builder-tests', compile_opt + ['--update-clang'],
106 T(std_tests, ['--asan']), {extra_gyp: 'asan=1'}), 111 T(std_tests, ['--asan']), {extra_gyp: 'asan=1'}),
107 B('chromedriver-fyi-tests-dbg', std_test_steps, 112 B('chromedriver-fyi-tests-dbg', std_test_opts,
108 T(['chromedriver'], ['--install=ChromiumTestShell'])), 113 T(['chromedriver'], ['--install=ChromiumTestShell'])),
109 B('fyi-builder-dbg', 114 B('fyi-builder-dbg',
110 ['bb_check_webview_licenses', 'bb_compile', 'bb_compile_experimental', 115 std_build_opts + std_host_tests + ['--experimental']),
111 'bb_run_findbugs', 'bb_zip_build']), 116 B('fyi-builder-rel', std_build_opts + ['--experimental']),
112 B('fyi-builder-rel', 117 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])), 118 T(std_tests, ['--experimental', flakiness_server])),
116 B('fyi-tests', std_test_steps, 119 B('fyi-tests', std_test_opts,
117 T(std_tests, ['--experimental', flakiness_server])), 120 T(std_tests, ['--experimental', flakiness_server])),
118 B('fyi-component-builder-tests-dbg', compile_step, 121 B('fyi-component-builder-tests-dbg', compile_opt,
119 T(std_tests, ['--experimental', flakiness_server]), 122 T(std_tests, ['--experimental', flakiness_server]),
120 {extra_gyp: 'component=shared_library'}), 123 {extra_gyp: 'component=shared_library'}),
121 B('perf-tests-rel', std_test_steps, T([], ['--install=ContentShell'])), 124 B('perf-tests-rel', std_test_opts, T([], ['--install=ContentShell'])),
122 B('webkit-latest-webkit-tests', std_test_steps, 125 B('webkit-latest-webkit-tests', std_test_opts,
123 T(['webkit_layout', 'webkit'])), 126 T(['webkit_layout', 'webkit'])),
124 B('webkit-latest-contentshell', compile_step, T(['webkit_layout'])), 127 B('webkit-latest-contentshell', compile_opt, T(['webkit_layout'])),
125 B('builder-unit-tests', compile_step, T(['unit'])), 128 B('builder-unit-tests', compile_opt, T(['unit'])),
126 129
127 # Generic builder config (for substring match). 130 # Generic builder config (for substring match).
128 B('builder', std_build_steps), 131 B('builder', std_build_opts),
129 ] 132 ]
130 133
131 bot_map = dict((config.bot_id, config) for config in bot_configs) 134 bot_map = dict((config.bot_id, config) for config in bot_configs)
132 135
133 # These bots have identical configuration to ones defined earlier. 136 # These bots have identical configuration to ones defined earlier.
134 copy_map = [ 137 copy_map = [
135 ('lkgr-clobber', 'main-clobber'), 138 ('lkgr-clobber', 'main-clobber'),
136 ('try-builder-dbg', 'main-builder-dbg'), 139 ('try-builder-dbg', 'main-builder-dbg'),
137 ('try-builder-rel', 'main-builder-rel'), 140 ('try-builder-rel', 'main-builder-rel'),
138 ('try-clang-builder', 'main-clang-builder'), 141 ('try-clang-builder', 'main-clang-builder'),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if substring_matches: 193 if substring_matches:
191 max_id = max(substring_matches, key=len) 194 max_id = max(substring_matches, key=len)
192 print 'Using config from id="%s" (substring match).' % max_id 195 print 'Using config from id="%s" (substring match).' % max_id
193 bot_config = bot_map[max_id] 196 bot_config = bot_map[max_id]
194 if not bot_config: 197 if not bot_config:
195 print 'Error: config for id="%s" cannot be inferred.' % bot_id 198 print 'Error: config for id="%s" cannot be inferred.' % bot_id
196 return 1 199 return 1
197 200
198 print 'Using config:', bot_config 201 print 'Using config:', bot_config
199 202
200 def CommandToString(command):
201 """Returns quoted command that can be run in bash shell."""
202 return ' '.join(map(pipes.quote, command))
203
204 command_objs = GetCommands(options, bot_config) 203 command_objs = GetCommands(options, bot_config)
205 for command_obj in command_objs: 204 for command_obj in command_objs:
206 print 'Will run:', CommandToString(command_obj.command) 205 print 'Will run:', CommandToString(command_obj.command)
207 206
208 for command_obj in command_objs: 207 for command_obj in command_objs:
209 if command_obj.step_name: 208 if command_obj.step_name:
210 buildbot_report.PrintNamedStep(command_obj.step_name) 209 buildbot_report.PrintNamedStep(command_obj.step_name)
211 command = command_obj.command 210 command = command_obj.command
212 print CommandToString(command) 211 print CommandToString(command)
213 sys.stdout.flush() 212 sys.stdout.flush()
214 env = None 213 env = None
215 if options.TESTING: 214 if options.TESTING:
216 if not command_obj.testing_cmd: 215 if not command_obj.testing_cmd:
217 continue 216 continue
218 return_code = subprocess.call( 217 return_code = subprocess.call(
219 command_obj.testing_cmd, 218 command_obj.testing_cmd,
220 cwd=CHROME_SRC, 219 cwd=CHROME_SRC,
221 env=dict(os.environ, BUILDBOT_TESTING='1')) 220 env=dict(os.environ, BUILDBOT_TESTING='1'))
222 else: 221 else:
223 return_code = subprocess.call(command, cwd=CHROME_SRC, env=env) 222 return_code = subprocess.call(command, cwd=CHROME_SRC, env=env)
224 if return_code != 0: 223 if return_code != 0:
225 return return_code 224 return return_code
226 225
227 226
228 if __name__ == '__main__': 227 if __name__ == '__main__':
229 sys.exit(main(sys.argv)) 228 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_host_steps.py ('k') | build/android/buildbot/bb_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698