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

Side by Side Diff: infra/bots/recipes/swarm_trigger.py

Issue 2263323002: Apply gerrit ref if it is a Gerrit patch (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Align Created 4 years, 4 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 os 9 import os
10 import json 10 import json
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 properties = { 186 properties = {
187 'buildername': builder, 187 'buildername': builder,
188 'mastername': master, 188 'mastername': master,
189 'buildnumber': buildnumber, 189 'buildnumber': buildnumber,
190 'reason': 'Triggered by Skia swarm_trigger Recipe', 190 'reason': 'Triggered by Skia swarm_trigger Recipe',
191 'revision': got_revision, 191 'revision': got_revision,
192 'slavename': slave, 192 'slavename': slave,
193 'swarm_out_dir': '${ISOLATED_OUTDIR}', 193 'swarm_out_dir': '${ISOLATED_OUTDIR}',
194 } 194 }
195 if builder_cfg['is_trybot']: 195 if builder_cfg['is_trybot']:
196 properties['issue'] = str(api.properties['issue']) 196 if api.properties.get('patch_storage') == 'gerrit':
197 properties['patchset'] = str(api.properties['patchset']) 197 properties['patch_storage'] = api.properties['patch_storage']
198 properties['rietveld'] = api.properties['rietveld'] 198 properties['repository'] = api.properties['repository']
199 properties['event.patchSet.ref'] = api.properties['event.patchSet.ref']
200 properties['event.change.number'] = api.properties['event.change.number']
201 else:
202 properties['issue'] = str(api.properties['issue'])
203 properties['patchset'] = str(api.properties['patchset'])
204 properties['rietveld'] = api.properties['rietveld']
199 205
200 extra_args = [ 206 extra_args = [
201 '--workdir', '../../..', 207 '--workdir', '../../..',
202 'swarm_%s' % task_name, 208 'swarm_%s' % task_name,
203 ] 209 ]
204 for k, v in properties.iteritems(): 210 for k, v in properties.iteritems():
205 extra_args.append('%s=%s' % (k, v)) 211 extra_args.append('%s=%s' % (k, v))
206 212
207 isolate_base_dir = api.path['slave_build'] 213 isolate_base_dir = api.path['slave_build']
208 dimensions = swarm_dimensions(builder_cfg) 214 dimensions = swarm_dimensions(builder_cfg)
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if api.path._test_data.enabled: 417 if api.path._test_data.enabled:
412 home_dir = '[HOME]' 418 home_dir = '[HOME]'
413 419
414 boto_path = None 420 boto_path = None
415 if boto_file: 421 if boto_file:
416 boto_path = api.path.join(home_dir, boto_file) 422 boto_path = api.path.join(home_dir, boto_file)
417 return {'AWS_CREDENTIAL_FILE': boto_path, 423 return {'AWS_CREDENTIAL_FILE': boto_path,
418 'BOTO_CONFIG': boto_path} 424 'BOTO_CONFIG': boto_path}
419 425
420 426
427 def get_issue_num(api, builder_cfg):
428 if not builder_cfg['is_trybot']:
429 return ''
430 if api.properties.get('patch_storage') == 'gerrit':
431 # TODO(rmistry): Figure out what to do for Gerrit here.
432 return ''
433 else:
434 return str(api.properties['issue'])
435
436
421 def perf_steps_trigger(api, builder_cfg, got_revision, infrabots_dir, 437 def perf_steps_trigger(api, builder_cfg, got_revision, infrabots_dir,
422 extra_hashes, cipd_packages): 438 extra_hashes, cipd_packages):
423 """Trigger perf tests via Swarming.""" 439 """Trigger perf tests via Swarming."""
424 440
425 expiration, hard_timeout, io_timeout = get_timeouts(builder_cfg) 441 expiration, hard_timeout, io_timeout = get_timeouts(builder_cfg)
426 return trigger_task( 442 return trigger_task(
427 api, 443 api,
428 'perf', 444 'perf',
429 api.properties['buildername'], 445 api.properties['buildername'],
430 api.properties['mastername'], 446 api.properties['mastername'],
431 api.properties['slavename'], 447 api.properties['slavename'],
432 api.properties['buildnumber'], 448 api.properties['buildnumber'],
433 builder_cfg, 449 builder_cfg,
434 got_revision, 450 got_revision,
435 infrabots_dir, 451 infrabots_dir,
436 extra_isolate_hashes=extra_hashes, 452 extra_isolate_hashes=extra_hashes,
437 expiration=expiration, 453 expiration=expiration,
438 hard_timeout=hard_timeout, 454 hard_timeout=hard_timeout,
439 io_timeout=io_timeout, 455 io_timeout=io_timeout,
440 cipd_packages=cipd_packages) 456 cipd_packages=cipd_packages)
441 457
442 458
443 def perf_steps_collect(api, task, got_revision, is_trybot): 459 def perf_steps_collect(api, task, got_revision, is_trybot, builder_cfg):
444 """Wait for perf steps to finish and upload results.""" 460 """Wait for perf steps to finish and upload results."""
445 # Wait for nanobench to finish, download the results. 461 # Wait for nanobench to finish, download the results.
446 api.run.rmtree(task.task_output_dir) 462 api.run.rmtree(task.task_output_dir)
447 api.swarming.collect_swarming_task(task) 463 api.swarming.collect_swarming_task(task)
448 464
449 # Upload the results. 465 # Upload the results.
450 if api.vars.upload_perf_results: 466 if api.vars.upload_perf_results:
451 perf_data_dir = api.path['slave_build'].join( 467 perf_data_dir = api.path['slave_build'].join(
452 'perfdata', api.properties['buildername'], 'data') 468 'perfdata', api.properties['buildername'], 'data')
453 git_timestamp = api.git.get_timestamp(test_data='1408633190', 469 git_timestamp = api.git.get_timestamp(test_data='1408633190',
454 infra_step=True) 470 infra_step=True)
455 api.run.rmtree(perf_data_dir) 471 api.run.rmtree(perf_data_dir)
456 api.file.makedirs('perf_dir', perf_data_dir, infra_step=True) 472 api.file.makedirs('perf_dir', perf_data_dir, infra_step=True)
457 src_results_file = task.task_output_dir.join( 473 src_results_file = task.task_output_dir.join(
458 '0', 'perfdata', api.properties['buildername'], 'data', 474 '0', 'perfdata', api.properties['buildername'], 'data',
459 'nanobench_%s.json' % got_revision) 475 'nanobench_%s.json' % got_revision)
460 dst_results_file = perf_data_dir.join( 476 dst_results_file = perf_data_dir.join(
461 'nanobench_%s_%s.json' % (got_revision, git_timestamp)) 477 'nanobench_%s_%s.json' % (got_revision, git_timestamp))
462 api.file.copy('perf_results', src_results_file, dst_results_file, 478 api.file.copy('perf_results', src_results_file, dst_results_file,
463 infra_step=True) 479 infra_step=True)
464 480
465 gsutil_path = api.path['slave_build'].join( 481 gsutil_path = api.path['slave_build'].join(
466 'skia', 'infra', 'bots', '.recipe_deps', 'depot_tools', 'third_party', 482 'skia', 'infra', 'bots', '.recipe_deps', 'depot_tools', 'third_party',
467 'gsutil', 'gsutil') 483 'gsutil', 'gsutil')
468 upload_args = [api.properties['buildername'], api.properties['buildnumber'], 484 upload_args = [api.properties['buildername'], api.properties['buildnumber'],
469 perf_data_dir, got_revision, gsutil_path] 485 perf_data_dir, got_revision, gsutil_path]
470 if is_trybot: 486 if is_trybot:
471 upload_args.append(api.properties['issue']) 487 upload_args.append(get_issue_num(api, builder_cfg))
472 api.python( 488 api.python(
473 'Upload perf results', 489 'Upload perf results',
474 script=api.core.resource('upload_bench_results.py'), 490 script=api.core.resource('upload_bench_results.py'),
475 args=upload_args, 491 args=upload_args,
476 cwd=api.path['checkout'], 492 cwd=api.path['checkout'],
477 infra_step=True) 493 infra_step=True)
478 494
479 495
480 def test_steps_trigger(api, builder_cfg, got_revision, infrabots_dir, 496 def test_steps_trigger(api, builder_cfg, got_revision, infrabots_dir,
481 extra_hashes, cipd_packages): 497 extra_hashes, cipd_packages):
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 529
514 # Upload them to Google Storage. 530 # Upload them to Google Storage.
515 api.python( 531 api.python(
516 'Upload DM Results', 532 'Upload DM Results',
517 script=api.core.resource('upload_dm_results.py'), 533 script=api.core.resource('upload_dm_results.py'),
518 args=[ 534 args=[
519 dm_dir, 535 dm_dir,
520 got_revision, 536 got_revision,
521 api.properties['buildername'], 537 api.properties['buildername'],
522 api.properties['buildnumber'], 538 api.properties['buildnumber'],
523 api.properties['issue'] if is_trybot else '', 539 get_issue_num(api, builder_cfg),
524 api.path['slave_build'].join('skia', 'common', 'py', 'utils'), 540 api.path['slave_build'].join('skia', 'common', 'py', 'utils'),
525 ], 541 ],
526 cwd=api.path['checkout'], 542 cwd=api.path['checkout'],
527 env=gsutil_env(api, 'chromium-skia-gm.boto'), 543 env=gsutil_env(api, 'chromium-skia-gm.boto'),
528 infra_step=True) 544 infra_step=True)
529 545
530 if builder_cfg['configuration'] == 'Coverage': 546 if builder_cfg['configuration'] == 'Coverage':
531 upload_coverage_results(api, task, got_revision, is_trybot) 547 upload_coverage_results(api, task, got_revision, is_trybot, builder_cfg)
532 548
533 549
534 def upload_coverage_results(api, task, got_revision, is_trybot): 550 def upload_coverage_results(api, task, got_revision, is_trybot, builder_cfg):
535 results_dir = task.task_output_dir.join('0') 551 results_dir = task.task_output_dir.join('0')
536 git_timestamp = api.git.get_timestamp(test_data='1408633190', 552 git_timestamp = api.git.get_timestamp(test_data='1408633190',
537 infra_step=True) 553 infra_step=True)
538 554
539 # Upload raw coverage data. 555 # Upload raw coverage data.
540 cov_file_basename = '%s.cov' % got_revision 556 cov_file_basename = '%s.cov' % got_revision
541 cov_file = results_dir.join(cov_file_basename) 557 cov_file = results_dir.join(cov_file_basename)
542 now = api.time.utcnow() 558 now = api.time.utcnow()
543 gs_json_path = '/'.join(( 559 gs_json_path = '/'.join((
544 str(now.year).zfill(4), str(now.month).zfill(2), 560 str(now.year).zfill(4), str(now.month).zfill(2),
545 str(now.day).zfill(2), str(now.hour).zfill(2), 561 str(now.day).zfill(2), str(now.hour).zfill(2),
546 api.properties['buildername'], 562 api.properties['buildername'],
547 str(api.properties['buildnumber']))) 563 str(api.properties['buildnumber'])))
548 if is_trybot: 564 if is_trybot:
549 gs_json_path = '/'.join(('trybot', gs_json_path, 565 gs_json_path = '/'.join(('trybot', gs_json_path,
550 str(api.properties['issue']))) 566 get_issue_num(api, builder_cfg)))
551 api.gsutil.upload( 567 api.gsutil.upload(
552 name='upload raw coverage data', 568 name='upload raw coverage data',
553 source=cov_file, 569 source=cov_file,
554 bucket='skia-infra', 570 bucket='skia-infra',
555 dest='/'.join(('coverage-raw-v1', gs_json_path, 571 dest='/'.join(('coverage-raw-v1', gs_json_path,
556 cov_file_basename)), 572 cov_file_basename)),
557 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None}, 573 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None},
558 ) 574 )
559 575
560 # Transform the nanobench_${git_hash}.json file received from swarming bot 576 # Transform the nanobench_${git_hash}.json file received from swarming bot
561 # into the nanobench_${git_hash}_${timestamp}.json file 577 # into the nanobench_${git_hash}_${timestamp}.json file
562 # upload_bench_results.py expects. 578 # upload_bench_results.py expects.
563 src_nano_file = results_dir.join('nanobench_%s.json' % got_revision) 579 src_nano_file = results_dir.join('nanobench_%s.json' % got_revision)
564 dst_nano_file = results_dir.join( 580 dst_nano_file = results_dir.join(
565 'nanobench_%s_%s.json' % (got_revision, git_timestamp)) 581 'nanobench_%s_%s.json' % (got_revision, git_timestamp))
566 api.file.copy('nanobench JSON', src_nano_file, dst_nano_file, 582 api.file.copy('nanobench JSON', src_nano_file, dst_nano_file,
567 infra_step=True) 583 infra_step=True)
568 api.file.remove('old nanobench JSON', src_nano_file) 584 api.file.remove('old nanobench JSON', src_nano_file)
569 585
570 # Upload nanobench JSON data. 586 # Upload nanobench JSON data.
571 gsutil_path = api.depot_tools.gsutil_py_path 587 gsutil_path = api.depot_tools.gsutil_py_path
572 upload_args = [api.properties['buildername'], api.properties['buildnumber'], 588 upload_args = [api.properties['buildername'], api.properties['buildnumber'],
573 results_dir, got_revision, gsutil_path] 589 results_dir, got_revision, gsutil_path]
574 if is_trybot: 590 if is_trybot:
575 upload_args.append(api.properties['issue']) 591 upload_args.append(get_issue_num(api, builder_cfg))
576 api.python( 592 api.python(
577 'upload nanobench coverage results', 593 'upload nanobench coverage results',
578 script=api.core.resource('upload_bench_results.py'), 594 script=api.core.resource('upload_bench_results.py'),
579 args=upload_args, 595 args=upload_args,
580 cwd=api.path['checkout'], 596 cwd=api.path['checkout'],
581 env=gsutil_env(api, 'chromium-skia-gm.boto'), 597 env=gsutil_env(api, 'chromium-skia-gm.boto'),
582 infra_step=True) 598 infra_step=True)
583 599
584 # Transform the coverage_by_line_${git_hash}.json file received from 600 # Transform the coverage_by_line_${git_hash}.json file received from
585 # swarming bot into a coverage_by_line_${git_hash}_${timestamp}.json file. 601 # swarming bot into a coverage_by_line_${git_hash}_${timestamp}.json file.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 is_trybot = builder_cfg['is_trybot'] 722 is_trybot = builder_cfg['is_trybot']
707 723
708 # Wait for results, then upload them if necessary. 724 # Wait for results, then upload them if necessary.
709 725
710 if test_task: 726 if test_task:
711 test_steps_collect(api, test_task, 727 test_steps_collect(api, test_task,
712 got_revision, is_trybot, builder_cfg) 728 got_revision, is_trybot, builder_cfg)
713 729
714 if perf_task: 730 if perf_task:
715 perf_steps_collect(api, perf_task, 731 perf_steps_collect(api, perf_task,
716 got_revision, is_trybot) 732 got_revision, is_trybot, builder_cfg)
717 733
718 734
719 def test_for_bot(api, builder, mastername, slavename, testname=None): 735 def test_for_bot(api, builder, mastername, slavename, testname=None):
720 """Generate a test for the given bot.""" 736 """Generate a test for the given bot."""
721 testname = testname or builder 737 testname = testname or builder
722 test = ( 738 test = (
723 api.test(testname) + 739 api.test(testname) +
724 api.properties(buildername=builder, 740 api.properties(buildername=builder,
725 mastername=mastername, 741 mastername=mastername,
726 slavename=slavename, 742 slavename=slavename,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 test += api.path.exists(*paths) 782 test += api.path.exists(*paths)
767 783
768 return test 784 return test
769 785
770 786
771 def GenTests(api): 787 def GenTests(api):
772 for mastername, slaves in TEST_BUILDERS.iteritems(): 788 for mastername, slaves in TEST_BUILDERS.iteritems():
773 for slavename, builders_by_slave in slaves.iteritems(): 789 for slavename, builders_by_slave in slaves.iteritems():
774 for builder in builders_by_slave: 790 for builder in builders_by_slave:
775 yield test_for_bot(api, builder, mastername, slavename) 791 yield test_for_bot(api, builder, mastername, slavename)
792
793 gerrit_kwargs = {
794 'patch_storage': 'gerrit',
795 'repository': 'skia',
796 'event.patchSet.ref': 'refs/changes/00/2100/2',
797 'event.change.number': '2100',
798 }
799 yield (
800 api.test('recipe_with_gerrit_patch') +
801 api.properties(
802 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot',
803 mastername='client.skia',
804 slavename='skiabot-linux-swarm-000',
805 buildnumber=5,
806 path_config='kitchen',
807 revision='abc123',
808 **gerrit_kwargs) +
809 api.step_data(
810 'upload new .isolated file for test_skia',
811 stdout=api.raw_io.output('def456 XYZ.isolated'))
812 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698