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

Side by Side Diff: scripts/slave/recipe_modules/chromium_tests/api.py

Issue 1474473004: Pass mb_mastername and mb_buildername as parameters to override the default. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Pass mb_mastername and mb_buildername as parameters Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 ast 5 import ast
6 import contextlib 6 import contextlib
7 import copy 7 import copy
8 import itertools 8 import itertools
9 import json 9 import json
10 10
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 command(lambda name: '%s (with patch)' % name) 350 command(lambda name: '%s (with patch)' % name)
351 except self.m.step.StepFailure: 351 except self.m.step.StepFailure:
352 self.deapply_patch(update_step) 352 self.deapply_patch(update_step)
353 command(lambda name: '%s (without patch)' % name) 353 command(lambda name: '%s (without patch)' % name)
354 raise 354 raise
355 else: 355 else:
356 command(lambda name: name) 356 command(lambda name: name)
357 357
358 358
359 def compile(self, mastername, buildername, update_step, master_dict, 359 def compile(self, mastername, buildername, update_step, master_dict,
360 test_spec): 360 test_spec, mb_mastername, mb_buildername):
Paweł Hajdan Jr. 2015/11/27 10:21:24 Can we make mb_ args optional and have them defaul
stgao 2015/11/28 07:37:48 I think we can not do that, assuming that "non-mb
Paweł Hajdan Jr. 2015/11/30 12:47:25 Tentatively sounds good. Maybe that was a bit vagu
361 """Runs compile and related steps for given builder.""" 361 """Runs compile and related steps for given builder."""
362 compile_targets, tests_including_triggered = \ 362 compile_targets, tests_including_triggered = \
363 self.get_compile_targets_and_tests( 363 self.get_compile_targets_and_tests(
364 mastername, 364 mastername,
365 buildername, 365 buildername,
366 master_dict, test_spec) 366 master_dict, test_spec)
367 self.compile_specific_targets( 367 self.compile_specific_targets(
368 mastername, buildername, update_step, master_dict, 368 mastername, buildername, update_step, master_dict,
369 compile_targets, tests_including_triggered) 369 compile_targets, tests_including_triggered,
370 mb_mastername, mb_buildername)
370 371
371 def compile_specific_targets( 372 def compile_specific_targets(
372 self, mastername, buildername, update_step, master_dict, 373 self, mastername, buildername, update_step, master_dict,
373 compile_targets, tests_including_triggered, override_bot_type=None): 374 compile_targets, tests_including_triggered,
375 mb_mastername, mb_buildername, override_bot_type=None):
374 """Runs compile and related steps for given builder. 376 """Runs compile and related steps for given builder.
375 377
378 We don't use the given `mastername` and `buildername` to run MB, because
379 they may be the values of the continuous builder the trybot may be
380 configured to match; instead we need to use the actual mastername and
381 buildername we're running on(given as `mb_mastername` and `mb_buildername`),
382 because it may be configured with different MB settings.
383
384 However, recipes used by Findit for culprit finding may still set
385 (mb_mastername, mb_buildername) = (mastername, buildername) to exactly match
386 a given continuous builder.
387
376 Allows finer-grained control about exact compile targets used.""" 388 Allows finer-grained control about exact compile targets used."""
377 389
378 bot_config = master_dict.get('builders', {}).get(buildername) 390 bot_config = master_dict.get('builders', {}).get(buildername)
379 master_config = master_dict.get('settings', {}) 391 master_config = master_dict.get('settings', {})
380 bot_type = override_bot_type or bot_config.get('bot_type', 'builder_tester') 392 bot_type = override_bot_type or bot_config.get('bot_type', 'builder_tester')
381 393
382 self.m.chromium.cleanup_temp() 394 self.m.chromium.cleanup_temp()
383 if self.m.chromium.c.TARGET_PLATFORM == 'android': 395 if self.m.chromium.c.TARGET_PLATFORM == 'android':
384 self.m.chromium_android.clean_local_files() 396 self.m.chromium_android.clean_local_files()
385 self.m.chromium_android.run_tree_truth() 397 self.m.chromium_android.run_tree_truth()
386 398
387 if bot_type in ['builder', 'builder_tester']: 399 if bot_type in ['builder', 'builder_tester']:
388 isolated_targets = [ 400 isolated_targets = [
389 t.isolate_target for t in tests_including_triggered if t.uses_swarming 401 t.isolate_target for t in tests_including_triggered if t.uses_swarming
390 ] 402 ]
391 403
392 if isolated_targets: 404 if isolated_targets:
393 self.m.isolate.clean_isolated_files(self.m.chromium.output_dir) 405 self.m.isolate.clean_isolated_files(self.m.chromium.output_dir)
394 406
395 if self.m.chromium.c.project_generator.tool == 'mb': 407 if self.m.chromium.c.project_generator.tool == 'mb':
396 if bot_config.get('chromium_config') == 'chromium_win_clang': 408 if bot_config.get('chromium_config') == 'chromium_win_clang':
397 self.m.chromium.update_clang() 409 self.m.chromium.update_clang()
398 410
399 try: 411 try:
400 self.transient_check(update_step, lambda transform_name: 412 self.transient_check(update_step, lambda transform_name:
401 self.run_mb_and_compile(compile_targets, isolated_targets, 413 self.run_mb_and_compile(compile_targets, isolated_targets,
402 name_suffix=transform_name(''))) 414 name_suffix=transform_name(''),
415 mb_mastername=mb_mastername,
416 mb_buildername=mb_buildername))
403 except self.m.step.StepFailure: 417 except self.m.step.StepFailure:
404 self.m.tryserver.set_compile_failure_tryjob_result() 418 self.m.tryserver.set_compile_failure_tryjob_result()
405 raise 419 raise
406 420
407 if isolated_targets: 421 if isolated_targets:
408 self.m.isolate.remove_build_metadata() 422 self.m.isolate.remove_build_metadata()
409 # 'compile' just prepares all information needed for the isolation, 423 # 'compile' just prepares all information needed for the isolation,
410 # and the isolation is a separate step. 424 # and the isolation is a separate step.
411 self.m.isolate.isolate_tests( 425 self.m.isolate.isolate_tests(
412 self.m.chromium.output_dir, 426 self.m.chromium.output_dir,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 }) 474 })
461 475
462 if bot_config.get('archive_build') and not self.m.tryserver.is_tryserver: 476 if bot_config.get('archive_build') and not self.m.tryserver.is_tryserver:
463 self.m.chromium.archive_build( 477 self.m.chromium.archive_build(
464 'archive_build', 478 'archive_build',
465 bot_config['gs_bucket'], 479 bot_config['gs_bucket'],
466 bot_config.get('gs_acl'), 480 bot_config.get('gs_acl'),
467 mode='dev' 481 mode='dev'
468 ) 482 )
469 483
470 def run_mb_and_compile(self, compile_targets, isolated_targets, name_suffix): 484 def run_mb_and_compile(self, compile_targets, isolated_targets, name_suffix,
485 mb_mastername, mb_buildername):
471 if self.m.chromium.c.project_generator.tool == 'mb': 486 if self.m.chromium.c.project_generator.tool == 'mb':
472 # We don't use the mastername and buildername passed in, because 487 self.m.chromium.run_mb(mb_mastername, mb_buildername,
473 # those may be the values of the continuous builder the trybot may
474 # be configured to match; we need to use the actual mastername
475 # and buildername we're running on, because it may be configured
476 # with different MB settings.
477 real_mastername = self.m.properties['mastername']
478 real_buildername = self.m.properties['buildername']
479 self.m.chromium.run_mb(real_mastername, real_buildername,
480 isolated_targets=isolated_targets, 488 isolated_targets=isolated_targets,
481 name='generate_build_files%s' % name_suffix) 489 name='generate_build_files%s' % name_suffix)
482 490
483 self.m.chromium.compile(compile_targets, name='compile%s' % name_suffix) 491 self.m.chromium.compile(compile_targets, name='compile%s' % name_suffix)
484 492
485 def tests_for_builder(self, mastername, buildername, update_step, master_dict, 493 def tests_for_builder(self, mastername, buildername, update_step, master_dict,
486 override_bot_type=None): 494 override_bot_type=None):
487 got_revision = update_step.presentation.properties['got_revision'] 495 got_revision = update_step.presentation.properties['got_revision']
488 496
489 bot_config = master_dict.get('builders', {}).get(buildername) 497 bot_config = master_dict.get('builders', {}).get(buildername)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 # mapping for their own purposes. 599 # mapping for their own purposes.
592 first_solution_name = self.m.gclient.c.solutions[0].name 600 first_solution_name = self.m.gclient.c.solutions[0].name
593 rev_property = self.m.gclient.c.got_revision_mapping[first_solution_name] 601 rev_property = self.m.gclient.c.got_revision_mapping[first_solution_name]
594 self.m.gclient.c.revisions[first_solution_name] = str( 602 self.m.gclient.c.revisions[first_solution_name] = str(
595 bot_update_json['properties'][rev_property]) 603 bot_update_json['properties'][rev_property])
596 self.m.bot_update.ensure_checkout( 604 self.m.bot_update.ensure_checkout(
597 force=True, patch=False, update_presentation=False) 605 force=True, patch=False, update_presentation=False)
598 self.m.chromium.runhooks(name='runhooks (without patch)') 606 self.m.chromium.runhooks(name='runhooks (without patch)')
599 607
600 def run_tests_on_tryserver(self, mastername, api, tests, bot_update_step, 608 def run_tests_on_tryserver(self, mastername, api, tests, bot_update_step,
601 affected_files): 609 affected_files, mb_mastername, mb_buildername):
602 def deapply_patch_fn(failing_tests): 610 def deapply_patch_fn(failing_tests):
603 self.deapply_patch(bot_update_step) 611 self.deapply_patch(bot_update_step)
604 compile_targets = list(itertools.chain( 612 compile_targets = list(itertools.chain(
605 *[t.compile_targets(api) for t in failing_tests])) 613 *[t.compile_targets(api) for t in failing_tests]))
606 if compile_targets: 614 if compile_targets:
607 # Remove duplicate targets. 615 # Remove duplicate targets.
608 compile_targets = sorted(set(compile_targets)) 616 compile_targets = sorted(set(compile_targets))
609 failing_swarming_tests = [ 617 failing_swarming_tests = [
610 t.isolate_target for t in failing_tests if t.uses_swarming] 618 t.isolate_target for t in failing_tests if t.uses_swarming]
611 if failing_swarming_tests: 619 if failing_swarming_tests:
612 self.m.isolate.clean_isolated_files(self.m.chromium.output_dir) 620 self.m.isolate.clean_isolated_files(self.m.chromium.output_dir)
613 self.run_mb_and_compile(compile_targets, failing_swarming_tests, 621 self.run_mb_and_compile(compile_targets, failing_swarming_tests,
614 ' (without patch)') 622 ' (without patch)',
623 mb_mastername, mb_buildername)
615 if failing_swarming_tests: 624 if failing_swarming_tests:
616 self.m.isolate.isolate_tests(self.m.chromium.output_dir, 625 self.m.isolate.isolate_tests(self.m.chromium.output_dir,
617 verbose=True) 626 verbose=True)
618 627
619 deapply_patch = True 628 deapply_patch = True
620 for path in RECIPE_CONFIG_PATHS: 629 for path in RECIPE_CONFIG_PATHS:
621 if any([f.startswith(path) for f in affected_files]): 630 if any([f.startswith(path) for f in affected_files]):
622 deapply_patch = False 631 deapply_patch = False
623 break 632 break
624 633
625 with self.wrap_chromium_tests(mastername, tests): 634 with self.wrap_chromium_tests(mastername, tests):
626 if deapply_patch: 635 if deapply_patch:
627 self.m.test_utils.determine_new_failures(api, tests, deapply_patch_fn) 636 self.m.test_utils.determine_new_failures(api, tests, deapply_patch_fn)
628 else: 637 else:
629 failing_tests = self.m.test_utils.run_tests_with_patch(api, tests) 638 failing_tests = self.m.test_utils.run_tests_with_patch(api, tests)
630 if failing_tests: 639 if failing_tests:
631 self.m.python.failing_step('test results', 'TESTS FAILED') 640 self.m.python.failing_step('test results', 'TESTS FAILED')
632 641
633 def analyze(self, affected_files, test_targets, additional_compile_targets, 642 def analyze(self, affected_files, test_targets, additional_compile_targets,
634 config_file_name, additional_names=None): 643 config_file_name, mb_mastername, mb_buildername,
644 additional_names=None):
635 """Runs "analyze" step to determine targets affected by the patch. 645 """Runs "analyze" step to determine targets affected by the patch.
636 646
637 Returns a tuple of: 647 Returns a tuple of:
638 - list of targets that are needed to run tests (see filter recipe module) 648 - list of targets that are needed to run tests (see filter recipe module)
639 - list of targets that need to be compiled (see filter recipe module)""" 649 - list of targets that need to be compiled (see filter recipe module)"""
640 650
641 if additional_names is None: 651 if additional_names is None:
642 additional_names = ['chromium'] 652 additional_names = ['chromium']
643 653
644 use_mb = (self.m.chromium.c.project_generator.tool == 'mb') 654 use_mb = (self.m.chromium.c.project_generator.tool == 'mb')
645 build_output_dir = '//out/%s' % self.m.chromium.c.build_config_fs 655 build_output_dir = '//out/%s' % self.m.chromium.c.build_config_fs
646 self.m.filter.does_patch_require_compile( 656 self.m.filter.does_patch_require_compile(
647 affected_files, 657 affected_files,
658 mb_mastername,
659 mb_buildername,
648 test_targets=test_targets, 660 test_targets=test_targets,
649 additional_compile_targets=additional_compile_targets, 661 additional_compile_targets=additional_compile_targets,
650 additional_names=additional_names, 662 additional_names=additional_names,
651 config_file_name=config_file_name, 663 config_file_name=config_file_name,
652 use_mb=use_mb, 664 use_mb=use_mb,
653 build_output_dir=build_output_dir, 665 build_output_dir=build_output_dir,
654 cros_board=self.m.chromium.c.TARGET_CROS_BOARD) 666 cros_board=self.m.chromium.c.TARGET_CROS_BOARD)
655 667
656 compile_targets = self.m.filter.compile_targets[:] 668 compile_targets = self.m.filter.compile_targets[:]
657 669
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 result_text = 'MB is enabled for this builder at this revision.' 826 result_text = 'MB is enabled for this builder at this revision.'
815 log_name = 'Builder MB-ready' 827 log_name = 'Builder MB-ready'
816 self.m.step.active_result.presentation.logs[log_name] = [result_text] 828 self.m.step.active_result.presentation.logs[log_name] = [result_text]
817 return False 829 return False
818 except (self.m.step.StepFailure, KeyError): 830 except (self.m.step.StepFailure, KeyError):
819 result_text = 'MB is not enabled for this builder at this revision.' 831 result_text = 'MB is not enabled for this builder at this revision.'
820 log_name = 'Builder NOT MB-ready' 832 log_name = 'Builder NOT MB-ready'
821 self.m.step.active_result.presentation.logs[log_name] = [result_text] 833 self.m.step.active_result.presentation.logs[log_name] = [result_text]
822 self.m.step.active_result.presentation.status = self.m.step.WARNING 834 self.m.step.active_result.presentation.status = self.m.step.WARNING
823 return True 835 return True
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/chromium/example.py ('k') | scripts/slave/recipe_modules/filter/api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698