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

Side by Side Diff: scripts/slave/recipes/skia/swarm_trigger.py

Issue 2099713002: Download the Android SDK as a CIPD package (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@cipd_swarm
Patch Set: Rebase Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 5
6 # Recipe module for Skia Swarming trigger. 6 # Recipe module for Skia Swarming trigger.
7 7
8 8
9 import json 9 import json
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 skia_recipes_dir, 161 skia_recipes_dir,
162 'linux', 162 'linux',
163 'isolate_recipes', 163 'isolate_recipes',
164 {}) 164 {})
165 return api.skia_swarming.batcharchive(['isolate_recipes'])[0][1] 165 return api.skia_swarming.batcharchive(['isolate_recipes'])[0][1]
166 166
167 167
168 def trigger_task(api, task_name, builder, master, slave, buildnumber, 168 def trigger_task(api, task_name, builder, master, slave, buildnumber,
169 builder_spec, got_revision, infrabots_dir, idempotent=False, 169 builder_spec, got_revision, infrabots_dir, idempotent=False,
170 store_output=True, extra_isolate_hashes=None, expiration=None, 170 store_output=True, extra_isolate_hashes=None, expiration=None,
171 hard_timeout=None, io_timeout=None): 171 hard_timeout=None, io_timeout=None, cipd_packages=None):
172 """Trigger the given bot to run as a Swarming task.""" 172 """Trigger the given bot to run as a Swarming task."""
173 # TODO(borenet): We're using Swarming directly to run the recipe through 173 # TODO(borenet): We're using Swarming directly to run the recipe through
174 # recipes.py. Once it's possible to track the state of a Buildbucket build, 174 # recipes.py. Once it's possible to track the state of a Buildbucket build,
175 # we should switch to use the trigger recipe module instead. 175 # we should switch to use the trigger recipe module instead.
176 176
177 properties = { 177 properties = {
178 'buildername': builder, 178 'buildername': builder,
179 'mastername': master, 179 'mastername': master,
180 'buildnumber': buildnumber, 180 'buildnumber': buildnumber,
181 'reason': 'Triggered by Skia swarm_trigger Recipe', 181 'reason': 'Triggered by Skia swarm_trigger Recipe',
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 '%s_skia' % task_name, 213 '%s_skia' % task_name,
214 isolate_vars, 214 isolate_vars,
215 dimensions, 215 dimensions,
216 isolate_blacklist=isolate_blacklist, 216 isolate_blacklist=isolate_blacklist,
217 extra_isolate_hashes=extra_isolate_hashes, 217 extra_isolate_hashes=extra_isolate_hashes,
218 idempotent=idempotent, 218 idempotent=idempotent,
219 store_output=store_output, 219 store_output=store_output,
220 extra_args=extra_args, 220 extra_args=extra_args,
221 expiration=expiration, 221 expiration=expiration,
222 hard_timeout=hard_timeout, 222 hard_timeout=hard_timeout,
223 io_timeout=io_timeout) 223 io_timeout=io_timeout,
224 cipd_packages=cipd_packages)
224 225
225 226
226 def checkout_steps(api): 227 def checkout_steps(api):
227 """Run the steps to obtain a checkout of Skia.""" 228 """Run the steps to obtain a checkout of Skia."""
228 gclient_cfg = api.gclient.make_config(CACHE_DIR=None) 229 gclient_cfg = api.gclient.make_config(CACHE_DIR=None)
229 skia = gclient_cfg.solutions.add() 230 skia = gclient_cfg.solutions.add()
230 skia.name = 'skia' 231 skia.name = 'skia'
231 skia.managed = False 232 skia.managed = False
232 skia.url = 'https://skia.googlesource.com/skia.git' 233 skia.url = 'https://skia.googlesource.com/skia.git'
233 skia.revision = api.properties.get('revision') or 'origin/master' 234 skia.revision = api.properties.get('revision') or 'origin/master'
(...skipping 21 matching lines...) Expand all
255 builder_spec, 256 builder_spec,
256 got_revision, 257 got_revision,
257 infrabots_dir, 258 infrabots_dir,
258 idempotent=False, 259 idempotent=False,
259 store_output=False, 260 store_output=False,
260 extra_isolate_hashes=extra_isolate_hashes) 261 extra_isolate_hashes=extra_isolate_hashes)
261 return api.skia_swarming.collect_swarming_task(task) 262 return api.skia_swarming.collect_swarming_task(task)
262 263
263 264
264 def compile_steps_swarm(api, builder_spec, got_revision, infrabots_dir, 265 def compile_steps_swarm(api, builder_spec, got_revision, infrabots_dir,
265 extra_isolate_hashes): 266 extra_isolate_hashes, cipd_packages):
266 builder_name = derive_compile_bot_name(api.properties['buildername'], 267 builder_name = derive_compile_bot_name(api.properties['buildername'],
267 builder_spec) 268 builder_spec)
268 compile_builder_spec = builder_spec 269 compile_builder_spec = builder_spec
269 if builder_name != api.properties['buildername']: 270 if builder_name != api.properties['buildername']:
270 compile_builder_spec = api.skia.get_builder_spec( 271 compile_builder_spec = api.skia.get_builder_spec(
271 api.path['slave_build'].join('skia'), builder_name) 272 api.path['slave_build'].join('skia'), builder_name)
272 273
273 extra_hashes = extra_isolate_hashes[:] 274 extra_hashes = extra_isolate_hashes[:]
274 275
275 # Windows bots require a toolchain. 276 # Windows bots require a toolchain.
(...skipping 22 matching lines...) Expand all
298 'compile', 299 'compile',
299 builder_name, 300 builder_name,
300 master, 301 master,
301 slave, 302 slave,
302 buildnumber, 303 buildnumber,
303 compile_builder_spec, 304 compile_builder_spec,
304 got_revision, 305 got_revision,
305 infrabots_dir, 306 infrabots_dir,
306 idempotent=True, 307 idempotent=True,
307 store_output=False, 308 store_output=False,
308 extra_isolate_hashes=extra_hashes) 309 extra_isolate_hashes=extra_hashes,
310 cipd_packages=cipd_packages)
309 311
310 # Wait for compile to finish, record the results hash. 312 # Wait for compile to finish, record the results hash.
311 return api.skia_swarming.collect_swarming_task_isolate_hash(task) 313 return api.skia_swarming.collect_swarming_task_isolate_hash(task)
312 314
313 315
314 def get_timeouts(builder_cfg): 316 def get_timeouts(builder_cfg):
315 """Some builders require longer than the default timeouts. 317 """Some builders require longer than the default timeouts.
316 318
317 Returns tuple of (expiration, hard_timeout, io_timeout). If those values are 319 Returns tuple of (expiration, hard_timeout, io_timeout). If those values are
318 none then default timeouts should be used. 320 none then default timeouts should be used.
319 """ 321 """
320 expiration = None 322 expiration = None
321 hard_timeout = None 323 hard_timeout = None
322 io_timeout = None 324 io_timeout = None
323 if 'Valgrind' in builder_cfg.get('extra_config', ''): 325 if 'Valgrind' in builder_cfg.get('extra_config', ''):
324 expiration = 2*24*60*60 326 expiration = 2*24*60*60
325 hard_timeout = 9*60*60 327 hard_timeout = 9*60*60
326 io_timeout = 60*60 328 io_timeout = 60*60
327 return expiration, hard_timeout, io_timeout 329 return expiration, hard_timeout, io_timeout
328 330
329 331
330 def perf_steps_trigger(api, builder_spec, got_revision, infrabots_dir, 332 def perf_steps_trigger(api, builder_spec, got_revision, infrabots_dir,
331 extra_hashes): 333 extra_hashes, cipd_packages):
332 """Trigger perf tests via Swarming.""" 334 """Trigger perf tests via Swarming."""
333 335
334 expiration, hard_timeout, io_timeout = get_timeouts( 336 expiration, hard_timeout, io_timeout = get_timeouts(
335 builder_spec['builder_cfg']) 337 builder_spec['builder_cfg'])
336 return trigger_task( 338 return trigger_task(
337 api, 339 api,
338 'perf', 340 'perf',
339 api.properties['buildername'], 341 api.properties['buildername'],
340 api.properties['mastername'], 342 api.properties['mastername'],
341 api.properties['slavename'], 343 api.properties['slavename'],
342 api.properties['buildnumber'], 344 api.properties['buildnumber'],
343 builder_spec, 345 builder_spec,
344 got_revision, 346 got_revision,
345 infrabots_dir, 347 infrabots_dir,
346 extra_isolate_hashes=extra_hashes, 348 extra_isolate_hashes=extra_hashes,
347 expiration=expiration, 349 expiration=expiration,
348 hard_timeout=hard_timeout, 350 hard_timeout=hard_timeout,
349 io_timeout=io_timeout) 351 io_timeout=io_timeout,
352 cipd_packages=cipd_packages)
350 353
351 354
352 def perf_steps_collect(api, task, upload_perf_results, got_revision, 355 def perf_steps_collect(api, task, upload_perf_results, got_revision,
353 is_trybot): 356 is_trybot):
354 """Wait for perf steps to finish and upload results.""" 357 """Wait for perf steps to finish and upload results."""
355 # Wait for nanobench to finish, download the results. 358 # Wait for nanobench to finish, download the results.
356 api.file.rmtree('results_dir', task.task_output_dir, infra_step=True) 359 api.file.rmtree('results_dir', task.task_output_dir, infra_step=True)
357 api.skia_swarming.collect_swarming_task(task) 360 api.skia_swarming.collect_swarming_task(task)
358 361
359 # Upload the results. 362 # Upload the results.
(...skipping 21 matching lines...) Expand all
381 api.python( 384 api.python(
382 'Upload perf results', 385 'Upload perf results',
383 script=api.skia.resource('upload_bench_results.py'), 386 script=api.skia.resource('upload_bench_results.py'),
384 args=upload_args, 387 args=upload_args,
385 cwd=api.path['checkout'], 388 cwd=api.path['checkout'],
386 env=api.skia.gsutil_env('chromium-skia-gm.boto'), 389 env=api.skia.gsutil_env('chromium-skia-gm.boto'),
387 infra_step=True) 390 infra_step=True)
388 391
389 392
390 def test_steps_trigger(api, builder_spec, got_revision, infrabots_dir, 393 def test_steps_trigger(api, builder_spec, got_revision, infrabots_dir,
391 extra_hashes): 394 extra_hashes, cipd_packages):
392 """Trigger DM via Swarming.""" 395 """Trigger DM via Swarming."""
393 expiration, hard_timeout, io_timeout = get_timeouts( 396 expiration, hard_timeout, io_timeout = get_timeouts(
394 builder_spec['builder_cfg']) 397 builder_spec['builder_cfg'])
395 return trigger_task( 398 return trigger_task(
396 api, 399 api,
397 'test', 400 'test',
398 api.properties['buildername'], 401 api.properties['buildername'],
399 api.properties['mastername'], 402 api.properties['mastername'],
400 api.properties['slavename'], 403 api.properties['slavename'],
401 api.properties['buildnumber'], 404 api.properties['buildnumber'],
402 builder_spec, 405 builder_spec,
403 got_revision, 406 got_revision,
404 infrabots_dir, 407 infrabots_dir,
405 extra_isolate_hashes=extra_hashes, 408 extra_isolate_hashes=extra_hashes,
406 expiration=expiration, 409 expiration=expiration,
407 hard_timeout=hard_timeout, 410 hard_timeout=hard_timeout,
408 io_timeout=io_timeout) 411 io_timeout=io_timeout,
412 cipd_packages=cipd_packages)
409 413
410 414
411 def test_steps_collect(api, task, upload_dm_results, got_revision, is_trybot, 415 def test_steps_collect(api, task, upload_dm_results, got_revision, is_trybot,
412 builder_cfg): 416 builder_cfg):
413 """Collect the test results from Swarming.""" 417 """Collect the test results from Swarming."""
414 # Wait for tests to finish, download the results. 418 # Wait for tests to finish, download the results.
415 api.file.rmtree('results_dir', task.task_output_dir, infra_step=True) 419 api.file.rmtree('results_dir', task.task_output_dir, infra_step=True)
416 api.skia_swarming.collect_swarming_task(task) 420 api.skia_swarming.collect_swarming_task(task)
417 421
418 # Upload the results. 422 # Upload the results.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 api.skia_swarming.setup( 528 api.skia_swarming.setup(
525 api.path['checkout'].join('infra', 'bots', 'tools', 'luci-go'), 529 api.path['checkout'].join('infra', 'bots', 'tools', 'luci-go'),
526 swarming_rev='') 530 swarming_rev='')
527 531
528 # Run gsutil.py to ensure that it's installed. 532 # Run gsutil.py to ensure that it's installed.
529 api.gsutil(['help']) 533 api.gsutil(['help'])
530 534
531 recipes_hash = isolate_recipes(api) 535 recipes_hash = isolate_recipes(api)
532 extra_hashes = [recipes_hash] 536 extra_hashes = [recipes_hash]
533 537
538 # Get ready to compile.
539 compile_cipd_deps = []
540 extra_compile_hashes = [recipes_hash]
541
534 # Android bots require an SDK. 542 # Android bots require an SDK.
535 if 'Android' in api.properties['buildername']: 543 if 'Android' in api.properties['buildername']:
536 test_data = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' 544 android_sdk_version_file = infrabots_dir.join(
537 hash_file = infrabots_dir.join('android_sdk_hash') 545 'assets', 'android_sdk', 'VERSION')
538 # try/except as a temporary measure to prevent breakages for backfills 546 if api.path.exists(android_sdk_version_file):
539 # and branches. 547 android_sdk_version = api.skia._readfile(android_sdk_version_file,
540 try: 548 name='read android_sdk VERSION',
541 h = api.skia._readfile(hash_file, 549 test_data='0').rstrip()
542 name='Read android_sdk_hash', 550 android_sdk_version = 'version:%s' % android_sdk_version
543 test_data=test_data).rstrip() 551 pkg = ('android_sdk', 'skia/bots/android_sdk', android_sdk_version)
544 except api.step.StepFailure: 552 compile_cipd_deps.append(pkg)
545 # Just fall back on the original hash. 553 else:
546 h = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' 554 # TODO(borenet): Remove this legacy method after 7/1/2016.
547 extra_hashes.append(h) 555 test_data = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee'
556 hash_file = infrabots_dir.join('android_sdk_hash')
557 # try/except as a temporary measure to prevent breakages for backfills
558 # and branches.
559 try:
560 h = api.skia._readfile(hash_file,
561 name='Read android_sdk_hash',
562 test_data=test_data).rstrip()
563 except api.step.StepFailure:
564 # Just fall back on the original hash.
565 h = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee'
566 extra_hashes.append(h)
567 extra_compile_hashes.append(h)
548 568
569 # Compile.
549 do_compile_steps = builder_spec.get('do_compile_steps', True) 570 do_compile_steps = builder_spec.get('do_compile_steps', True)
550 compile_hash = None
551 if do_compile_steps: 571 if do_compile_steps:
552 compile_hash = compile_steps_swarm(api, builder_spec, got_revision, 572 extra_hashes.append(compile_steps_swarm(
553 infrabots_dir, extra_hashes) 573 api, builder_spec, got_revision, infrabots_dir, extra_compile_hashes,
574 cipd_packages=compile_cipd_deps))
554 575
555 if builder_cfg['role'] == 'Housekeeper': 576 if builder_cfg['role'] == 'Housekeeper':
556 housekeeper_swarm(api, builder_spec, got_revision, infrabots_dir, 577 housekeeper_swarm(api, builder_spec, got_revision, infrabots_dir,
557 extra_hashes) 578 extra_hashes)
558 return 579 return
559 580
581 # Get ready to test/perf.
582
583 # CIPD packages needed by test/perf.
584 cipd_packages = []
585
560 do_test_steps = builder_spec['do_test_steps'] 586 do_test_steps = builder_spec['do_test_steps']
561 do_perf_steps = builder_spec['do_perf_steps'] 587 do_perf_steps = builder_spec['do_perf_steps']
562 588
563 if not (do_test_steps or do_perf_steps): 589 if not (do_test_steps or do_perf_steps):
564 return 590 return
565 591
566 if compile_hash:
567 extra_hashes.append(compile_hash)
568
569 api.skia.download_skps(api.path['slave_build'].join('tmp'), 592 api.skia.download_skps(api.path['slave_build'].join('tmp'),
570 api.path['slave_build'].join('skps')) 593 api.path['slave_build'].join('skps'))
571 api.skia.download_images(api.path['slave_build'].join('tmp'), 594 api.skia.download_images(api.path['slave_build'].join('tmp'),
572 api.path['slave_build'].join('images')) 595 api.path['slave_build'].join('images'))
573 596
574 test_task = None 597 test_task = None
575 perf_task = None 598 perf_task = None
576 if do_test_steps: 599 if do_test_steps:
577 test_task = test_steps_trigger(api, builder_spec, got_revision, 600 test_task = test_steps_trigger(api, builder_spec, got_revision,
578 infrabots_dir, extra_hashes) 601 infrabots_dir, extra_hashes, cipd_packages)
579 if do_perf_steps: 602 if do_perf_steps:
580 perf_task = perf_steps_trigger(api, builder_spec, got_revision, 603 perf_task = perf_steps_trigger(api, builder_spec, got_revision,
581 infrabots_dir, extra_hashes) 604 infrabots_dir, extra_hashes, cipd_packages)
582 is_trybot = builder_cfg['is_trybot'] 605 is_trybot = builder_cfg['is_trybot']
583 if test_task: 606 if test_task:
584 test_steps_collect(api, test_task, builder_spec['upload_dm_results'], 607 test_steps_collect(api, test_task, builder_spec['upload_dm_results'],
585 got_revision, is_trybot, builder_cfg) 608 got_revision, is_trybot, builder_cfg)
586 if perf_task: 609 if perf_task:
587 perf_steps_collect(api, perf_task, builder_spec['upload_perf_results'], 610 perf_steps_collect(api, perf_task, builder_spec['upload_perf_results'],
588 got_revision, is_trybot) 611 got_revision, is_trybot)
589 612
590 613
591 def test_for_bot(api, builder, mastername, slavename, testname=None): 614 def test_for_bot(api, builder, mastername, slavename, testname=None,
615 legacy_android_sdk=False):
592 """Generate a test for the given bot.""" 616 """Generate a test for the given bot."""
593 testname = testname or builder 617 testname = testname or builder
594 test = ( 618 test = (
595 api.test(testname) + 619 api.test(testname) +
596 api.properties(buildername=builder, 620 api.properties(buildername=builder,
597 mastername=mastername, 621 mastername=mastername,
598 slavename=slavename, 622 slavename=slavename,
599 buildnumber=5, 623 buildnumber=5,
600 revision='abc123') + 624 revision='abc123') +
601 api.path.exists( 625 api.path.exists(
602 api.path['slave_build'].join('skia'), 626 api.path['slave_build'].join('skia'),
603 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') 627 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt')
604 ) 628 )
605 ) 629 )
606 if 'Trybot' in builder: 630 if 'Trybot' in builder:
607 test += api.properties(issue=500, 631 test += api.properties(issue=500,
608 patchset=1, 632 patchset=1,
609 rietveld='https://codereview.chromium.org') 633 rietveld='https://codereview.chromium.org')
634 if 'Android' in builder:
635 if not legacy_android_sdk:
636 test += api.path.exists(api.path['slave_build'].join(
637 'skia', 'infra', 'bots', 'assets', 'android_sdk', 'VERSION'))
610 if 'Coverage' not in builder: 638 if 'Coverage' not in builder:
611 test += api.step_data( 639 test += api.step_data(
612 'upload new .isolated file for compile_skia', 640 'upload new .isolated file for compile_skia',
613 stdout=api.raw_io.output('def456 XYZ.isolated')) 641 stdout=api.raw_io.output('def456 XYZ.isolated'))
614 if 'Test' in builder: 642 if 'Test' in builder:
615 test += api.step_data( 643 test += api.step_data(
616 'upload new .isolated file for test_skia', 644 'upload new .isolated file for test_skia',
617 stdout=api.raw_io.output('def456 XYZ.isolated')) 645 stdout=api.raw_io.output('def456 XYZ.isolated'))
618 if ('Test' in builder and 'Debug' in builder) or 'Perf' in builder or ( 646 if ('Test' in builder and 'Debug' in builder) or 'Perf' in builder or (
619 'Valgrind' in builder and 'Test' in builder): 647 'Valgrind' in builder and 'Test' in builder):
(...skipping 30 matching lines...) Expand all
650 test += api.properties(test_downloaded_skp_version='999') 678 test += api.properties(test_downloaded_skp_version='999')
651 test += api.path.exists( 679 test += api.path.exists(
652 api.path['slave_build'].join('skia'), 680 api.path['slave_build'].join('skia'),
653 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') 681 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt')
654 ) 682 )
655 yield test 683 yield test
656 684
657 builder = 'Build-Ubuntu-GCC-Arm7-Release-Android_Vulkan' 685 builder = 'Build-Ubuntu-GCC-Arm7-Release-Android_Vulkan'
658 master = 'client.skia.compile' 686 master = 'client.skia.compile'
659 slave = 'skiabot-linux-compile-000' 687 slave = 'skiabot-linux-compile-000'
660 test = test_for_bot(api, builder, master, slave, 'Missing_android_sdk_hash') 688 test = test_for_bot(api, builder, master, slave, 'legacy_android_sdk',
689 legacy_android_sdk=True)
690 test += api.step_data('Read android_sdk_hash',
691 stdout=api.raw_io.output('<android_sdk_hash>'))
692 yield test
693
694 test = test_for_bot(api, builder, master, slave, 'Missing_android_sdk_hash',
695 legacy_android_sdk=True)
661 test += api.step_data('Read android_sdk_hash', retcode=1) 696 test += api.step_data('Read android_sdk_hash', retcode=1)
662 yield test 697 yield test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698