OLD | NEW |
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 collections | |
6 import contextlib | 5 import contextlib |
7 import copy | 6 import copy |
8 import itertools | 7 import itertools |
9 import json | 8 import json |
10 | 9 |
11 from recipe_engine.types import freeze | 10 from recipe_engine.types import freeze |
12 from recipe_engine import recipe_api | 11 from recipe_engine import recipe_api |
13 from recipe_engine import util as recipe_util | 12 from recipe_engine import util as recipe_util |
14 | 13 |
15 from . import bot_config_and_test_db as bdb_module | 14 from . import bot_config_and_test_db as bdb_module |
16 from . import builders | 15 from . import builders |
17 from . import steps | 16 from . import steps |
18 from . import trybots | 17 from . import trybots |
19 | 18 |
20 | 19 |
21 # Paths which affect recipe config and behavior in a way that survives | 20 # Paths which affect recipe config and behavior in a way that survives |
22 # deapplying user's patch. | 21 # deapplying user's patch. |
23 RECIPE_CONFIG_PATHS = [ | 22 RECIPE_CONFIG_PATHS = [ |
24 'testing/buildbot', | 23 'testing/buildbot', |
25 ] | 24 ] |
26 | 25 |
27 | 26 |
28 PER_TARGET_SWARMING_DIMS = collections.defaultdict(dict) | |
29 PER_TARGET_SWARMING_DIMS.update({ | |
30 'android': { | |
31 'android_devices': '6', | |
32 'cpu': None, | |
33 'gpu': None, | |
34 'os': 'Android', | |
35 } | |
36 }) | |
37 | |
38 | |
39 MASTER_SWARMING_PRIORITIES = collections.defaultdict(lambda: 25) | |
40 MASTER_SWARMING_PRIORITIES.update({ | |
41 'chromium.fyi': 35, # This should be lower than the CQ. | |
42 'chromium.memory.fyi': 27, | |
43 }) | |
44 | |
45 | |
46 class ChromiumTestsApi(recipe_api.RecipeApi): | 27 class ChromiumTestsApi(recipe_api.RecipeApi): |
47 def __init__(self, *args, **kwargs): | 28 def __init__(self, *args, **kwargs): |
48 super(ChromiumTestsApi, self).__init__(*args, **kwargs) | 29 super(ChromiumTestsApi, self).__init__(*args, **kwargs) |
49 self._builders = {} | 30 self._builders = {} |
50 self.add_builders(builders.BUILDERS) | 31 self.add_builders(builders.BUILDERS) |
51 self._precommit_mode = False | 32 self._precommit_mode = False |
52 | 33 |
53 # Keep track of working directory (which contains the checkout). | 34 # Keep track of working directory (which contains the checkout). |
54 # None means "default value". | 35 # None means "default value". |
55 self._working_dir = None | 36 self._working_dir = None |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 'self.m.filter.test_targets': self.m.filter.test_targets, | 699 'self.m.filter.test_targets': self.m.filter.test_targets, |
719 'compile_targets': compile_targets, | 700 'compile_targets': compile_targets, |
720 } | 701 } |
721 with contextlib.closing(recipe_util.StringListIO()) as listio: | 702 with contextlib.closing(recipe_util.StringListIO()) as listio: |
722 json.dump(analyze_details, listio, indent=2, sort_keys=True) | 703 json.dump(analyze_details, listio, indent=2, sort_keys=True) |
723 step_result = self.m.step.active_result | 704 step_result = self.m.step.active_result |
724 step_result.presentation.logs['analyze_details'] = listio.lines | 705 step_result.presentation.logs['analyze_details'] = listio.lines |
725 | 706 |
726 return self.m.filter.test_targets, compile_targets | 707 return self.m.filter.test_targets, compile_targets |
727 | 708 |
| 709 # TODO(phajdan.jr): fix callers and remove chromium_tests.configure_swarming. |
728 def configure_swarming(self, project_name, precommit, mastername=None): | 710 def configure_swarming(self, project_name, precommit, mastername=None): |
729 """Configures default swarming dimensions and tags. | 711 return self.m.chromium_swarming.configure_swarming( # pragma: no cover |
730 | 712 project_name, precommit, mastername) |
731 Uses the 'chromium' global config to determine target platform defaults, | |
732 make sure something like chromium_tests.configure_build() has been called | |
733 beforehand. | |
734 | |
735 Args: | |
736 project_name: Lowercase name of the project, e.g. "blink", "chromium". | |
737 precommit: Boolean flag to indicate whether the tests are running before | |
738 the changes are commited. | |
739 """ | |
740 | |
741 # Set platform-specific default dims. | |
742 target_platform = self.m.chromium.c.TARGET_PLATFORM | |
743 swarming_dims = PER_TARGET_SWARMING_DIMS[target_platform] | |
744 for k, v in swarming_dims.iteritems(): | |
745 self.m.swarming.set_default_dimension(k, v) | |
746 | |
747 self.m.swarming.set_default_dimension('pool', 'Chrome') | |
748 self.m.swarming.add_default_tag('project:%s' % project_name) | |
749 self.m.swarming.default_idempotent = True | |
750 | |
751 if precommit: | |
752 self.m.swarming.default_priority = 30 | |
753 self.m.swarming.add_default_tag('purpose:pre-commit') | |
754 requester = self.m.properties.get('requester') | |
755 if requester == 'commit-bot@chromium.org': | |
756 self.m.swarming.add_default_tag('purpose:CQ') | |
757 blamelist = self.m.properties.get('blamelist') | |
758 if len(blamelist) == 1: | |
759 requester = blamelist[0] | |
760 else: | |
761 self.m.swarming.add_default_tag('purpose:ManualTS') | |
762 self.m.swarming.default_user = requester | |
763 | |
764 patch_project = self.m.properties.get('patch_project') | |
765 if patch_project: | |
766 self.m.swarming.add_default_tag('patch_project:%s' % patch_project) | |
767 else: | |
768 self.m.swarming.default_priority = MASTER_SWARMING_PRIORITIES[mastername] | |
769 self.m.swarming.add_default_tag('purpose:post-commit') | |
770 self.m.swarming.add_default_tag('purpose:CI') | |
771 | 713 |
772 def _build_gs_archive_url(self, mastername, master_config, buildername): | 714 def _build_gs_archive_url(self, mastername, master_config, buildername): |
773 """Returns the archive URL to pass to self.m.archive.zip_and_upload_build. | 715 """Returns the archive URL to pass to self.m.archive.zip_and_upload_build. |
774 | 716 |
775 Most builders on most masters use a standard format for the build archive | 717 Most builders on most masters use a standard format for the build archive |
776 URL, but some builders on some masters may specify custom places to upload | 718 URL, but some builders on some masters may specify custom places to upload |
777 builds to. These special cases include: | 719 builds to. These special cases include: |
778 'chromium.perf' or 'chromium.perf.fyi': | 720 'chromium.perf' or 'chromium.perf.fyi': |
779 Exclude the name of the master from the url. | 721 Exclude the name of the master from the url. |
780 'tryserver.chromium.perf', or | 722 'tryserver.chromium.perf', or |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 def get_compile_targets_for_scripts(self): | 778 def get_compile_targets_for_scripts(self): |
837 return self.m.python( | 779 return self.m.python( |
838 name='get compile targets for scripts', | 780 name='get compile targets for scripts', |
839 script=self.m.path['checkout'].join( | 781 script=self.m.path['checkout'].join( |
840 'testing', 'scripts', 'get_compile_targets.py'), | 782 'testing', 'scripts', 'get_compile_targets.py'), |
841 args=[ | 783 args=[ |
842 '--output', self.m.json.output(), | 784 '--output', self.m.json.output(), |
843 '--', | 785 '--', |
844 ] + self.get_common_args_for_scripts(), | 786 ] + self.get_common_args_for_scripts(), |
845 step_test_data=lambda: self.m.json.test_api.output({})) | 787 step_test_data=lambda: self.m.json.test_api.output({})) |
OLD | NEW |