OLD | NEW |
---|---|
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 | 5 from common import cros_chromite |
6 | 6 |
7 DEPS = [ | 7 DEPS = [ |
8 'chromite', | 8 'chromite', |
9 'gitiles', | 9 'gitiles', |
10 'properties', | 10 'properties', |
11 ] | 11 ] |
12 | 12 |
13 # Map master name to 'chromite' configuration name. | 13 # Map master name to 'chromite' configuration name. |
14 _MASTER_CONFIG_MAP = { | 14 _MASTER_CONFIG_MAP = { |
15 'chromiumos.tryserver': { | 15 'chromiumos.tryserver': { |
16 'master_config': 'external', | 16 'master_config': 'chromiumos_tryserver', |
17 'variants': { | |
18 'etc': ['chromeos_tryserver_etc'], | |
19 }, | |
20 }, | 17 }, |
21 } | 18 } |
22 | 19 |
23 | 20 |
24 # Testing: Tryjob data file JSON. | 21 # Testing: Tryjob data file JSON. |
25 _TRYJOB_DATA = """ | 22 _TRYJOB_DATA = """ |
26 { | 23 { |
27 "name": "12345", | 24 "name": "12345", |
28 "email": "testauthor@fake.chromium.org", | 25 "email": "testauthor@fake.chromium.org", |
29 "extra_args": [ | 26 "extra_args": [ |
30 "--timeout", | 27 "--timeout", |
31 "14400", | 28 "14400", |
32 "--remote-trybot", | 29 "--remote-trybot", |
33 "--remote-version=4" | 30 "--remote-version=4" |
34 ] | 31 ] |
35 } | 32 } |
36 """ | 33 """ |
37 | 34 |
38 | 35 |
39 def RunSteps(api): | 36 def RunSteps(api): |
40 # The 'cbuildbot' config name to build is the name of the builder. | 37 # The 'cbuildbot' config name to build is the name of the builder. |
41 cbb_config_name = api.properties.get('buildername') | 38 # |
39 # TODO(dnj): After we fully switch to BuildBucket scheduling, load the config | |
40 # name from the BuildBucket job instead of `cbb_config` build | |
41 # property. We can't do this yet b/c the job description can | |
42 # specify multiple configs in one tryjob, so there's no way for us | |
43 # to know which one we are. | |
44 cbb_config_name = api.properties.get('cbb_config') | |
45 assert cbb_config_name, "No configuration name specified." | |
42 | 46 |
43 cbb = cros_chromite.Get() | 47 cbb = cros_chromite.Get() |
44 cbb_config = cbb.get(cbb_config_name) | 48 cbb_config = cbb.get(cbb_config_name) |
45 | 49 |
46 # Apply our generic configuration. | 50 # Apply our generic configuration. |
47 api.chromite.configure( | 51 api.chromite.configure( |
48 api.properties, | 52 api.properties, |
49 _MASTER_CONFIG_MAP) | 53 _MASTER_CONFIG_MAP) |
50 api.chromite.c.cbb.config = cbb_config_name | 54 api.chromite.c.cbb.config = cbb_config_name |
51 | 55 |
52 # Determine our build directory name. | 56 repository = api.properties.get('repository') |
53 namebase = cbb_config_name | 57 revision = api.properties.get('revision') |
54 if cbb_config: | 58 assert repository, "A repository must be specified." |
55 namebase = 'internal' if cbb_config.get('internal') else 'external' | 59 assert revision, "A revision must be specified." |
56 api.chromite.c.cbb.builddir = '%s_master' % (namebase,) | 60 assert api.chromite.check_repository('tryjob', repository), ( |
61 "Refusing to query unknown tryjob repository: %s" % (repository,)) | |
62 | |
63 # Add parameters specified in the tryjob description. | |
64 tryjob_args = api.chromite.load_try_job(repository, revision) | |
65 | |
66 # Determine our build directory name based on whether this build is internal | |
67 # or external. | |
68 # | |
69 # We have two checkout options: internal and external. By default we will | |
70 # infer# which to use based on the Chromite config. However, the pinned | |
David James
2015/09/16 00:52:57
s/infer# which/infer which/
| |
71 # Chromite config may not be up to date. If the value cannot be inferred, we | |
72 # will "quarantine" the build by running it in a separate "etc_master" | |
73 # build root and instructing `cbuildbot` to clobber beforehand. | |
74 # | |
75 # TODO: As the configuration owner, Chromite should be the entity to make the | |
76 # internal/external buildroot decision. A future iteration should add | |
David James
2015/09/16 00:52:57
Probably looks better not to indent this.
| |
77 # flags to Chromite to inform it of the internal/external build roots | |
78 # on the slave and defer to it to decide which to use based on the config | |
79 # that it is executing. | |
80 if not api.chromite.c.cbb.builddir: | |
81 if cbb_config: | |
82 namebase = 'internal' if cbb_config.get('internal') else 'external' | |
83 api.chromite.c.cbb.builddir = '%s_master' % (namebase,) | |
84 else: | |
85 api.chromite.c.cbb.builddir = 'etc_master' | |
86 api.chromite.c.cbb.clobber = True | |
57 | 87 |
58 # Run our 'cbuildbot'. | 88 # Run our 'cbuildbot'. |
59 api.chromite.run_cbuildbot(tryjob=True) | 89 api.chromite.run_cbuildbot(args=tryjob_args) |
60 | 90 |
61 | 91 |
62 def GenTests(api): | 92 def GenTests(api): |
63 # Test a CrOS tryjob. | 93 # Test a CrOS tryjob. |
64 yield ( | 94 yield ( |
65 api.test('basic') | 95 api.test('basic') |
66 + api.properties( | 96 + api.properties( |
67 mastername='chromiumos.tryserver', | 97 mastername='chromiumos.tryserver', |
68 buildername='x86-generic-full', | 98 buildername='full', |
69 slavename='test', | 99 slavename='test', |
70 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 100 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
71 revision=api.gitiles.make_hash('test'), | 101 revision=api.gitiles.make_hash('test'), |
102 cbb_config='x86-generic-full', | |
72 ) | 103 ) |
73 + api.step_data( | 104 + api.step_data( |
74 'Fetch tryjob commit', | 105 'Fetch tryjob commit', |
75 api.gitiles.make_commit_test_data( | 106 api.gitiles.make_commit_test_data( |
76 'test', | 107 'test', |
77 '\n'.join([ | 108 '\n'.join([ |
78 'Commit message!', | 109 'Commit message!', |
79 ]), | 110 ]), |
80 new_files=['user/user.12345'], | 111 new_files=['user/user.12345'], |
81 ), | 112 ), |
82 ) | 113 ) |
83 + api.step_data( | 114 + api.step_data( |
84 'Fetch tryjob descriptor (user/user.12345)', | 115 'Fetch tryjob descriptor (user/user.12345)', |
85 api.gitiles.make_encoded_file(_TRYJOB_DATA) | 116 api.gitiles.make_encoded_file(_TRYJOB_DATA) |
86 ) | 117 ) |
87 ) | 118 ) |
88 | 119 |
89 # Test an 'etc' job (no Chromite config). | 120 # Test a config that is not registered in Chromite. |
90 yield ( | 121 yield ( |
91 api.test('etc') | 122 api.test('unknown_config') |
92 + api.properties( | 123 + api.properties( |
93 mastername='chromiumos.tryserver', | 124 mastername='chromiumos.tryserver', |
94 buildername='etc', | 125 buildername='etc', |
95 slavename='test', | 126 slavename='test', |
96 cbb_variant='etc', | |
97 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 127 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
98 revision=api.gitiles.make_hash('test'), | 128 revision=api.gitiles.make_hash('test'), |
129 cbb_config='xxx-fakeboard-fakebuild', | |
99 ) | 130 ) |
100 + api.step_data( | 131 + api.step_data( |
101 'Fetch tryjob commit', | 132 'Fetch tryjob commit', |
102 api.gitiles.make_commit_test_data( | 133 api.gitiles.make_commit_test_data( |
103 'test', | 134 'test', |
104 '\n'.join([ | 135 '\n'.join([ |
105 'Commit message!', | 136 'Commit message!', |
106 ]), | 137 ]), |
107 new_files=['user/user.12345'], | 138 new_files=['user/user.12345'], |
108 ), | 139 ), |
109 ) | 140 ) |
110 + api.step_data( | 141 + api.step_data( |
111 'Fetch tryjob descriptor (user/user.12345)', | 142 'Fetch tryjob descriptor (user/user.12345)', |
112 api.gitiles.make_encoded_file(_TRYJOB_DATA) | 143 api.gitiles.make_encoded_file(_TRYJOB_DATA) |
113 ) | 144 ) |
114 ) | 145 ) |
115 | 146 |
116 # Test an invalid CrOS tryjob (no files in commit). | 147 # Test an invalid CrOS tryjob (no files in commit). |
117 yield ( | 148 yield ( |
118 api.test('basic_no_files_in_commit') | 149 api.test('basic_no_files_in_commit') |
119 + api.properties( | 150 + api.properties( |
120 mastername='chromiumos.tryserver', | 151 mastername='chromiumos.tryserver', |
121 buildername='x86-generic-full', | 152 buildername='full', |
122 slavename='test', | 153 slavename='test', |
123 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', | 154 repository='https://chromium.googlesource.com/chromiumos/tryjobs.git', |
124 revision=api.gitiles.make_hash('test'), | 155 revision=api.gitiles.make_hash('test'), |
156 cbb_config='x86-generic-full', | |
125 ) | 157 ) |
126 + api.step_data( | 158 + api.step_data( |
127 'Fetch tryjob commit', | 159 'Fetch tryjob commit', |
128 api.gitiles.make_commit_test_data( | 160 api.gitiles.make_commit_test_data( |
129 'test', | 161 'test', |
130 '\n'.join([ | 162 '\n'.join([ |
131 'Commit message!', | 163 'Commit message!', |
132 ]), | 164 ]), |
133 ), | 165 ), |
134 ) | 166 ) |
135 ) | 167 ) |
OLD | NEW |