| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 common_dimensions=['cores:8', 'pool:default'], | 29 common_dimensions=['cores:8', 'pool:default'], |
| 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'], |
| 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 ), | 40 ), |
| 40 ), | 41 ), |
| 41 ], | 42 ], |
| 42 ) | 43 ) |
| 43 self.cfg_test(cfg, []) | 44 self.cfg_test(cfg, []) |
| 44 | 45 |
| 45 def test_empty(self): | 46 def test_empty(self): |
| 46 self.cfg_test(Swarming(), ['hostname unspecified']) | 47 self.cfg_test(Swarming(), ['hostname unspecified']) |
| 47 | 48 |
| 48 def test_bad(self): | 49 def test_bad(self): |
| 49 cfg = Swarming( | 50 cfg = Swarming( |
| 50 common_swarming_tags=['wrong'], | 51 common_swarming_tags=['wrong'], |
| 51 common_dimensions=[''], | 52 common_dimensions=[''], |
| 52 builders=[ | 53 builders=[ |
| 53 Swarming.Builder( | 54 Swarming.Builder( |
| 54 swarming_tags=['wrong2'], | 55 swarming_tags=['wrong2'], |
| 55 dimensions=[':', 'a.b:c', 'pool:default'], | 56 dimensions=[':', 'a.b:c', 'pool:default'], |
| 56 ), | 57 ), |
| 57 Swarming.Builder( | 58 Swarming.Builder( |
| 58 name='b2', | 59 name='b2', |
| 59 swarming_tags=['builder:b2'], | 60 swarming_tags=['builder:b2'], |
| 60 dimensions=['x:y', 'x:y2'], | 61 dimensions=['x:y', 'x:y2'], |
| 61 recipe=Swarming.Recipe( | 62 recipe=Swarming.Recipe( |
| 62 properties=[ | 63 properties=[ |
| 63 '', | 64 '', |
| 64 ':', | 65 ':', |
| 65 'buildername:foobar', | 66 'buildername:foobar', |
| 67 'x:y', |
| 66 ], | 68 ], |
| 69 properties_j=[ |
| 70 'x:"y"', |
| 71 'y:b', |
| 72 'z', |
| 73 ] |
| 67 ), | 74 ), |
| 68 priority=-1, | 75 priority=-1, |
| 69 ), | 76 ), |
| 70 ], | 77 ], |
| 71 ) | 78 ) |
| 72 self.cfg_test(cfg, [ | 79 self.cfg_test(cfg, [ |
| 73 'hostname unspecified', | 80 'hostname unspecified', |
| 74 'common tag #1: does not have ":": wrong', | 81 'common tag #1: does not have ":": wrong', |
| 75 'common dimension #1: does not have ":"', | 82 'common dimension #1: does not have ":"', |
| 76 'builder #1: name unspecified', | 83 'builder #1: name unspecified', |
| 77 'builder #1: tag #1: does not have ":": wrong2', | 84 'builder #1: tag #1: does not have ":": wrong2', |
| 78 'builder #1: dimension #1: no key', | 85 'builder #1: dimension #1: no key', |
| 79 'builder #1: dimension #1: no value', | 86 'builder #1: dimension #1: no value', |
| 80 ('builder #1: dimension #2: ' | 87 ('builder #1: dimension #2: ' |
| 81 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'), | 88 'key "a.b" does not match pattern "^[a-zA-Z\_\-]+$"'), |
| 82 'builder #1: recipe unspecified', | 89 'builder #1: recipe unspecified', |
| 83 ('builder b2: tag #1: do not specify builder tag; ' | 90 ('builder b2: tag #1: do not specify builder tag; ' |
| 84 'it is added by swarmbucket automatically'), | 91 'it is added by swarmbucket automatically'), |
| 85 'builder b2: dimension #2: duplicate key x', | 92 'builder b2: dimension #2: duplicate key x', |
| 86 ('builder b2: has no "pool" dimension. ' | 93 ('builder b2: has no "pool" dimension. ' |
| 87 'Either define it in the builder or in "common_dimensions"'), | 94 'Either define it in the builder or in "common_dimensions"'), |
| 88 'builder b2: recipe: name unspecified', | 95 'builder b2: recipe: name unspecified', |
| 89 'builder b2: recipe: repository unspecified', | 96 'builder b2: recipe: repository unspecified', |
| 90 'builder b2: recipe: property #1: does not have colon', | 97 'builder b2: recipe: properties #1: does not have colon', |
| 91 'builder b2: recipe: property #2: key not specified', | 98 'builder b2: recipe: properties #2: key not specified', |
| 92 ('builder b2: recipe: property #3: ' | 99 ('builder b2: recipe: properties #3: ' |
| 93 'do not specify buildername property; ' | 100 'do not specify buildername property; ' |
| 94 'it is added by swarmbucket automatically'), | 101 'it is added by swarmbucket automatically'), |
| 102 'builder b2: recipe: properties_j #1: duplicate property "x"', |
| 103 'builder b2: recipe: properties_j #2: No JSON object could be decoded', |
| 104 'builder b2: recipe: properties_j #3: does not have colon', |
| 95 'builder b2: priority must be in [0, 200] range; got -1', | 105 'builder b2: priority must be in [0, 200] range; got -1', |
| 96 ]) | 106 ]) |
| 97 | 107 |
| 98 def test_common_recipe(self): | 108 def test_common_recipe(self): |
| 99 cfg = Swarming( | 109 cfg = Swarming( |
| 100 hostname='chromium-swarm.appspot.com', | 110 hostname='chromium-swarm.appspot.com', |
| 101 common_dimensions=['pool:default'], | 111 common_dimensions=['pool:default'], |
| 102 common_recipe=Swarming.Recipe( | 112 common_recipe=Swarming.Recipe( |
| 103 repository='https://x.com', | 113 repository='https://x.com', |
| 104 name='foo', | 114 name='foo', |
| (...skipping 15 matching lines...) Expand all Loading... |
| 120 common_dimensions=['pool:default'], | 130 common_dimensions=['pool:default'], |
| 121 common_recipe=Swarming.Recipe( | 131 common_recipe=Swarming.Recipe( |
| 122 name='foo', | 132 name='foo', |
| 123 properties=['a'], | 133 properties=['a'], |
| 124 ), | 134 ), |
| 125 builders=[ | 135 builders=[ |
| 126 Swarming.Builder(name='debug'), | 136 Swarming.Builder(name='debug'), |
| 127 ], | 137 ], |
| 128 ) | 138 ) |
| 129 self.cfg_test(cfg, [ | 139 self.cfg_test(cfg, [ |
| 130 'common_recipe: property #1: does not have colon', | 140 'common_recipe: properties #1: does not have colon', |
| 131 'builder debug: recipe: repository unspecified', | 141 'builder debug: recipe: repository unspecified', |
| 132 ]) | 142 ]) |
| OLD | NEW |