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

Unified 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: deepcopy and subctx 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/cr-buildbucket/swarming/swarmingcfg.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py
diff --git a/appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py b/appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py
index 218d7c3bc1910882cb5207cd9b6a4e31bdb05523..9b07aeeb9e36324b905f43bc661ff351bcb5ec99 100755
--- a/appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py
+++ b/appengine/cr-buildbucket/swarming/test/swarmingcfg_test.py
@@ -48,6 +48,25 @@ class SwarmingCfgTest(testing.AppengineTestCase):
def test_bad(self):
cfg = Swarming(
+ hostname='chromium-swarm.appspot.com',
+ builders=[Swarming.Builder()],
+ )
+ self.cfg_test(cfg, [
+ 'builder #1: name unspecified',
+ 'builder #1: has no "pool" dimension',
+ 'builder #1: recipe: name unspecified',
+ 'builder #1: recipe: repository unspecified',
+ ])
+
+ cfg = Swarming(
+ hostname='chromium-swarm.appspot.com',
+ builder_defaults=Swarming.Builder(name='x'),
+ )
+ self.cfg_test(cfg, [
+ 'builder_defaults: do not specify default name',
+ ])
+
+ cfg = Swarming(
common_swarming_tags=['wrong'],
common_dimensions=[''],
task_template_canary_percentage=102,
@@ -79,22 +98,16 @@ class SwarmingCfgTest(testing.AppengineTestCase):
)
self.cfg_test(cfg, [
'hostname unspecified',
- 'common tag #1: does not have ":": wrong',
- 'common dimension #1: does not have ":"',
'task_template_canary_percentage must must be in [0, 100]',
- 'builder #1: name unspecified',
+ 'builder_defaults: tag #1: does not have ":": wrong',
+ 'builder_defaults: dimension #1: does not have ":"',
'builder #1: tag #1: does not have ":": wrong2',
'builder #1: dimension #1: no key',
('builder #1: dimension #2: '
'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'),
- 'builder #1: recipe unspecified',
('builder b2: tag #1: do not specify builder tag; '
'it is added by swarmbucket automatically'),
'builder b2: dimension #2: duplicate key x',
- ('builder b2: has no "pool" dimension. '
- 'Either define it in the builder or in "common_dimensions"'),
- 'builder b2: recipe: name unspecified',
- 'builder b2: recipe: repository unspecified',
'builder b2: recipe: properties #1: does not have colon',
'builder b2: recipe: properties #2: key not specified',
('builder b2: recipe: properties #3: '
@@ -106,6 +119,60 @@ class SwarmingCfgTest(testing.AppengineTestCase):
'builder b2: priority must be in [0, 200] range; got 300',
])
+ cfg = Swarming(
+ common_swarming_tags=['wrong'],
+ common_dimensions=[''],
+ task_template_canary_percentage=102,
+ builders=[
+ Swarming.Builder(
+ swarming_tags=['wrong2'],
+ dimensions=[':', 'a.b:c', 'pool:default'],
+ ),
+ Swarming.Builder(
+ name='b2',
+ swarming_tags=['builder:b2'],
+ dimensions=['x:y', 'x:y2'],
+ recipe=Swarming.Recipe(
+ properties=[
+ '',
+ ':',
+ 'buildername:foobar',
+ 'x:y',
+ ],
+ properties_j=[
+ 'x:"y"',
+ 'y:b',
+ 'z',
+ ]
+ ),
+ priority=300,
+ ),
+ ],
+ )
+ self.cfg_test(cfg, [
+ 'hostname unspecified',
+ 'task_template_canary_percentage must must be in [0, 100]',
+ 'builder_defaults: tag #1: does not have ":": wrong',
+ 'builder_defaults: dimension #1: does not have ":"',
+ 'builder #1: tag #1: does not have ":": wrong2',
+ 'builder #1: dimension #1: no key',
+ ('builder #1: dimension #2: '
+ 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'),
+ ('builder b2: tag #1: do not specify builder tag; '
+ 'it is added by swarmbucket automatically'),
+ 'builder b2: dimension #2: duplicate key x',
+ 'builder b2: recipe: properties #1: does not have colon',
+ 'builder b2: recipe: properties #2: key not specified',
+ ('builder b2: recipe: properties #3: '
+ 'do not specify buildername property; '
+ 'it is added by swarmbucket automatically'),
+ 'builder b2: recipe: properties_j #1: duplicate property "x"',
+ 'builder b2: recipe: properties_j #2: No JSON object could be decoded',
+ 'builder b2: recipe: properties_j #3: does not have colon',
+ 'builder b2: priority must be in [0, 200] range; got 300',
+ ])
+
+
def test_common_recipe(self):
cfg = Swarming(
hostname='chromium-swarm.appspot.com',
@@ -113,13 +180,13 @@ class SwarmingCfgTest(testing.AppengineTestCase):
common_recipe=Swarming.Recipe(
repository='https://x.com',
name='foo',
- properties=['a:b'],
+ properties=['a:b', 'x:y'],
),
builders=[
Swarming.Builder(name='debug'),
Swarming.Builder(
name='release',
- recipe=Swarming.Recipe(properties=['a:c']),
+ recipe=Swarming.Recipe(properties=['a:c'], properties_j=['x:']),
),
],
)
@@ -138,6 +205,5 @@ class SwarmingCfgTest(testing.AppengineTestCase):
],
)
self.cfg_test(cfg, [
- 'common_recipe: properties #1: does not have colon',
- 'builder debug: recipe: repository unspecified',
+ 'builder_defaults: recipe: properties #1: does not have colon',
])
« no previous file with comments | « appengine/cr-buildbucket/swarming/swarmingcfg.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698