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

Side by Side Diff: scripts/slave/recipes/cros/cbuildbot_tryjob.py

Issue 1345143004: CrOS: Use local Chromite checkout for configs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 from common import cros_chromite
6
7 DEPS = [ 5 DEPS = [
8 'chromite', 6 'chromite',
9 'gitiles', 7 'gitiles',
10 'json', 8 'json',
11 'properties', 9 'properties',
12 ] 10 ]
13 11
14 # Map master name to 'chromite' configuration name. 12 # Map master name to 'chromite' configuration name.
15 _MASTER_CONFIG_MAP = { 13 _MASTER_CONFIG_MAP = {
16 'chromiumos.tryserver': { 14 'chromiumos.tryserver': {
17 'master_config': 'chromiumos_tryserver', 15 'master_config': 'chromiumos_tryserver',
18 }, 16 },
19 } 17 }
20 18
21 19
22 # Testing: Tryjob data file JSON. 20 # Testing: Tryjob data file JSON.
23 _TRYJOB_DATA = """ 21 _TRYJOB_DATA = """
24 { 22 {
25 "name": "12345", 23 "name": "12345",
26 "email": "testauthor@fake.chromium.org", 24 "email": "testauthor@fake.chromium.org",
27 "extra_args": [ 25 "extra_args": [
28 "--timeout", 26 "--timeout",
29 "14400", 27 "14400",
30 "--remote-trybot", 28 "--remote-trybot",
31 "--remote-version=4" 29 "--remote-version=4"
32 ] 30 ]
33 } 31 }
34 """ 32 """
35 33
34 # JSON string containing sufficient Chromite configuration layout for our test
35 # configs.
36 _CHROMITE_CONFIG = {
37 'x86-generic-full': {},
38 'internal-paladin': {
39 'internal': True,
40 },
41 }
42
36 43
37 def RunSteps(api): 44 def RunSteps(api):
38 # The 'cbuildbot' config name to build is the name of the builder. 45 # The 'cbuildbot' config name to build is the name of the builder.
39 # 46 #
40 # TODO(dnj): After we fully switch to BuildBucket scheduling, load the config 47 # TODO(dnj): After we fully switch to BuildBucket scheduling, load the config
41 # name from the BuildBucket job instead of `cbb_config` build 48 # name from the BuildBucket job instead of `cbb_config` build
42 # property. We can't do this yet b/c the job description can 49 # property. We can't do this yet b/c the job description can
43 # specify multiple configs in one tryjob, so there's no way for us 50 # specify multiple configs in one tryjob, so there's no way for us
44 # to know which one we are. 51 # to know which one we are.
45 cbb_config_name = api.properties.get('cbb_config') 52 cbb_config_name = api.properties.get('cbb_config')
46 assert cbb_config_name, "No configuration name specified." 53 assert cbb_config_name, "No configuration name specified."
47 54
48 cbb = cros_chromite.Get()
49 cbb_config = cbb.get(cbb_config_name)
50
51 # Apply our generic configuration. 55 # Apply our generic configuration.
52 api.chromite.configure( 56 api.chromite.configure(
53 api.properties, 57 api.properties,
54 _MASTER_CONFIG_MAP) 58 _MASTER_CONFIG_MAP)
55 api.chromite.c.cbb.config = cbb_config_name 59 api.chromite.c.cbb.config = cbb_config_name
56 60
57 repository = api.properties.get('repository') 61 repository = api.properties.get('repository')
58 revision = api.properties.get('revision') 62 revision = api.properties.get('revision')
59 assert repository, "A repository must be specified." 63 assert repository, "A repository must be specified."
60 assert revision, "A revision must be specified." 64 assert revision, "A revision must be specified."
61 assert api.chromite.check_repository('tryjob', repository), ( 65 assert api.chromite.check_repository('tryjob', repository), (
62 "Refusing to query unknown tryjob repository: %s" % (repository,)) 66 "Refusing to query unknown tryjob repository: %s" % (repository,))
63 67
68 # Load the Chromite configuration for our target.
69 api.chromite.checkout_chromite()
70 cbb_config = api.chromite.load_config(cbb_config_name)
71
64 # Add parameters specified in the tryjob description. 72 # Add parameters specified in the tryjob description.
65 tryjob_args = api.properties.get('cbb_extra_args', []) 73 tryjob_args = api.properties.get('cbb_extra_args', [])
66 if tryjob_args: 74 if tryjob_args:
67 tryjob_args = api.json.loads(tryjob_args) 75 tryjob_args = api.json.loads(tryjob_args)
68 76
69 # Determine our build directory name based on whether this build is internal 77 # Determine our build directory name based on whether this build is internal
70 # or external. 78 # or external.
71 # 79 #
72 # We have two checkout options: internal and external. By default we will 80 # We have two checkout options: internal and external. By default we will
73 # infer which to use based on the Chromite config. However, the pinned 81 # infer which to use based on the Chromite config. However, the pinned
74 # Chromite config may not be up to date. If the value cannot be inferred, we 82 # Chromite config may not be up to date. If the value cannot be inferred, we
75 # will "quarantine" the build by running it in a separate "etc_master" 83 # will "quarantine" the build by running it in a separate "etc_master"
76 # build root and instructing `cbuildbot` to clobber beforehand. 84 # build root and instructing `cbuildbot` to clobber beforehand.
77 # 85 #
78 # TODO: As the configuration owner, Chromite should be the entity to make the 86 # TODO: As the configuration owner, Chromite should be the entity to make the
79 # internal/external buildroot decision. A future iteration should add flags 87 # internal/external buildroot decision. A future iteration should add flags
80 # to Chromite to inform it of the internal/external build roots on the slave 88 # to Chromite to inform it of the internal/external build roots on the slave
81 # and defer to it to decide which to use based on the config that it is 89 # and defer to it to decide which to use based on the config that it is
82 # executing. 90 # executing.
83 if not api.chromite.c.cbb.builddir: 91 if not api.chromite.c.cbb.builddir:
84 if cbb_config: 92 if cbb_config:
85 namebase = 'internal' if cbb_config.get('internal') else 'external' 93 namebase = 'internal' if cbb_config.get('internal') else 'external'
86 api.chromite.c.cbb.builddir = '%s_master' % (namebase,) 94 api.chromite.c.cbb.builddir = '%s_master' % (namebase,)
87 else: 95 else:
88 api.chromite.c.cbb.builddir = 'etc_master' 96 api.chromite.c.cbb.builddir = 'etc_master'
89 api.chromite.c.cbb.clobber = True 97 api.chromite.c.cbb.clobber = True
90 98
91 # Run our 'cbuildbot'. 99 # Run our 'cbuildbot'.
92 api.chromite.run_cbuildbot(args=tryjob_args) 100 api.chromite.run(args=tryjob_args)
93 101
94 102
95 def GenTests(api): 103 def GenTests(api):
96 # Test a CrOS tryjob. 104 # Test a CrOS tryjob.
97 yield ( 105 yield (
98 api.test('basic') 106 api.test('external')
99 + api.properties( 107 + api.properties(
100 mastername='chromiumos.tryserver', 108 mastername='chromiumos.tryserver',
101 buildername='full', 109 buildername='full',
102 slavename='test', 110 slavename='test',
103 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', 111 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git',
104 revision=api.gitiles.make_hash('test'), 112 revision=api.gitiles.make_hash('test'),
105 cbb_config='x86-generic-full', 113 cbb_config='x86-generic-full',
106 cbb_extra_args='["--timeout", "14400", "--remote-trybot",' 114 cbb_extra_args='["--timeout", "14400", "--remote-trybot",'
107 '"--remote-version=4"]', 115 '"--remote-version=4"]',
108 ) 116 )
117 + api.chromite.seed_chromite_config(_CHROMITE_CONFIG)
118 )
119
120 yield (
121 api.test('internal')
122 + api.properties(
123 mastername='chromiumos.tryserver',
124 buildername='paladin',
125 slavename='test',
126 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git',
127 revision=api.gitiles.make_hash('test'),
128 cbb_config='internal-paladin',
129 cbb_extra_args='["--timeout", "14400", "--remote-trybot",'
130 '"--remote-version=4"]',
131 )
132 + api.chromite.seed_chromite_config(_CHROMITE_CONFIG)
109 ) 133 )
110 134
111 # Test a config that is not registered in Chromite. 135 # Test a config that is not registered in Chromite.
112 yield ( 136 yield (
113 api.test('unknown_config') 137 api.test('unknown_config')
114 + api.properties( 138 + api.properties(
115 mastername='chromiumos.tryserver', 139 mastername='chromiumos.tryserver',
116 buildername='etc', 140 buildername='etc',
117 slavename='test', 141 slavename='test',
118 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', 142 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git',
119 revision=api.gitiles.make_hash('test'), 143 revision=api.gitiles.make_hash('test'),
120 cbb_config='xxx-fakeboard-fakebuild', 144 cbb_config='xxx-fakeboard-fakebuild',
121 cbb_extra_args='["--timeout", "14400", "--remote-trybot",' 145 cbb_extra_args='["--timeout", "14400", "--remote-trybot",'
122 '"--remote-version=4"]', 146 '"--remote-version=4"]',
123 ) 147 )
148 + api.chromite.seed_chromite_config(_CHROMITE_CONFIG)
124 ) 149 )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698