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

Side by Side Diff: appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py

Issue 2209583003: swarmbucket: refactor builder defaults (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: swarmbucket: refactor builder defaults Created 4 years, 4 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
OLDNEW
1 1
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 from components import config as config_component 6 from components import config as config_component
7 from testing_utils import testing 7 from testing_utils import testing
8 8
9 from proto import project_config_pb2 9 from proto import project_config_pb2
10 from test import config_test 10 from test import config_test
(...skipping 30 matching lines...) Expand all
41 ), 41 ),
42 ], 42 ],
43 ) 43 )
44 self.cfg_test(cfg, []) 44 self.cfg_test(cfg, [])
45 45
46 def test_empty(self): 46 def test_empty(self):
47 self.cfg_test(Swarming(), ['hostname unspecified']) 47 self.cfg_test(Swarming(), ['hostname unspecified'])
48 48
49 def test_bad(self): 49 def test_bad(self):
50 cfg = Swarming( 50 cfg = Swarming(
51 hostname='chromium-swarm.appspot.com',
52 builders=[Swarming.Builder()],
53 )
54 self.cfg_test(cfg, [
55 'builder #1: name unspecified',
56 'builder #1: has no "pool" dimension',
57 'builder #1: recipe: name unspecified',
58 'builder #1: recipe: repository unspecified',
59 ])
60
61 cfg = Swarming(
62 hostname='chromium-swarm.appspot.com',
63 builder_defaults=Swarming.Builder(name='x'),
64 )
65 self.cfg_test(cfg, [
66 'builder_defaults: do not specify default name',
67 ])
68
69 cfg = Swarming(
51 common_swarming_tags=['wrong'], 70 common_swarming_tags=['wrong'],
52 common_dimensions=[''], 71 common_dimensions=[''],
53 task_template_canary_percentage=102, 72 task_template_canary_percentage=102,
54 builders=[ 73 builders=[
55 Swarming.Builder( 74 Swarming.Builder(
56 swarming_tags=['wrong2'], 75 swarming_tags=['wrong2'],
57 dimensions=[':', 'a.b:c', 'pool:default'], 76 dimensions=[':', 'a.b:c', 'pool:default'],
58 ), 77 ),
59 Swarming.Builder( 78 Swarming.Builder(
60 name='b2', 79 name='b2',
(...skipping 11 matching lines...) Expand all
72 'y:b', 91 'y:b',
73 'z', 92 'z',
74 ] 93 ]
75 ), 94 ),
76 priority=300, 95 priority=300,
77 ), 96 ),
78 ], 97 ],
79 ) 98 )
80 self.cfg_test(cfg, [ 99 self.cfg_test(cfg, [
81 'hostname unspecified', 100 'hostname unspecified',
82 'common tag #1: does not have ":": wrong',
83 'common dimension #1: does not have ":"',
84 'task_template_canary_percentage must must be in [0, 100]', 101 'task_template_canary_percentage must must be in [0, 100]',
85 'builder #1: name unspecified', 102 'builder_defaults: tag #1: does not have ":": wrong',
103 'builder_defaults: dimension #1: does not have ":"',
86 'builder #1: tag #1: does not have ":": wrong2', 104 'builder #1: tag #1: does not have ":": wrong2',
87 'builder #1: dimension #1: no key', 105 'builder #1: dimension #1: no key',
88 ('builder #1: dimension #2: ' 106 ('builder #1: dimension #2: '
89 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'), 107 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'),
90 'builder #1: recipe unspecified',
91 ('builder b2: tag #1: do not specify builder tag; ' 108 ('builder b2: tag #1: do not specify builder tag; '
92 'it is added by swarmbucket automatically'), 109 'it is added by swarmbucket automatically'),
93 'builder b2: dimension #2: duplicate key x', 110 'builder b2: dimension #2: duplicate key x',
94 ('builder b2: has no "pool" dimension. '
95 'Either define it in the builder or in "common_dimensions"'),
96 'builder b2: recipe: name unspecified',
97 'builder b2: recipe: repository unspecified',
98 'builder b2: recipe: properties #1: does not have colon', 111 'builder b2: recipe: properties #1: does not have colon',
99 'builder b2: recipe: properties #2: key not specified', 112 'builder b2: recipe: properties #2: key not specified',
100 ('builder b2: recipe: properties #3: ' 113 ('builder b2: recipe: properties #3: '
101 'do not specify buildername property; ' 114 'do not specify buildername property; '
102 'it is added by swarmbucket automatically'), 115 'it is added by swarmbucket automatically'),
103 'builder b2: recipe: properties_j #1: duplicate property "x"', 116 'builder b2: recipe: properties_j #1: duplicate property "x"',
104 'builder b2: recipe: properties_j #2: No JSON object could be decoded', 117 'builder b2: recipe: properties_j #2: No JSON object could be decoded',
105 'builder b2: recipe: properties_j #3: does not have colon', 118 'builder b2: recipe: properties_j #3: does not have colon',
106 'builder b2: priority must be in [0, 200] range; got 300', 119 'builder b2: priority must be in [0, 200] range; got 300',
107 ]) 120 ])
108 121
122 cfg = Swarming(
123 common_swarming_tags=['wrong'],
124 common_dimensions=[''],
125 task_template_canary_percentage=102,
126 builders=[
127 Swarming.Builder(
128 swarming_tags=['wrong2'],
129 dimensions=[':', 'a.b:c', 'pool:default'],
130 ),
131 Swarming.Builder(
132 name='b2',
133 swarming_tags=['builder:b2'],
134 dimensions=['x:y', 'x:y2'],
135 recipe=Swarming.Recipe(
136 properties=[
137 '',
138 ':',
139 'buildername:foobar',
140 'x:y',
141 ],
142 properties_j=[
143 'x:"y"',
144 'y:b',
145 'z',
146 ]
147 ),
148 priority=300,
149 ),
150 ],
151 )
152 self.cfg_test(cfg, [
153 'hostname unspecified',
154 'task_template_canary_percentage must must be in [0, 100]',
155 'builder_defaults: tag #1: does not have ":": wrong',
156 'builder_defaults: dimension #1: does not have ":"',
157 'builder #1: tag #1: does not have ":": wrong2',
158 'builder #1: dimension #1: no key',
159 ('builder #1: dimension #2: '
160 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'),
161 ('builder b2: tag #1: do not specify builder tag; '
162 'it is added by swarmbucket automatically'),
163 'builder b2: dimension #2: duplicate key x',
164 'builder b2: recipe: properties #1: does not have colon',
165 'builder b2: recipe: properties #2: key not specified',
166 ('builder b2: recipe: properties #3: '
167 'do not specify buildername property; '
168 'it is added by swarmbucket automatically'),
169 'builder b2: recipe: properties_j #1: duplicate property "x"',
170 'builder b2: recipe: properties_j #2: No JSON object could be decoded',
171 'builder b2: recipe: properties_j #3: does not have colon',
172 'builder b2: priority must be in [0, 200] range; got 300',
173 ])
174
175
109 def test_common_recipe(self): 176 def test_common_recipe(self):
110 cfg = Swarming( 177 cfg = Swarming(
111 hostname='chromium-swarm.appspot.com', 178 hostname='chromium-swarm.appspot.com',
112 common_dimensions=['pool:default'], 179 common_dimensions=['pool:default'],
113 common_recipe=Swarming.Recipe( 180 common_recipe=Swarming.Recipe(
114 repository='https://x.com', 181 repository='https://x.com',
115 name='foo', 182 name='foo',
116 properties=['a:b'], 183 properties=['a:b', 'x:y'],
117 ), 184 ),
118 builders=[ 185 builders=[
119 Swarming.Builder(name='debug'), 186 Swarming.Builder(name='debug'),
120 Swarming.Builder( 187 Swarming.Builder(
121 name='release', 188 name='release',
122 recipe=Swarming.Recipe(properties=['a:c']), 189 recipe=Swarming.Recipe(properties=['a:c'], properties_j=['x:']),
123 ), 190 ),
124 ], 191 ],
125 ) 192 )
126 self.cfg_test(cfg, []) 193 self.cfg_test(cfg, [])
127 194
128 def test_common_recipe_bad(self): 195 def test_common_recipe_bad(self):
129 cfg = Swarming( 196 cfg = Swarming(
130 hostname='chromium-swarm.appspot.com', 197 hostname='chromium-swarm.appspot.com',
131 common_dimensions=['pool:default'], 198 common_dimensions=['pool:default'],
132 common_recipe=Swarming.Recipe( 199 common_recipe=Swarming.Recipe(
133 name='foo', 200 name='foo',
134 properties=['a'], 201 properties=['a'],
135 ), 202 ),
136 builders=[ 203 builders=[
137 Swarming.Builder(name='debug'), 204 Swarming.Builder(name='debug'),
138 ], 205 ],
139 ) 206 )
140 self.cfg_test(cfg, [ 207 self.cfg_test(cfg, [
141 'common_recipe: properties #1: does not have colon', 208 'builder_defaults: recipe: properties #1: does not have colon',
142 'builder debug: recipe: repository unspecified',
143 ]) 209 ])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698