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

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

Issue 2090343006: swarmbucket: support for repository property (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: swarmbucket: support for repository property 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
« no previous file with comments | « appengine/cr-buildbucket/swarming/swarming.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import base64 5 import base64
6 import contextlib 6 import contextlib
7 import datetime 7 import datetime
8 import json 8 import json
9 9
10 from components import auth 10 from components import auth
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bucket='bucket', 104 bucket='bucket',
105 parameters={'builder_name': 'builder'} 105 parameters={'builder_name': 'builder'}
106 ) 106 )
107 self.assertTrue(swarming.is_for_swarming_async(build).get_result()) 107 self.assertTrue(swarming.is_for_swarming_async(build).get_result())
108 108
109 config_component.get_self_config_async.return_value = futuristic( 109 config_component.get_self_config_async.return_value = futuristic(
110 (None, None)) 110 (None, None))
111 self.assertFalse(swarming.is_for_swarming_async(build).get_result()) 111 self.assertFalse(swarming.is_for_swarming_async(build).get_result())
112 112
113 def test_build_parameters(self): 113 def test_build_parameters(self):
114 with self.assertRaises(errors.InvalidInputError): 114 bad = [
115 swarming.validate_build_parameters('foo', {'properties': []}) 115 {'properties': []},
116 with self.assertRaises(errors.InvalidInputError): 116 {'properties': {'buildername': 'bar'}},
117 swarming.validate_build_parameters('foo', { 117 {'changes': 0},
118 'properties': {'buildername': 'bar'}, 118 {'changes': [0]},
119 }) 119 {'changes': [{'author': 0}]},
120 {'changes': [{'author': {}}]},
121 {'changes': [{'author': {'email': 0}}]},
122 {'changes': [{'author': {'email': ''}}]},
123 {'changes': [{'author': {'email': 'a@example.com'}, 'repo_url': 0}]},
124 ]
125 for p in bad:
126 with self.assertRaises(errors.InvalidInputError):
127 swarming.validate_build_parameters('foo', p)
120 128
121 def test_validate_swarming_param(self): 129 def test_validate_swarming_param(self):
122 def validate_swarming_param(value): 130 def validate_swarming_param(value):
123 swarming.validate_build_parameters('builder', {'swarming': value}) 131 swarming.validate_build_parameters('builder', {'swarming': value})
124 132
125 validate_swarming_param(None) 133 validate_swarming_param(None)
126 validate_swarming_param({}) 134 validate_swarming_param({})
127 validate_swarming_param({'recipe': {}}) 135 validate_swarming_param({'recipe': {}})
128 validate_swarming_param({'recipe': {'revision': 'deadbeef'}}) 136 validate_swarming_param({'recipe': {'revision': 'deadbeef'}})
129 137
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 parameters={ 172 parameters={
165 'builder_name': 'builder', 173 'builder_name': 'builder',
166 'swarming': { 174 'swarming': {
167 'recipe': {'revision': 'badcoffee'}, 175 'recipe': {'revision': 'badcoffee'},
168 }, 176 },
169 'properties': { 177 'properties': {
170 'a': 'b', 178 'a': 'b',
171 }, 179 },
172 'changes': [{ 180 'changes': [{
173 'author': {'email': 'bob@example.com'}, 181 'author': {'email': 'bob@example.com'},
182 'repo_url': 'https://chromium.googlesource.com/chromium/src',
174 }] 183 }]
175 }, 184 },
176 ) 185 )
177 186
178 self.mock(net, 'json_request_async', mock.Mock(return_value=futuristic({ 187 self.mock(net, 'json_request_async', mock.Mock(return_value=futuristic({
179 'task_id': 'deadbeef', 188 'task_id': 'deadbeef',
180 'request': { 189 'request': {
181 'properties': { 190 'properties': {
182 'dimensions': [ 191 'dimensions': [
183 {'key': 'cores', 'value': '8'}, 192 {'key': 'cores', 'value': '8'},
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 'extra_args': [ 239 'extra_args': [
231 'cook', 240 'cook',
232 '-repository', 'https://example.com/repo', 241 '-repository', 'https://example.com/repo',
233 '-revision', 'badcoffee', 242 '-revision', 'badcoffee',
234 '-recipe', 'recipe', 243 '-recipe', 'recipe',
235 '-properties', json.dumps({ 244 '-properties', json.dumps({
236 'a': 'b', 245 'a': 'b',
237 'blamelist': ['bob@example.com'], 246 'blamelist': ['bob@example.com'],
238 'buildername': 'builder', 247 'buildername': 'builder',
239 'predefined-property': 'x', 248 'predefined-property': 'x',
249 'repository': 'https://chromium.googlesource.com/chromium/src',
240 }, sort_keys=True) 250 }, sort_keys=True)
241 ], 251 ],
242 'dimensions': sorted([ 252 'dimensions': sorted([
243 {'key': 'cores', 'value': '8'}, 253 {'key': 'cores', 'value': '8'},
244 {'key': 'os', 'value': 'Linux'}, 254 {'key': 'os', 'value': 'Linux'},
245 {'key': 'pool', 'value': 'Chrome'}, 255 {'key': 'pool', 'value': 'Chrome'},
246 ]), 256 ]),
247 }, 257 },
248 'pubsub_topic': 'projects/testbed-test/topics/swarming', 258 'pubsub_topic': 'projects/testbed-test/topics/swarming',
249 'pubsub_userdata': json.dumps({ 259 'pubsub_userdata': json.dumps({
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 self.assertEqual(build.status, model.BuildStatus.COMPLETED) 610 self.assertEqual(build.status, model.BuildStatus.COMPLETED)
601 self.assertEqual(build.result, model.BuildResult.FAILURE) 611 self.assertEqual(build.result, model.BuildResult.FAILURE)
602 self.assertEqual(build.failure_reason, model.FailureReason.INFRA_FAILURE) 612 self.assertEqual(build.failure_reason, model.FailureReason.INFRA_FAILURE)
603 self.assertIsNotNone(build.result_details) 613 self.assertIsNotNone(build.result_details)
604 self.assertIsNone(build.lease_key) 614 self.assertIsNone(build.lease_key)
605 self.assertIsNotNone(build.complete_time) 615 self.assertIsNotNone(build.complete_time)
606 616
607 617
608 def b64json(data): 618 def b64json(data):
609 return base64.b64encode(json.dumps(data)) 619 return base64.b64encode(json.dumps(data))
OLDNEW
« no previous file with comments | « appengine/cr-buildbucket/swarming/swarming.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698