OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import re | 5 import re |
6 | 6 |
7 from recipe_engine.types import freeze | 7 from recipe_engine.types import freeze |
8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
9 | 9 |
10 DEPS = [ | 10 DEPS = [ |
11 'depot_tools/bot_update', | 11 'depot_tools/bot_update', |
12 'chromium', | 12 'chromium', |
13 'chromium_android', | 13 'chromium_android', |
14 'file', | |
15 'gsutil', | |
16 'recipe_engine/raw_io', | |
17 'recipe_engine/path', | 14 'recipe_engine/path', |
18 'recipe_engine/platform', | |
19 'recipe_engine/properties', | 15 'recipe_engine/properties', |
20 'recipe_engine/python', | 16 'recipe_engine/python', |
21 'recipe_engine/step', | 17 'recipe_engine/step', |
22 ] | 18 ] |
23 | 19 |
24 | |
25 BUILDERS = freeze({ | 20 BUILDERS = freeze({ |
26 'chromium.mojo': { | 21 'chromium.mojo': { |
27 'builders': { | 22 'builders': { |
28 'Chromium Mojo Linux': { | 23 'Chromium Mojo Linux': { |
29 'chromium_config_kwargs': { | 24 'chromium_config_kwargs': { |
30 'BUILD_CONFIG': 'Release', | 25 'BUILD_CONFIG': 'Release', |
31 'TARGET_PLATFORM': 'linux', | 26 'TARGET_PLATFORM': 'linux', |
32 }, | 27 }, |
33 }, | 28 }, |
34 'Chromium Mojo Android': { | 29 'Chromium Mojo Android': { |
35 'chromium_config': 'android', | 30 'chromium_config': 'android', |
36 'chromium_config_kwargs': { | 31 'chromium_config_kwargs': { |
37 'BUILD_CONFIG': 'Release', | 32 'BUILD_CONFIG': 'Release', |
38 'TARGET_PLATFORM': 'android', | 33 'TARGET_PLATFORM': 'android', |
39 'TARGET_ARCH': 'arm', | 34 'TARGET_ARCH': 'arm', |
40 'TARGET_BITS': 32, | 35 'TARGET_BITS': 32, |
41 }, | 36 }, |
42 'gclient_apply_config': ['android'], | 37 'gclient_apply_config': ['android'], |
43 }, | 38 }, |
44 'Chromium Mojo Linux Perf': { | |
45 'chromium_config_kwargs': { | |
46 'BUILD_CONFIG': 'Release', | |
47 'TARGET_PLATFORM': 'linux', | |
48 }, | |
49 'run_perf_tests': True, | |
50 'perf_test_info': { | |
51 'browser_type': 'mandoline-release', | |
52 'perf_id': 'mandoline-linux-release', | |
53 'supported_testnames': [ | |
54 'blink_perf.dom', | |
55 'blink_perf.events', | |
56 'blink_perf.mutation', | |
57 'blink_perf.shadow_dom', | |
58 'page_cycler.typical_25', | |
59 'startup.cold.blank_page', | |
60 'startup.warm.blank_page', | |
61 ], | |
62 }, | |
63 }, | |
64 'Chromium Mojo Android Nexus5 Perf': { | |
65 'chromium_config': 'android', | |
66 'chromium_config_kwargs': { | |
67 'BUILD_CONFIG': 'Release', | |
68 'TARGET_PLATFORM': 'android', | |
69 'TARGET_ARCH': 'arm', | |
70 'TARGET_BITS': 32, | |
71 }, | |
72 'gclient_apply_config': ['android'], | |
73 # TODO(yzshen): Actually run perf tests. | |
74 }, | |
75 'Chromium Mojo Windows': { | 39 'Chromium Mojo Windows': { |
76 'chromium_config_kwargs': { | 40 'chromium_config_kwargs': { |
77 'BUILD_CONFIG': 'Release', | 41 'BUILD_CONFIG': 'Release', |
78 'TARGET_PLATFORM': 'win', | 42 'TARGET_PLATFORM': 'win', |
79 }, | 43 }, |
80 }, | 44 }, |
81 'Chromium Mojo Windows 7 Perf': { | |
82 'chromium_config_kwargs': { | |
83 'BUILD_CONFIG': 'Release', | |
84 'TARGET_PLATFORM': 'win', | |
85 }, | |
86 'run_perf_tests': True, | |
87 'perf_test_info': { | |
88 'browser_type': 'mandoline-release', | |
89 'perf_id': 'mandoline-win7-release', | |
90 'supported_testnames': [ | |
91 'blink_perf.dom', | |
92 'blink_perf.events', | |
93 'blink_perf.mutation', | |
94 'blink_perf.shadow_dom', | |
95 'page_cycler.typical_25', | |
96 'startup.cold.blank_page', | |
97 'startup.warm.blank_page', | |
98 ], | |
99 }, | |
100 }, | |
101 }, | 45 }, |
102 }, | 46 }, |
103 }) | 47 }) |
104 | 48 |
105 | 49 |
106 def _GetBotConfig(api): | |
107 mastername = api.properties.get('mastername') | |
108 buildername = api.properties.get('buildername') | |
109 master_dict = BUILDERS.get(mastername, {}) | |
110 bot_config = master_dict.get('builders', {}).get(buildername, {}) | |
111 return bot_config | |
112 | |
113 | |
114 @recipe_api.composite_step | |
115 def _UploadMandolineToGoogleStorage(api): | |
116 # Get the release version, which is updated daily for Chrome canary. | |
117 v = api.chromium.get_version() | |
118 version = '%s.%s.%s.%s' % (v['MAJOR'], v['MINOR'], v['BUILD'], v['PATCH']) | |
119 assert re.match('^\d+\.\d+\.\d+\.\d+$', version), 'Error: Bad version %r' % v | |
120 api.step.active_result.presentation.step_text = 'Found version %s' % version | |
121 | |
122 # Check if the current version is already uploaded for the given platform. | |
123 bucket = 'mandoline' | |
124 url = 'gs://%s/%s' % (bucket, version) | |
125 result = api.gsutil.ls(bucket, '', stdout=api.raw_io.output()) | |
126 result.presentation.logs['ls result stdout'] = [result.stdout or ''] | |
127 if result.stdout and url in result.stdout: | |
128 result = api.gsutil.ls(bucket, version, stdout=api.raw_io.output()) | |
129 result.presentation.logs['ls result stdout'] = [result.stdout or ''] | |
130 url = '%s/%s' % (url, api.chromium.c.TARGET_PLATFORM) | |
131 | |
132 if result.stdout and url in result.stdout: | |
133 api.step('skipping mandoline upload: release already exits', None) | |
134 return | |
135 | |
136 # Read a limited FILES.cfg file-list format, uploading each applicable entry. | |
137 # Also clobber and upload a copy of the files to the 'latest' build directory. | |
138 files = api.path['checkout'].join('mandoline', 'tools', 'data', 'FILES.cfg') | |
139 test_data = 'FILES=[{\'filepath\': \'foo\', \'platforms\': [\'linux\'],},]' | |
140 files_data = api.file.read('read FILES.cfg', files, test_data=test_data) | |
141 execution_globals = {} | |
142 exec(files_data, execution_globals) | |
143 gs_path = '%s/%s' % (version, api.chromium.c.TARGET_PLATFORM) | |
144 gs_latest_path = 'latest/%s' % api.chromium.c.TARGET_PLATFORM | |
145 api.gsutil.remove_url('gs://%s/%s' % (bucket, gs_latest_path), args=['-r']) | |
146 for file_dictionary in execution_globals['FILES']: | |
147 if api.chromium.c.TARGET_PLATFORM in file_dictionary['platforms']: | |
148 file_path = file_dictionary['filepath'] | |
149 local_path = api.chromium.output_dir.join(file_path) | |
150 remote_path = '%s/%s' % (gs_path, file_path) | |
151 args = ['-r'] if file_dictionary.get('directory', False) else [] | |
152 api.gsutil.upload(local_path, bucket, remote_path, args=args) | |
153 remote_path = '%s/%s' % (gs_latest_path, file_path) | |
154 api.gsutil.upload(local_path, bucket, remote_path, args=args) | |
155 | |
156 # Upload a stamp file to inform any observers that the upload is complete. | |
157 stamp_path = api.path.mkdtemp('upload_stamp').join('stamp') | |
158 api.file.write('Create upload stamp', stamp_path, 'Upload complete') | |
159 api.gsutil.upload(stamp_path, bucket, '%s/stamp' % gs_path) | |
160 api.gsutil.upload(stamp_path, bucket, '%s/stamp' % gs_latest_path) | |
161 | |
162 | |
163 @recipe_api.composite_step | 50 @recipe_api.composite_step |
164 def _RunApptests(api): | 51 def _RunApptests(api): |
165 # TODO(msw): Run and get compile targets via testing/scripts/mojo_apptests.py. | 52 # TODO(msw): Run and get compile targets via testing/scripts/mojo_apptests.py. |
166 runner = api.path['checkout'].join('mojo', 'tools', 'apptest_runner.py') | 53 runner = api.path['checkout'].join('mojo', 'tools', 'apptest_runner.py') |
167 api.python('app_tests', runner, [api.chromium.output_dir, '--verbose']) | 54 api.python('app_tests', runner, [api.chromium.output_dir, '--verbose']) |
168 | 55 |
169 | 56 |
170 def _RunUnitAndAppTests(api): | 57 def _RunUnitAndAppTests(api): |
171 with api.step.defer_results(): | 58 with api.step.defer_results(): |
172 api.chromium.runtest('html_viewer_unittests') | |
173 api.chromium.runtest('ipc_mojo_unittests') | 59 api.chromium.runtest('ipc_mojo_unittests') |
174 api.chromium.runtest('mojo_common_unittests') | 60 api.chromium.runtest('mojo_common_unittests') |
175 | 61 |
176 # TODO(yzshen): fix missing JS files on Android. crbug.com/536669 | 62 # TODO(yzshen): fix missing JS files on Android. crbug.com/536669 |
177 if api.chromium.c.TARGET_PLATFORM != 'android': | 63 if api.chromium.c.TARGET_PLATFORM != 'android': |
178 api.chromium.runtest('mojo_js_integration_tests') | 64 api.chromium.runtest('mojo_js_integration_tests') |
179 api.chromium.runtest('mojo_js_unittests') | 65 api.chromium.runtest('mojo_js_unittests') |
180 | 66 |
181 api.chromium.runtest('mojo_public_application_unittests') | 67 api.chromium.runtest('mojo_public_application_unittests') |
182 api.chromium.runtest('mojo_public_bindings_unittests') | 68 api.chromium.runtest('mojo_public_bindings_unittests') |
183 api.chromium.runtest('mojo_public_environment_unittests') | 69 api.chromium.runtest('mojo_public_environment_unittests') |
184 api.chromium.runtest('mojo_public_system_unittests') | 70 api.chromium.runtest('mojo_public_system_unittests') |
185 api.chromium.runtest('mojo_public_utility_unittests') | 71 api.chromium.runtest('mojo_public_utility_unittests') |
186 api.chromium.runtest('mojo_runner_host_unittests') | 72 api.chromium.runtest('mojo_runner_host_unittests') |
187 api.chromium.runtest('mojo_shell_unittests') | 73 api.chromium.runtest('mojo_shell_unittests') |
188 api.chromium.runtest('mojo_surfaces_lib_unittests') | 74 api.chromium.runtest('mojo_surfaces_lib_unittests') |
189 api.chromium.runtest('mojo_system_unittests') | 75 api.chromium.runtest('mojo_system_unittests') |
190 api.chromium.runtest('mojo_view_manager_lib_unittests') | 76 api.chromium.runtest('mojo_view_manager_lib_unittests') |
191 api.chromium.runtest('resource_provider_unittests') | 77 api.chromium.runtest('resource_provider_unittests') |
192 api.chromium.runtest('window_manager_unittests') | 78 api.chromium.runtest('window_manager_unittests') |
193 _RunApptests(api) | 79 _RunApptests(api) |
194 | 80 |
195 | 81 |
196 def _RunPerfTests(api, perf_test_info): | |
197 tests = api.chromium.list_perf_tests(perf_test_info['browser_type'], 1) | |
198 | |
199 # TODO(yzshen): Remove this filter once we annotate tests disabled for | |
200 # Mandoline in Telemetry. Consider reusing | |
201 # chromium_tests.steps.DynamicPerfTests. | |
202 tests = dict((k, v) for k, v in tests.json.output['steps'].iteritems() | |
203 if str(k) in perf_test_info['supported_testnames']) | |
204 | |
205 with api.step.defer_results(): | |
206 for test_name, test in sorted(tests.iteritems()): | |
207 test_name = str(test_name) | |
208 annotate = api.chromium.get_annotate_by_test_name(test_name) | |
209 cmd = test['cmd'].split() | |
210 cmd.extend( | |
211 ['--extra-browser-args=--override-use-gl-with-osmesa-for-tests']) | |
212 | |
213 api.chromium.runtest( | |
214 cmd[1] if len(cmd) > 1 else cmd[0], | |
215 args=cmd[2:], | |
216 name=test_name, | |
217 annotate=annotate, | |
218 python_mode=True, | |
219 results_url='https://chromeperf.appspot.com', | |
220 perf_dashboard_id=test.get('perf_dashboard_id', test_name), | |
221 perf_id=perf_test_info['perf_id'], | |
222 test_type=test.get('perf_dashboard_id', test_name), | |
223 xvfb=True, | |
224 chartjson_file=True) | |
225 | |
226 | |
227 def RunSteps(api): | 82 def RunSteps(api): |
228 # TODO(yzshen): Perf bots should retrieve build results from builders of the | |
229 # same architecture. | |
230 api.chromium.configure_bot(BUILDERS, ['gn']) | 83 api.chromium.configure_bot(BUILDERS, ['gn']) |
231 | 84 |
232 api.bot_update.ensure_checkout(force=True) | 85 api.bot_update.ensure_checkout(force=True) |
233 | 86 |
234 api.chromium.runhooks() | 87 api.chromium.runhooks() |
235 | 88 |
236 api.chromium.run_mb(api.properties.get('mastername'), | 89 api.chromium.run_mb(api.properties.get('mastername'), |
237 api.properties.get('buildername'), | 90 api.properties.get('buildername'), |
238 use_goma=True) | 91 use_goma=True) |
239 | 92 |
240 compile_targets = ['mandoline:all'] | 93 api.chromium.compile(targets=['mojo:tests', 'mojo_apptests']) |
241 if api.chromium.c.TARGET_PLATFORM != 'android': | |
242 compile_targets.append('mash/wm:tests') | |
243 api.chromium.compile(targets=compile_targets) | |
244 | 94 |
245 if api.chromium.c.TARGET_PLATFORM == 'android': | 95 if api.chromium.c.TARGET_PLATFORM == 'android': |
246 api.chromium_android.detect_and_setup_devices() | 96 api.chromium_android.detect_and_setup_devices() |
247 | 97 |
248 bot_config = _GetBotConfig(api) | 98 _RunUnitAndAppTests(api) |
249 if bot_config.get('run_perf_tests', False): | |
250 _RunPerfTests(api, bot_config['perf_test_info']) | |
251 else: | |
252 _RunUnitAndAppTests(api) | |
253 _UploadMandolineToGoogleStorage(api) | |
254 | 99 |
255 | 100 |
256 def GenTests(api): | 101 def GenTests(api): |
257 for test in api.chromium.gen_tests_for_builders(BUILDERS): | 102 for test in api.chromium.gen_tests_for_builders(BUILDERS): |
258 yield test | 103 yield test |
259 | |
260 # Ensure upload is skipped if version/platform binaries are already uploaded. | |
261 test = api.test('test_upload_skipped_for_existing_binaries') | |
262 test += api.platform.name('linux') | |
263 test += api.properties.generic(buildername='Chromium Mojo Android', | |
264 mastername='chromium.mojo') | |
265 # This relies on api.chromium.get_version's hard-coded step_test_data version. | |
266 test_ls = api.raw_io.output('gs://mandoline/37.0.2021.0/android/') | |
267 test += api.step_data('gsutil ls gs://mandoline/', stdout=test_ls) | |
268 test += api.step_data('gsutil ls gs://mandoline/37.0.2021.0', stdout=test_ls) | |
269 yield test | |
OLD | NEW |