OLD | NEW |
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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 if 'Valgrind' in builder_cfg.get('extra_config', ''): | 427 if 'Valgrind' in builder_cfg.get('extra_config', ''): |
428 expiration = 2*24*60*60 | 428 expiration = 2*24*60*60 |
429 hard_timeout = 9*60*60 | 429 hard_timeout = 9*60*60 |
430 io_timeout = 60*60 | 430 io_timeout = 60*60 |
431 if builder_cfg.get('extra_config', '').startswith('CT_'): | 431 if builder_cfg.get('extra_config', '').startswith('CT_'): |
432 hard_timeout = 24*60*60 | 432 hard_timeout = 24*60*60 |
433 io_timeout = 60*60 | 433 io_timeout = 60*60 |
434 return expiration, hard_timeout, io_timeout | 434 return expiration, hard_timeout, io_timeout |
435 | 435 |
436 | 436 |
437 def gsutil_env(api, boto_file): | |
438 """Environment variables for gsutil.""" | |
439 home_dir = os.path.expanduser('~') | |
440 if api.path._test_data.enabled: | |
441 home_dir = '[HOME]' | |
442 | |
443 boto_path = None | |
444 if boto_file: | |
445 boto_path = api.path.join(home_dir, boto_file) | |
446 return {'AWS_CREDENTIAL_FILE': boto_path, | |
447 'BOTO_CONFIG': boto_path} | |
448 | |
449 | |
450 def get_issue_num(api): | |
451 if api.properties.get('patch_storage') == 'gerrit': | |
452 return str(api.properties['event.change.number']) | |
453 else: | |
454 return str(api.properties['issue']) | |
455 | |
456 | |
457 def perf_steps_trigger(api, builder_cfg, got_revision, infrabots_dir, | 437 def perf_steps_trigger(api, builder_cfg, got_revision, infrabots_dir, |
458 extra_hashes, cipd_packages): | 438 extra_hashes, cipd_packages): |
459 """Trigger perf tests via Swarming.""" | 439 """Trigger perf tests via Swarming.""" |
460 | 440 |
461 expiration, hard_timeout, io_timeout = get_timeouts(builder_cfg) | 441 expiration, hard_timeout, io_timeout = get_timeouts(builder_cfg) |
462 return trigger_task( | 442 return trigger_task( |
463 api, | 443 api, |
464 'perf', | 444 'perf', |
465 api.properties['buildername'], | 445 api.properties['buildername'], |
466 api.properties['mastername'], | 446 api.properties['mastername'], |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 api.properties['mastername'], | 499 api.properties['mastername'], |
520 api.properties['slavename'], | 500 api.properties['slavename'], |
521 api.properties['buildnumber'], | 501 api.properties['buildnumber'], |
522 builder_cfg, | 502 builder_cfg, |
523 got_revision, | 503 got_revision, |
524 infrabots_dir, | 504 infrabots_dir, |
525 extra_isolate_hashes=extra_hashes, | 505 extra_isolate_hashes=extra_hashes, |
526 expiration=expiration, | 506 expiration=expiration, |
527 hard_timeout=hard_timeout, | 507 hard_timeout=hard_timeout, |
528 io_timeout=io_timeout, | 508 io_timeout=io_timeout, |
529 cipd_packages=cipd_packages) | 509 cipd_packages=cipd_packages, |
| 510 store_output=False) |
530 | 511 |
531 | 512 |
532 def test_steps_collect(api, task, got_revision, is_trybot, builder_cfg): | 513 def test_steps_collect(api, task, builder_cfg, got_revision, infrabots_dir): |
533 """Collect the test results from Swarming.""" | 514 """Collect the test results from Swarming.""" |
534 # Wait for tests to finish, download the results. | 515 # Wait for tests to finish, download the results. |
535 api.run.rmtree(task.task_output_dir) | 516 if not api.vars.upload_dm_results: # pragma: nocover |
536 api.swarming.collect_swarming_task(task) | 517 api.swarming.collect_swarming_task(task) |
| 518 return |
| 519 |
| 520 dm_hash = api.swarming.collect_swarming_task_isolate_hash(task) |
537 | 521 |
538 # Upload the results. | 522 # Upload the results. |
539 if api.vars.upload_dm_results: | 523 task = trigger_task( |
540 dm_dir = api.path['slave_build'].join('dm') | 524 api, |
541 dm_src = task.task_output_dir.join('0', 'dm') | 525 'upload_dm_results', |
542 api.run.rmtree(dm_dir) | 526 api.properties['buildername'], |
543 api.file.copytree('dm_dir', dm_src, dm_dir, infra_step=True) | 527 api.properties['mastername'], |
| 528 api.properties['slavename'], |
| 529 api.properties['buildnumber'], |
| 530 builder_cfg, |
| 531 got_revision, |
| 532 infrabots_dir, |
| 533 idempotent=True, |
| 534 store_output=False, |
| 535 cipd_packages=None, |
| 536 extra_isolate_hashes=[dm_hash], |
| 537 recipe_name='upload_dm_results', |
| 538 isolate_file='upload_dm_results.isolate', |
| 539 dimensions=UPLOAD_DIMENSIONS) |
544 | 540 |
545 # Upload them to Google Storage. | 541 return api.swarming.collect_swarming_task(task) |
546 api.python( | |
547 'Upload DM Results', | |
548 script=api.core.resource('upload_dm_results.py'), | |
549 args=[ | |
550 dm_dir, | |
551 got_revision, | |
552 api.properties['buildername'], | |
553 api.properties['buildnumber'], | |
554 get_issue_num(api) if is_trybot else '', | |
555 api.path['slave_build'].join('skia', 'common', 'py', 'utils'), | |
556 ], | |
557 cwd=api.path['checkout'], | |
558 env=gsutil_env(api, 'chromium-skia-gm.boto'), | |
559 infra_step=True) | |
560 | |
561 if builder_cfg['configuration'] == 'Coverage': | |
562 upload_coverage_results(api, task, got_revision, is_trybot) | |
563 | |
564 | |
565 def upload_coverage_results(api, task, got_revision, is_trybot): | |
566 results_dir = task.task_output_dir.join('0') | |
567 git_timestamp = api.git.get_timestamp(test_data='1408633190', | |
568 infra_step=True) | |
569 | |
570 # Upload raw coverage data. | |
571 cov_file_basename = '%s.cov' % got_revision | |
572 cov_file = results_dir.join(cov_file_basename) | |
573 now = api.time.utcnow() | |
574 gs_json_path = '/'.join(( | |
575 str(now.year).zfill(4), str(now.month).zfill(2), | |
576 str(now.day).zfill(2), str(now.hour).zfill(2), | |
577 api.properties['buildername'], | |
578 str(api.properties['buildnumber']))) | |
579 if is_trybot: | |
580 gs_json_path = '/'.join(('trybot', gs_json_path, get_issue_num(api))) | |
581 api.gsutil.upload( | |
582 name='upload raw coverage data', | |
583 source=cov_file, | |
584 bucket='skia-infra', | |
585 dest='/'.join(('coverage-raw-v1', gs_json_path, | |
586 cov_file_basename)), | |
587 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None}, | |
588 ) | |
589 | |
590 # Transform the nanobench_${git_hash}.json file received from swarming bot | |
591 # into the nanobench_${git_hash}_${timestamp}.json file | |
592 # upload_bench_results.py expects. | |
593 src_nano_file = results_dir.join('nanobench_%s.json' % got_revision) | |
594 dst_nano_file = results_dir.join( | |
595 'nanobench_%s_%s.json' % (got_revision, git_timestamp)) | |
596 api.file.copy('nanobench JSON', src_nano_file, dst_nano_file, | |
597 infra_step=True) | |
598 api.file.remove('old nanobench JSON', src_nano_file) | |
599 | |
600 # Upload nanobench JSON data. | |
601 gsutil_path = api.depot_tools.gsutil_py_path | |
602 upload_args = [api.properties['buildername'], api.properties['buildnumber'], | |
603 results_dir, got_revision, gsutil_path] | |
604 if is_trybot: | |
605 upload_args.append(get_issue_num(api)) | |
606 api.python( | |
607 'upload nanobench coverage results', | |
608 script=api.core.resource('upload_bench_results.py'), | |
609 args=upload_args, | |
610 cwd=api.path['checkout'], | |
611 env=gsutil_env(api, 'chromium-skia-gm.boto'), | |
612 infra_step=True) | |
613 | |
614 # Transform the coverage_by_line_${git_hash}.json file received from | |
615 # swarming bot into a coverage_by_line_${git_hash}_${timestamp}.json file. | |
616 src_lbl_file = results_dir.join('coverage_by_line_%s.json' % got_revision) | |
617 dst_lbl_file_basename = 'coverage_by_line_%s_%s.json' % ( | |
618 got_revision, git_timestamp) | |
619 dst_lbl_file = results_dir.join(dst_lbl_file_basename) | |
620 api.file.copy('Line-by-line coverage JSON', src_lbl_file, dst_lbl_file, | |
621 infra_step=True) | |
622 api.file.remove('old line-by-line coverage JSON', src_lbl_file) | |
623 | |
624 # Upload line-by-line coverage data. | |
625 api.gsutil.upload( | |
626 name='upload line-by-line coverage data', | |
627 source=dst_lbl_file, | |
628 bucket='skia-infra', | |
629 dest='/'.join(('coverage-json-v1', gs_json_path, | |
630 dst_lbl_file_basename)), | |
631 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None}, | |
632 ) | |
633 | 542 |
634 | 543 |
635 def cipd_pkg(api, infrabots_dir, asset_name): | 544 def cipd_pkg(api, infrabots_dir, asset_name): |
636 """Find and return the CIPD package info for the given asset.""" | 545 """Find and return the CIPD package info for the given asset.""" |
637 version_file = infrabots_dir.join('assets', asset_name, 'VERSION') | 546 version_file = infrabots_dir.join('assets', asset_name, 'VERSION') |
638 version = api.run.readfile(version_file, | 547 version = api.run.readfile(version_file, |
639 name='read %s VERSION' % asset_name, | 548 name='read %s VERSION' % asset_name, |
640 test_data='0').rstrip() | 549 test_data='0').rstrip() |
641 version = 'version:%s' % version | 550 version = 'version:%s' % version |
642 return (asset_name, 'skia/bots/%s' % asset_name, version) | 551 return (asset_name, 'skia/bots/%s' % asset_name, version) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 640 |
732 # Trigger test and perf tasks. | 641 # Trigger test and perf tasks. |
733 test_task = None | 642 test_task = None |
734 perf_task = None | 643 perf_task = None |
735 if do_test_steps: | 644 if do_test_steps: |
736 test_task = test_steps_trigger(api, builder_cfg, got_revision, | 645 test_task = test_steps_trigger(api, builder_cfg, got_revision, |
737 infrabots_dir, extra_hashes, cipd_packages) | 646 infrabots_dir, extra_hashes, cipd_packages) |
738 if do_perf_steps: | 647 if do_perf_steps: |
739 perf_task = perf_steps_trigger(api, builder_cfg, got_revision, | 648 perf_task = perf_steps_trigger(api, builder_cfg, got_revision, |
740 infrabots_dir, extra_hashes, cipd_packages) | 649 infrabots_dir, extra_hashes, cipd_packages) |
741 is_trybot = builder_cfg['is_trybot'] | |
742 | 650 |
743 # Wait for results, then upload them if necessary. | 651 # Wait for results, then upload them if necessary. |
744 | 652 |
745 if test_task: | 653 if test_task: |
746 test_steps_collect(api, test_task, | 654 test_steps_collect(api, test_task, builder_cfg, |
747 got_revision, is_trybot, builder_cfg) | 655 got_revision, infrabots_dir) |
748 | 656 |
749 if perf_task: | 657 if perf_task: |
750 perf_steps_collect(api, perf_task, builder_cfg, | 658 perf_steps_collect(api, perf_task, builder_cfg, |
751 got_revision, infrabots_dir) | 659 got_revision, infrabots_dir) |
752 | 660 |
753 | 661 |
754 def test_for_bot(api, builder, mastername, slavename, testname=None): | 662 def test_for_bot(api, builder, mastername, slavename, testname=None): |
755 """Generate a test for the given bot.""" | 663 """Generate a test for the given bot.""" |
756 testname = testname or builder | 664 testname = testname or builder |
757 test = ( | 665 test = ( |
(...skipping 13 matching lines...) Expand all Loading... |
771 test += api.properties(issue=500, | 679 test += api.properties(issue=500, |
772 patchset=1, | 680 patchset=1, |
773 rietveld='https://codereview.chromium.org') | 681 rietveld='https://codereview.chromium.org') |
774 if 'Android' in builder: | 682 if 'Android' in builder: |
775 paths.append(api.path['slave_build'].join( | 683 paths.append(api.path['slave_build'].join( |
776 'skia', 'infra', 'bots', 'assets', 'android_sdk', 'VERSION')) | 684 'skia', 'infra', 'bots', 'assets', 'android_sdk', 'VERSION')) |
777 if 'Test' in builder and 'Coverage' not in builder: | 685 if 'Test' in builder and 'Coverage' not in builder: |
778 test += api.step_data( | 686 test += api.step_data( |
779 'upload new .isolated file for test_skia', | 687 'upload new .isolated file for test_skia', |
780 stdout=api.raw_io.output('def456 XYZ.isolated')) | 688 stdout=api.raw_io.output('def456 XYZ.isolated')) |
| 689 if not 'Valgrind' in builder and not 'MSAN' in builder: |
| 690 test += api.step_data( |
| 691 'upload new .isolated file for upload_dm_results_skia', |
| 692 stdout=api.raw_io.output('def456 XYZ.isolated')) |
781 if 'Perf' in builder and '-CT_' not in builder: | 693 if 'Perf' in builder and '-CT_' not in builder: |
782 test += api.step_data( | 694 test += api.step_data( |
783 'upload new .isolated file for perf_skia', | 695 'upload new .isolated file for perf_skia', |
784 stdout=api.raw_io.output('def456 XYZ.isolated')) | 696 stdout=api.raw_io.output('def456 XYZ.isolated')) |
785 test += api.step_data( | 697 test += api.step_data( |
786 'upload new .isolated file for upload_nano_results_skia', | 698 'upload new .isolated file for upload_nano_results_skia', |
787 stdout=api.raw_io.output('def456 XYZ.isolated')) | 699 stdout=api.raw_io.output('def456 XYZ.isolated')) |
788 if 'Housekeeper' in builder and 'RecreateSKPs' not in builder: | 700 if 'Housekeeper' in builder and 'RecreateSKPs' not in builder: |
789 test += api.step_data( | 701 test += api.step_data( |
790 'upload new .isolated file for housekeeper_skia', | 702 'upload new .isolated file for housekeeper_skia', |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 api.properties( | 735 api.properties( |
824 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot', | 736 buildername='Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot', |
825 mastername='client.skia', | 737 mastername='client.skia', |
826 slavename='skiabot-linux-swarm-000', | 738 slavename='skiabot-linux-swarm-000', |
827 buildnumber=5, | 739 buildnumber=5, |
828 path_config='kitchen', | 740 path_config='kitchen', |
829 revision='abc123', | 741 revision='abc123', |
830 **gerrit_kwargs) + | 742 **gerrit_kwargs) + |
831 api.step_data( | 743 api.step_data( |
832 'upload new .isolated file for test_skia', | 744 'upload new .isolated file for test_skia', |
| 745 stdout=api.raw_io.output('def456 XYZ.isolated')) + |
| 746 api.step_data( |
| 747 'upload new .isolated file for upload_dm_results_skia', |
833 stdout=api.raw_io.output('def456 XYZ.isolated')) | 748 stdout=api.raw_io.output('def456 XYZ.isolated')) |
834 ) | 749 ) |
OLD | NEW |