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

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

Issue 2068123002: Add Swarming task for downloading Android SDK on Skia bots (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Expectations, fix names Created 4 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
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 'scripts', 'slave', 'recipes', 'skia') 158 'scripts', 'slave', 'recipes', 'skia')
159 api.skia_swarming.create_isolated_gen_json( 159 api.skia_swarming.create_isolated_gen_json(
160 skia_recipes_dir.join('swarm_recipe.isolate'), 160 skia_recipes_dir.join('swarm_recipe.isolate'),
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 isolate_gsutil(api):
169 """Isolate gsutil from the depot_tools checkout."""
170 skia_recipes_dir = api.path['build'].join(
171 'scripts', 'slave', 'recipes', 'skia')
172 api.skia_swarming.create_isolated_gen_json(
173 skia_recipes_dir.join('gsutil.isolate'),
174 skia_recipes_dir,
175 'linux',
176 'isolate_gsutil',
177 {})
178 return api.skia_swarming.batcharchive(['isolate_gsutil'])[0][1]
179
180
168 def trigger_task(api, task_name, builder, master, slave, buildnumber, 181 def trigger_task(api, task_name, builder, master, slave, buildnumber,
169 builder_spec, got_revision, infrabots_dir, idempotent=False, 182 builder_spec, got_revision, infrabots_dir, idempotent=False,
170 store_output=True, extra_isolate_hashes=None, expiration=None, 183 store_output=True, extra_isolate_hashes=None, expiration=None,
171 hard_timeout=None, io_timeout=None): 184 hard_timeout=None, io_timeout=None):
172 """Trigger the given bot to run as a Swarming task.""" 185 """Trigger the given bot to run as a Swarming task."""
173 # TODO(borenet): We're using Swarming directly to run the recipe through 186 # 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, 187 # 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. 188 # we should switch to use the trigger recipe module instead.
176 189
177 properties = { 190 properties = {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 api.gsutil.upload( 520 api.gsutil.upload(
508 name='upload line-by-line coverage data', 521 name='upload line-by-line coverage data',
509 source=dst_lbl_file, 522 source=dst_lbl_file,
510 bucket='skia-infra', 523 bucket='skia-infra',
511 dest='/'.join(('coverage-json-v1', gs_json_path, 524 dest='/'.join(('coverage-json-v1', gs_json_path,
512 dst_lbl_file_basename)), 525 dst_lbl_file_basename)),
513 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None}, 526 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None},
514 ) 527 )
515 528
516 529
530 def download_asset(api, infrabots_dir, depot_tools_hash, asset):
531 """Trigger a swarming task to download and isolate the given asset."""
532 return api.skia_swarming.isolate_and_trigger_task(
533 infrabots_dir.join('download_asset.isolate'),
534 api.path['slave_build'],
535 'download_%s' % asset,
536 {'ASSET': asset, 'GSUTIL': '../../../../../depot_tools/gsutil.py'},
537 {'pool': 'Skia', 'os': 'Ubuntu'},
538 extra_isolate_hashes=[depot_tools_hash],
539 idempotent=True,
540 isolate_blacklist=['.git', 'out', '*.pyc'],
541 store_output=False,
542 )
543
544
545 def collect_hashes(api, tasks):
546 """Collect the isolated hash for each swarming task."""
547 return [
548 api.skia_swarming.collect_swarming_task_isolate_hash(t) for t in tasks]
549
550
517 def RunSteps(api): 551 def RunSteps(api):
518 got_revision = checkout_steps(api) 552 got_revision = checkout_steps(api)
519 builder_spec = api.skia.get_builder_spec(api.path['checkout'], 553 builder_spec = api.skia.get_builder_spec(api.path['checkout'],
520 api.properties['buildername']) 554 api.properties['buildername'])
521 builder_cfg = builder_spec['builder_cfg'] 555 builder_cfg = builder_spec['builder_cfg']
522 infrabots_dir = api.path['checkout'].join('infra', 'bots') 556 infrabots_dir = api.path['checkout'].join('infra', 'bots')
523 557
524 api.skia_swarming.setup( 558 api.skia_swarming.setup(
525 api.path['checkout'].join('infra', 'bots', 'tools', 'luci-go'), 559 api.path['checkout'].join('infra', 'bots', 'tools', 'luci-go'),
526 swarming_rev='') 560 swarming_rev='')
527 561
528 # Run gsutil.py to ensure that it's installed. 562 # Run gsutil.py to ensure that it's installed.
529 api.gsutil(['help']) 563 api.gsutil(['help'])
530 564
531 recipes_hash = isolate_recipes(api) 565 recipes_hash = isolate_recipes(api)
532 extra_hashes = [recipes_hash] 566 extra_hashes = [recipes_hash]
533 567
568 # Some tasks only need depot_tools.
569 depot_tools_hash = isolate_gsutil(api)
570
571 # Get ready to compile.
572 compile_deps = []
573 extra_compile_hashes = [recipes_hash]
574
534 # Android bots require an SDK. 575 # Android bots require an SDK.
535 if 'Android' in api.properties['buildername']: 576 if 'Android' in api.properties['buildername']:
536 test_data = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' 577 if api.path.exists(infrabots_dir.join('assets', 'android_sdk')):
537 hash_file = infrabots_dir.join('android_sdk_hash') 578 compile_deps.append(download_asset(
538 # try/except as a temporary measure to prevent breakages for backfills 579 api, infrabots_dir, depot_tools_hash, 'android_sdk'))
539 # and branches. 580 else:
540 try: 581 # TODO(borenet): Remove this legacy method after 7/1/2016.
rmistry 2016/06/16 12:34:20 Why after 7/1/2016?
borenet 2016/06/16 19:25:37 Roughly two weeks from now. I like the idea of at
541 h = api.skia._readfile(hash_file, 582 test_data = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee'
542 name='Read android_sdk_hash', 583 hash_file = infrabots_dir.join('android_sdk_hash')
543 test_data=test_data).rstrip() 584 # try/except as a temporary measure to prevent breakages for backfills
544 except api.step.StepFailure: 585 # and branches.
545 # Just fall back on the original hash. 586 try:
546 h = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' 587 h = api.skia._readfile(hash_file,
547 extra_hashes.append(h) 588 name='Read android_sdk_hash',
589 test_data=test_data).rstrip()
590 except api.step.StepFailure:
591 # Just fall back on the original hash.
592 h = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee'
593 extra_hashes.append(h)
594 extra_compile_hashes.append(h)
548 595
596 extra_compile_hashes.extend(collect_hashes(api, compile_deps))
597
598 # Compile.
549 do_compile_steps = builder_spec.get('do_compile_steps', True) 599 do_compile_steps = builder_spec.get('do_compile_steps', True)
550 compile_hash = None
551 if do_compile_steps: 600 if do_compile_steps:
552 compile_hash = compile_steps_swarm(api, builder_spec, got_revision, 601 extra_hashes.append(compile_steps_swarm(
553 infrabots_dir, extra_hashes) 602 api, builder_spec, got_revision, infrabots_dir, extra_compile_hashes))
554 603
555 if builder_cfg['role'] == 'Housekeeper': 604 if builder_cfg['role'] == 'Housekeeper':
556 housekeeper_swarm(api, builder_spec, got_revision, infrabots_dir, 605 housekeeper_swarm(api, builder_spec, got_revision, infrabots_dir,
557 extra_hashes) 606 extra_hashes)
558 return 607 return
559 608
609 # Get ready to test/perf.
560 do_test_steps = builder_spec['do_test_steps'] 610 do_test_steps = builder_spec['do_test_steps']
561 do_perf_steps = builder_spec['do_perf_steps'] 611 do_perf_steps = builder_spec['do_perf_steps']
562 612
563 if not (do_test_steps or do_perf_steps): 613 if not (do_test_steps or do_perf_steps):
564 return 614 return
565 615
566 if compile_hash:
567 extra_hashes.append(compile_hash)
568
569 api.skia.download_skps(api.path['slave_build'].join('tmp'), 616 api.skia.download_skps(api.path['slave_build'].join('tmp'),
570 api.path['slave_build'].join('skps'), 617 api.path['slave_build'].join('skps'),
571 False) 618 False)
572 api.skia.download_images(api.path['slave_build'].join('tmp'), 619 api.skia.download_images(api.path['slave_build'].join('tmp'),
573 api.path['slave_build'].join('images'), 620 api.path['slave_build'].join('images'),
574 False) 621 False)
575 622
576 test_task = None 623 test_task = None
577 perf_task = None 624 perf_task = None
578 if do_test_steps: 625 if do_test_steps:
579 test_task = test_steps_trigger(api, builder_spec, got_revision, 626 test_task = test_steps_trigger(api, builder_spec, got_revision,
580 infrabots_dir, extra_hashes) 627 infrabots_dir, extra_hashes)
581 if do_perf_steps: 628 if do_perf_steps:
582 perf_task = perf_steps_trigger(api, builder_spec, got_revision, 629 perf_task = perf_steps_trigger(api, builder_spec, got_revision,
583 infrabots_dir, extra_hashes) 630 infrabots_dir, extra_hashes)
584 is_trybot = builder_cfg['is_trybot'] 631 is_trybot = builder_cfg['is_trybot']
585 if test_task: 632 if test_task:
586 test_steps_collect(api, test_task, builder_spec['upload_dm_results'], 633 test_steps_collect(api, test_task, builder_spec['upload_dm_results'],
587 got_revision, is_trybot, builder_cfg) 634 got_revision, is_trybot, builder_cfg)
588 if perf_task: 635 if perf_task:
589 perf_steps_collect(api, perf_task, builder_spec['upload_perf_results'], 636 perf_steps_collect(api, perf_task, builder_spec['upload_perf_results'],
590 got_revision, is_trybot) 637 got_revision, is_trybot)
591 638
592 639
593 def test_for_bot(api, builder, mastername, slavename, testname=None): 640 def test_for_bot(api, builder, mastername, slavename, testname=None,
641 legacy_android_sdk=False):
594 """Generate a test for the given bot.""" 642 """Generate a test for the given bot."""
595 testname = testname or builder 643 testname = testname or builder
596 test = ( 644 test = (
597 api.test(testname) + 645 api.test(testname) +
598 api.properties(buildername=builder, 646 api.properties(buildername=builder,
599 mastername=mastername, 647 mastername=mastername,
600 slavename=slavename, 648 slavename=slavename,
601 buildnumber=5, 649 buildnumber=5,
602 revision='abc123') + 650 revision='abc123') +
603 api.path.exists( 651 api.path.exists(
604 api.path['slave_build'].join('skia'), 652 api.path['slave_build'].join('skia'),
605 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') 653 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt')
606 ) 654 )
607 ) 655 )
608 if 'Trybot' in builder: 656 if 'Trybot' in builder:
609 test += api.properties(issue=500, 657 test += api.properties(issue=500,
610 patchset=1, 658 patchset=1,
611 rietveld='https://codereview.chromium.org') 659 rietveld='https://codereview.chromium.org')
660 if 'Android' in builder:
661 if not legacy_android_sdk:
662 test += api.path.exists(api.path['slave_build'].join(
663 'skia', 'infra', 'bots', 'assets', 'android_sdk'))
664 test += api.step_data(
665 'upload new .isolated file for download_android_sdk',
666 stdout=api.raw_io.output('def456 XYZ.isolated'))
612 if 'Coverage' not in builder: 667 if 'Coverage' not in builder:
613 test += api.step_data( 668 test += api.step_data(
614 'upload new .isolated file for compile_skia', 669 'upload new .isolated file for compile_skia',
615 stdout=api.raw_io.output('def456 XYZ.isolated')) 670 stdout=api.raw_io.output('def456 XYZ.isolated'))
616 if 'Test' in builder: 671 if 'Test' in builder:
617 test += api.step_data( 672 test += api.step_data(
618 'upload new .isolated file for test_skia', 673 'upload new .isolated file for test_skia',
619 stdout=api.raw_io.output('def456 XYZ.isolated')) 674 stdout=api.raw_io.output('def456 XYZ.isolated'))
620 if ('Test' in builder and 'Debug' in builder) or 'Perf' in builder or ( 675 if ('Test' in builder and 'Debug' in builder) or 'Perf' in builder or (
621 'Valgrind' in builder and 'Test' in builder): 676 'Valgrind' in builder and 'Test' in builder):
(...skipping 30 matching lines...) Expand all
652 test += api.properties(test_downloaded_skp_version='999') 707 test += api.properties(test_downloaded_skp_version='999')
653 test += api.path.exists( 708 test += api.path.exists(
654 api.path['slave_build'].join('skia'), 709 api.path['slave_build'].join('skia'),
655 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') 710 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt')
656 ) 711 )
657 yield test 712 yield test
658 713
659 builder = 'Build-Ubuntu-GCC-Arm7-Release-Android_Vulkan' 714 builder = 'Build-Ubuntu-GCC-Arm7-Release-Android_Vulkan'
660 master = 'client.skia.compile' 715 master = 'client.skia.compile'
661 slave = 'skiabot-linux-compile-000' 716 slave = 'skiabot-linux-compile-000'
662 test = test_for_bot(api, builder, master, slave, 'Missing_android_sdk_hash') 717 test = test_for_bot(api, builder, master, slave, 'legacy_android_sdk',
718 legacy_android_sdk=True)
719 test += api.step_data('Read android_sdk_hash',
720 stdout=api.raw_io.output('<android_sdk_hash>'))
721 yield test
722
723 test = test_for_bot(api, builder, master, slave, 'Missing_android_sdk_hash',
724 legacy_android_sdk=True)
663 test += api.step_data('Read android_sdk_hash', retcode=1) 725 test += api.step_data('Read android_sdk_hash', retcode=1)
664 yield test 726 yield test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698