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

Side by Side Diff: scripts/slave/recipes/chromium_trybot.py

Issue 1574433004: Allow a single trybot to mirror multiple waterfall bots. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@bot-config-and-test-db
Patch Set: Created 4 years, 11 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 collections 5 import collections
6 6
7 from recipe_engine.types import freeze 7 from recipe_engine.types import freeze
8 8
9 DEPS = [ 9 DEPS = [
10 'amp', 10 'amp',
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 for test in tests 192 for test in tests
193 for x in test.compile_targets(api))) 193 for x in test.compile_targets(api)))
194 194
195 195
196 def is_source_file(api, filepath): 196 def is_source_file(api, filepath):
197 """Returns true iff the file is a source file.""" 197 """Returns true iff the file is a source file."""
198 _, ext = api.path.splitext(filepath) 198 _, ext = api.path.splitext(filepath)
199 return ext in ['.c', '.cc', '.cpp', '.h', '.java', '.mm'] 199 return ext in ['.c', '.cc', '.cpp', '.h', '.java', '.mm']
200 200
201 def _RunStepsInternal(api): 201 def _RunStepsInternal(api):
202 def _get_bot_config(mastername, buildername): 202 # This returns either a single dictionary or list of dictionaries
203 # that contain the 'mastername' and 'buildername' properties. This
204 # is the 'bot_desc' concept rather than the 'bot_config' concept.
205 def _get_bot_desc(mastername, buildername):
203 master_dict = api.chromium_tests.trybots.get(mastername, {}) 206 master_dict = api.chromium_tests.trybots.get(mastername, {})
204 return master_dict.get('builders', {}).get(buildername) 207 return master_dict.get('builders', {}).get(buildername)
205 208
206 mastername = api.properties.get('mastername') 209 mastername = api.properties.get('mastername')
207 buildername = api.properties.get('buildername') 210 buildername = api.properties.get('buildername')
208 bot_config = _get_bot_config(mastername, buildername) 211 bot_descs = _get_bot_desc(mastername, buildername)
212 # Support the case where a single trybot picks up compile targets
213 # and tests from multiple bots.
214 bot_descs = api.chromium_tests.normalize_bot_descs(bot_descs)
209 215
210 # TODO(sergiyb): This is a temporary hack to run GPU tests on tryserver 216 # TODO(sergiyb): This is a temporary hack to run GPU tests on tryserver
211 # only. This should be removed when we will convert chromium.gpu waterfall 217 # only. This should be removed when we will convert chromium.gpu waterfall
212 # to swarming and be able to replicate the tests to tryserver automatically. 218 # to swarming and be able to replicate the tests to tryserver automatically.
213 master = api.properties['mastername'] 219 master = api.properties['mastername']
214 builder = api.properties['buildername'] 220 builder = api.properties['buildername']
215 enable_gpu_tests = builder in CHROMIUM_GPU_DIMENSION_SETS.get(master, {}) 221 enable_gpu_tests = builder in CHROMIUM_GPU_DIMENSION_SETS.get(master, {})
216 222
217 api.chromium_tests.configure_build( 223 api.chromium_tests.configure_build(
218 bot_config['mastername'], 224 bot_descs,
219 bot_config['buildername'],
220 override_bot_type='builder_tester') 225 override_bot_type='builder_tester')
221 226
222 api.chromium_tests.configure_swarming('chromium', precommit=True) 227 api.chromium_tests.configure_swarming('chromium', precommit=True)
223 228
224 api.chromium.apply_config('trybot_flavor') 229 api.chromium.apply_config('trybot_flavor')
225 if enable_gpu_tests: 230 if enable_gpu_tests:
226 api.chromium.apply_config('archive_gpu_tests') 231 # TODO(kbr): the "optional" flag is only being used during the
227 api.chromium.apply_config('chrome_with_codecs') 232 # transition from the GPU recipe to the Chromium recipe. This
233 # entire if-test will soon be removed.
234 api.chromium.apply_config('archive_gpu_tests', optional=True)
235 api.chromium.apply_config('chrome_with_codecs', optional=True)
228 236
229 if api.properties.get('patch_project') == 'blink': # pragma: no cover 237 if api.properties.get('patch_project') == 'blink': # pragma: no cover
230 raise Exception('CLs which use blink project are not supported. ' 238 raise Exception('CLs which use blink project are not supported. '
231 'Please re-create the CL using fresh checkout after ' 239 'Please re-create the CL using fresh checkout after '
232 'the blink merge.') 240 'the blink merge.')
233 241
234 bot_update_step, bot_db = \ 242 bot_update_step, bot_db = \
235 api.chromium_tests.prepare_checkout( 243 api.chromium_tests.prepare_checkout(bot_descs)
236 bot_config['mastername'],
237 bot_config['buildername'])
238 244
239 tests = list(api.chromium_tests.tests_for_builder( 245 tests = []
240 bot_config['mastername'], 246 for bot_desc in bot_descs:
241 bot_config['buildername'],
242 bot_update_step,
243 bot_db,
244 override_bot_type='builder_tester'))
245 tester = bot_config.get('tester', '')
246 if tester:
247 test_config = bot_db.get_bot_config(bot_config['mastername'], tester)
248 for key, value in test_config.get('swarming_dimensions', {}).iteritems():
249 api.swarming.set_default_dimension(key, value)
250 tests.extend(api.chromium_tests.tests_for_builder( 247 tests.extend(api.chromium_tests.tests_for_builder(
251 bot_config['mastername'], 248 bot_desc['mastername'],
252 tester, 249 bot_desc['buildername'],
253 bot_update_step, 250 bot_update_step,
254 bot_db, 251 bot_db,
255 override_bot_type='builder_tester')) 252 override_bot_type='builder_tester'))
253 tester = bot_desc.get('tester', '')
254 if tester:
255 test_config = bot_db.get_bot_config(bot_desc['mastername'], tester)
256 for key, value in test_config.get('swarming_dimensions', {}).iteritems():
257 api.swarming.set_default_dimension(key, value)
258 tests.extend(api.chromium_tests.tests_for_builder(
259 bot_desc['mastername'],
260 tester,
261 bot_update_step,
262 bot_db,
263 override_bot_type='builder_tester'))
256 264
257 if enable_gpu_tests: 265 if enable_gpu_tests:
258 tests.extend(api.gpu.create_tests( 266 tests.extend(api.gpu.create_tests(
259 bot_update_step.presentation.properties['got_revision'], 267 bot_update_step.presentation.properties['got_revision'],
260 bot_update_step.presentation.properties['got_revision'], 268 bot_update_step.presentation.properties['got_revision'],
261 enable_swarming=True, 269 enable_swarming=True,
262 swarming_dimension_sets=CHROMIUM_GPU_DIMENSION_SETS[master][builder])) 270 swarming_dimension_sets=CHROMIUM_GPU_DIMENSION_SETS[master][builder]))
263 271
264 affected_files = api.tryserver.get_files_affected_by_patch() 272 affected_files = api.tryserver.get_files_affected_by_patch()
265 273
(...skipping 22 matching lines...) Expand all
288 if add_blink_tests: 296 if add_blink_tests:
289 tests.extend([ 297 tests.extend([
290 api.chromium_tests.steps.GTestTest('blink_heap_unittests'), 298 api.chromium_tests.steps.GTestTest('blink_heap_unittests'),
291 api.chromium_tests.steps.GTestTest('blink_platform_unittests'), 299 api.chromium_tests.steps.GTestTest('blink_platform_unittests'),
292 api.chromium_tests.steps.GTestTest('webkit_unit_tests'), 300 api.chromium_tests.steps.GTestTest('webkit_unit_tests'),
293 api.chromium_tests.steps.GTestTest('wtf_unittests'), 301 api.chromium_tests.steps.GTestTest('wtf_unittests'),
294 ]) 302 ])
295 303
296 compile_targets, tests_including_triggered = \ 304 compile_targets, tests_including_triggered = \
297 api.chromium_tests.get_compile_targets_and_tests( 305 api.chromium_tests.get_compile_targets_and_tests(
298 bot_config['mastername'], 306 bot_descs,
299 bot_config['buildername'],
300 bot_db, 307 bot_db,
301 override_bot_type='builder_tester', 308 override_bot_type='builder_tester',
302 override_tests=tests) 309 override_tests=tests)
303 310
304 test_targets = sorted(set( 311 test_targets = sorted(set(
305 all_compile_targets(api, tests + tests_including_triggered))) 312 all_compile_targets(api, tests + tests_including_triggered)))
306 additional_compile_targets = sorted(set(compile_targets) - 313 additional_compile_targets = sorted(set(compile_targets) -
307 set(test_targets)) 314 set(test_targets))
308 test_targets, compile_targets = \ 315 test_targets, compile_targets = \
309 api.chromium_tests.analyze(affected_files, 316 api.chromium_tests.analyze(affected_files,
310 test_targets, 317 test_targets,
311 additional_compile_targets, 318 additional_compile_targets,
312 'trybot_analyze_config.json') 319 'trybot_analyze_config.json')
313 320
314 if bot_config.get('analyze_mode') == 'compile': 321 if bot_descs[0].get('analyze_mode') == 'compile':
Sergey Berezin 2016/01/12 01:44:23 nit: this makes the [0]'th configuration "special"
Ken Russell (switch to Gerrit) 2016/01/12 05:35:51 I didn't understand this code nor the ramification
315 tests = [] 322 tests = []
316 tests_including_triggered = [] 323 tests_including_triggered = []
317 324
318 # Blink tests have to bypass "analyze", see below. 325 # Blink tests have to bypass "analyze", see below.
319 if compile_targets or add_blink_tests: 326 if compile_targets or add_blink_tests:
320 tests = tests_in_compile_targets(api, test_targets, tests) 327 tests = tests_in_compile_targets(api, test_targets, tests)
321 tests_including_triggered = tests_in_compile_targets( 328 tests_including_triggered = tests_in_compile_targets(
322 api, test_targets, tests_including_triggered) 329 api, test_targets, tests_including_triggered)
323 330
324 # Blink tests are tricky at this moment. We'd like to use "analyze" for 331 # Blink tests are tricky at this moment. We'd like to use "analyze" for
325 # everything else. However, there are blink changes that only add or modify 332 # everything else. However, there are blink changes that only add or modify
326 # layout test files (html etc). This is not recognized by "analyze" as 333 # layout test files (html etc). This is not recognized by "analyze" as
327 # compile dependency. However, the blink tests should still be executed. 334 # compile dependency. However, the blink tests should still be executed.
328 if add_blink_tests: 335 if add_blink_tests:
329 blink_tests = [ 336 blink_tests = [
330 api.chromium_tests.steps.ScriptTest( 337 api.chromium_tests.steps.ScriptTest(
331 'webkit_lint', 'webkit_lint.py', collections.defaultdict(list)), 338 'webkit_lint', 'webkit_lint.py', collections.defaultdict(list)),
332 api.chromium_tests.steps.ScriptTest( 339 api.chromium_tests.steps.ScriptTest(
333 'webkit_python_tests', 'webkit_python_tests.py', 340 'webkit_python_tests', 'webkit_python_tests.py',
334 collections.defaultdict(list)), 341 collections.defaultdict(list)),
335 api.chromium_tests.steps.BlinkTest(), 342 api.chromium_tests.steps.BlinkTest(),
336 ] 343 ]
337 tests.extend(blink_tests) 344 tests.extend(blink_tests)
338 tests_including_triggered.extend(blink_tests) 345 tests_including_triggered.extend(blink_tests)
339 for test in blink_tests: 346 for test in blink_tests:
340 compile_targets.extend(test.compile_targets(api)) 347 compile_targets.extend(test.compile_targets(api))
341 compile_targets = sorted(set(compile_targets)) 348 compile_targets = sorted(set(compile_targets))
342 349
343 api.chromium_tests.compile_specific_targets( 350 api.chromium_tests.compile_specific_targets(
344 bot_config['mastername'], 351 bot_descs[0]['mastername'],
345 bot_config['buildername'], 352 bot_descs[0]['buildername'],
346 bot_update_step, 353 bot_update_step,
347 bot_db, 354 bot_db,
348 compile_targets, 355 compile_targets,
349 tests_including_triggered, 356 tests_including_triggered,
350 override_bot_type='builder_tester') 357 override_bot_type='builder_tester')
351 else: 358 else:
352 # Even though the patch doesn't require a compile on this platform, 359 # Even though the patch doesn't require a compile on this platform,
353 # we'd still like to run tests not depending on 360 # we'd still like to run tests not depending on
354 # compiled targets (that's obviously not covered by the 361 # compiled targets (that's obviously not covered by the
355 # 'analyze' step) if any source files change. 362 # 'analyze' step) if any source files change.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 }, 418 },
412 'chromium': { 419 'chromium': {
413 'exclusions': [], 420 'exclusions': [],
414 }, 421 },
415 }) 422 })
416 ) 423 )
417 424
418 # While not strictly required for coverage, record expectations for each 425 # While not strictly required for coverage, record expectations for each
419 # of the configs so we can see when and how they change. 426 # of the configs so we can see when and how they change.
420 for mastername, master_config in api.chromium_tests.trybots.iteritems(): 427 for mastername, master_config in api.chromium_tests.trybots.iteritems():
421 for buildername, bot_config in master_config['builders'].iteritems(): 428 for buildername, bot_desc in master_config['builders'].iteritems():
422 for analyze in ['', '_analyze']: 429 for analyze in ['', '_analyze']:
423 test_name = 'full_%s_%s%s' % (_sanitize_nonalpha(mastername), 430 test_name = 'full_%s_%s%s' % (_sanitize_nonalpha(mastername),
424 _sanitize_nonalpha(buildername), 431 _sanitize_nonalpha(buildername),
425 analyze) 432 analyze)
433 bot_desc = api.chromium_tests.normalize_bot_descs(bot_desc)
426 yield ( 434 yield (
427 api.test(test_name) + 435 api.test(test_name) +
436 # In the case where a trybot mirrors multiple waterfall
437 # bots, pick up the platform from the first one. (They
438 # should all be identical, anyway.)
428 api.chromium_tests.platform( 439 api.chromium_tests.platform(
429 bot_config['mastername'], bot_config['buildername']) + 440 bot_desc[0]['mastername'], bot_desc[0]['buildername']) +
430 (api.empty_test_data() if analyze else suppress_analyze()) + 441 (api.empty_test_data() if analyze else suppress_analyze()) +
431 props(mastername=mastername, buildername=buildername) 442 props(mastername=mastername, buildername=buildername)
432 ) 443 )
433 444
434 # Additional tests for blink trybots. 445 # Additional tests for blink trybots.
435 blink_trybots = api.chromium_tests.trybots['tryserver.blink']['builders'] 446 blink_trybots = api.chromium_tests.trybots['tryserver.blink']['builders']
436 for buildername, bot_config in blink_trybots.iteritems(): 447 for buildername, bot_config in blink_trybots.iteritems():
437 if bot_config.get('analyze_mode') == 'compile': 448 if bot_config.get('analyze_mode') == 'compile':
438 continue 449 continue
439 450
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 api.test_utils.canned_test_output(passing=True)) 1086 api.test_utils.canned_test_output(passing=True))
1076 ) 1087 )
1077 1088
1078 yield ( 1089 yield (
1079 api.test('use_v8_patch_on_blink_trybot') + 1090 api.test('use_v8_patch_on_blink_trybot') +
1080 props(mastername='tryserver.blink', 1091 props(mastername='tryserver.blink',
1081 buildername='mac_blink_rel', 1092 buildername='mac_blink_rel',
1082 patch_project='v8') + 1093 patch_project='v8') +
1083 api.platform.name('mac') 1094 api.platform.name('mac')
1084 ) 1095 )
1096
1097 # This tests the scenario where one trybot mirrors multiple
1098 # waterfall bots. Right now, linux_chromium_rel_ng has the GPU tests
1099 # hardwired in. The presence of base_unittests in the output with
1100 # the configuration below shows that the mirroring is working
1101 # correctly. (Once the bot is switched from the GPU to the Chromium
1102 # recipe, the test setup and expectations will be updated -- no
1103 # reminder necessary, they'll have to be.)
1104 yield (
1105 api.test('trybot_mirrors_multiple_waterfall_bots') +
1106 api.properties.tryserver(
1107 mastername='tryserver.chromium.linux',
1108 buildername='linux_chromium_rel_ng',
1109 path_config='swarming',
1110 ) +
1111 api.platform.name('linux') +
1112 suppress_analyze() +
1113 api.override_step_data('read test spec (chromium.gpu)', api.json.output({
1114 'Fake Linux Release (NVIDIA)': {
1115 'gtest_tests': ['base_unittests'],
1116 },
1117 }))
1118 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698