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

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

Issue 2160913003: swarmbucket: fix empty dimension value (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: add swarmbucketbuilders test Created 4 years, 5 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
11 from swarming import swarmingcfg 11 from swarming import swarmingcfg
12 12
13 13
14 Swarming = project_config_pb2.Swarming 14 Swarming = project_config_pb2.Swarming
15 15
16 16
17 class SwarmingCfgTest(testing.AppengineTestCase): 17 class SwarmingCfgTest(testing.AppengineTestCase):
18 def cfg_test(self, cfg, expected_errors): 18 def cfg_test(self, cfg, expected_errors):
19 ctx = config_component.validation.Context() 19 ctx = config_component.validation.Context()
20 swarmingcfg.validate_cfg(cfg, ctx) 20 swarmingcfg.validate_cfg(cfg, ctx)
21 self.assertEqual( 21 self.assertEqual(
22 map(config_test.errmsg, expected_errors), 22 map(config_test.errmsg, expected_errors),
23 ctx.result().messages) 23 ctx.result().messages)
24 24
25 def test_valid(self): 25 def test_valid(self):
26 cfg = Swarming( 26 cfg = Swarming(
27 hostname='chromium-swarm.appspot.com', 27 hostname='chromium-swarm.appspot.com',
28 common_swarming_tags=['master:master.a'], 28 common_swarming_tags=['master:master.a'],
29 common_dimensions=['cores:8', 'pool:default'], 29 common_dimensions=['cores:8', 'pool:default', 'cpu:x86-64'],
30 builders=[ 30 builders=[
31 Swarming.Builder( 31 Swarming.Builder(
32 name='release', 32 name='release',
33 swarming_tags=['a:b'], 33 swarming_tags=['a:b'],
34 dimensions=['os:Linux'], 34 dimensions=['os:Linux', 'cpu:'],
35 recipe=Swarming.Recipe( 35 recipe=Swarming.Recipe(
36 repository='https://x.com', 36 repository='https://x.com',
37 name='foo', 37 name='foo',
38 properties=['a:b'], 38 properties=['a:b'],
39 properties_j=['x:true'], 39 properties_j=['x:true'],
40 ), 40 ),
41 ), 41 ),
42 ], 42 ],
43 ) 43 )
44 self.cfg_test(cfg, []) 44 self.cfg_test(cfg, [])
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ), 76 ),
77 ], 77 ],
78 ) 78 )
79 self.cfg_test(cfg, [ 79 self.cfg_test(cfg, [
80 'hostname unspecified', 80 'hostname unspecified',
81 'common tag #1: does not have ":": wrong', 81 'common tag #1: does not have ":": wrong',
82 'common dimension #1: does not have ":"', 82 'common dimension #1: does not have ":"',
83 'builder #1: name unspecified', 83 'builder #1: name unspecified',
84 'builder #1: tag #1: does not have ":": wrong2', 84 'builder #1: tag #1: does not have ":": wrong2',
85 'builder #1: dimension #1: no key', 85 'builder #1: dimension #1: no key',
86 'builder #1: dimension #1: no value',
87 ('builder #1: dimension #2: ' 86 ('builder #1: dimension #2: '
88 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'), 87 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'),
89 'builder #1: recipe unspecified', 88 'builder #1: recipe unspecified',
90 ('builder b2: tag #1: do not specify builder tag; ' 89 ('builder b2: tag #1: do not specify builder tag; '
91 'it is added by swarmbucket automatically'), 90 'it is added by swarmbucket automatically'),
92 'builder b2: dimension #2: duplicate key x', 91 'builder b2: dimension #2: duplicate key x',
93 ('builder b2: has no "pool" dimension. ' 92 ('builder b2: has no "pool" dimension. '
94 'Either define it in the builder or in "common_dimensions"'), 93 'Either define it in the builder or in "common_dimensions"'),
95 'builder b2: recipe: name unspecified', 94 'builder b2: recipe: name unspecified',
96 'builder b2: recipe: repository unspecified', 95 'builder b2: recipe: repository unspecified',
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 properties=['a'], 132 properties=['a'],
134 ), 133 ),
135 builders=[ 134 builders=[
136 Swarming.Builder(name='debug'), 135 Swarming.Builder(name='debug'),
137 ], 136 ],
138 ) 137 )
139 self.cfg_test(cfg, [ 138 self.cfg_test(cfg, [
140 'common_recipe: properties #1: does not have colon', 139 'common_recipe: properties #1: does not have colon',
141 'builder debug: recipe: repository unspecified', 140 'builder debug: recipe: repository unspecified',
142 ]) 141 ])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698