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

Side by Side Diff: appengine/swarming/handlers_endpoints_test.py

Issue 2069903003: swarming: custom cipd package paths (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@cipd-win
Patch Set: fix _validate_cipd_path Created 4 years, 6 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/swarming/handlers_bot_test.py ('k') | appengine/swarming/server/task_request.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding=utf-8 2 # coding=utf-8
3 # Copyright 2015 The LUCI Authors. All rights reserved. 3 # Copyright 2015 The LUCI Authors. All rights reserved.
4 # Use of this source code is governed under the Apache License, Version 2.0 4 # Use of this source code is governed under the Apache License, Version 2.0
5 # that can be found in the LICENSE file. 5 # that can be found in the LICENSE file.
6 6
7 import base64 7 import base64
8 import datetime 8 import datetime
9 import json 9 import json
10 import logging 10 import logging
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 self.mock_now(now) 147 self.mock_now(now)
148 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO)) 148 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO))
149 request = swarming_rpcs.NewTaskRequest( 149 request = swarming_rpcs.NewTaskRequest(
150 expiration_secs=30, 150 expiration_secs=30,
151 name='job1', 151 name='job1',
152 priority=200, 152 priority=200,
153 properties=swarming_rpcs.TaskProperties( 153 properties=swarming_rpcs.TaskProperties(
154 cipd_input=swarming_rpcs.CipdInput( 154 cipd_input=swarming_rpcs.CipdInput(
155 client_package=swarming_rpcs.CipdPackage( 155 client_package=swarming_rpcs.CipdPackage(
156 package_name='infra/tools/cipd/${platform}', 156 package_name='infra/tools/cipd/${platform}',
157 version='git_revision:deadbeef', 157 version='git_revision:deadbeef'),
158 ),
159 packages=[ 158 packages=[
160 swarming_rpcs.CipdPackage( 159 swarming_rpcs.CipdPackage(
161 package_name='rm', version='latest'), 160 package_name='rm', version='latest'),
162 ], 161 ],
163 server='https://chrome-infra-packages.appspot.com', 162 server='https://chrome-infra-packages.appspot.com'),
164 ),
165 command=['rm', '-rf', '/'], 163 command=['rm', '-rf', '/'],
166 dimensions=[ 164 dimensions=[
167 swarming_rpcs.StringPair(key='pool', value='default'), 165 swarming_rpcs.StringPair(key='pool', value='default'),
168 ], 166 ],
169 env=[ 167 env=[
170 swarming_rpcs.StringPair(key='PATH', value='/'), 168 swarming_rpcs.StringPair(key='PATH', value='/'),
171 ], 169 ],
172 execution_timeout_secs=30, 170 execution_timeout_secs=30,
173 io_timeout_secs=30), 171 io_timeout_secs=30),
174 tags=['foo:bar'], 172 tags=['foo:bar'],
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 239
242 request = swarming_rpcs.NewTaskRequest( 240 request = swarming_rpcs.NewTaskRequest(
243 expiration_secs=30, 241 expiration_secs=30,
244 name='job1', 242 name='job1',
245 priority=200, 243 priority=200,
246 properties=swarming_rpcs.TaskProperties( 244 properties=swarming_rpcs.TaskProperties(
247 command=['python', 'run_test.py'], 245 command=['python', 'run_test.py'],
248 cipd_input=swarming_rpcs.CipdInput( 246 cipd_input=swarming_rpcs.CipdInput(
249 client_package=swarming_rpcs.CipdPackage( 247 client_package=swarming_rpcs.CipdPackage(
250 package_name='infra/tools/cipd/${platform}', 248 package_name='infra/tools/cipd/${platform}',
251 version='git_revision:deadbeef', 249 version='git_revision:deadbeef'),
252 ),
253 packages=[ 250 packages=[
254 swarming_rpcs.CipdPackage( 251 swarming_rpcs.CipdPackage(
255 package_name='rm', 252 package_name='rm',
253 path='bin',
256 version='git_revision:deadbeef'), 254 version='git_revision:deadbeef'),
257 ], 255 ],
258 server='https://chrome-infra-packages.appspot.com', 256 server='https://chrome-infra-packages.appspot.com'),
259 ),
260 dimensions=[ 257 dimensions=[
261 swarming_rpcs.StringPair(key='os', value='Amiga'), 258 swarming_rpcs.StringPair(key='os', value='Amiga'),
262 swarming_rpcs.StringPair(key='pool', value='default'), 259 swarming_rpcs.StringPair(key='pool', value='default'),
263 ], 260 ],
264 execution_timeout_secs=3600, 261 execution_timeout_secs=3600,
265 idempotent=True, 262 idempotent=True,
266 io_timeout_secs=1200), 263 io_timeout_secs=1200),
267 tags=['foo:bar'], 264 tags=['foo:bar'],
268 user='joe@localhost') 265 user='joe@localhost')
269 expected = { 266 expected = {
270 u'request': { 267 u'request': {
271 u'authenticated': u'user:user@example.com', 268 u'authenticated': u'user:user@example.com',
272 u'created_ts': str_now_30, 269 u'created_ts': str_now_30,
273 u'expiration_secs': u'30', 270 u'expiration_secs': u'30',
274 u'name': u'job1', 271 u'name': u'job1',
275 u'priority': u'200', 272 u'priority': u'200',
276 u'properties': { 273 u'properties': {
277 u'cipd_input': { 274 u'cipd_input': {
278 u'client_package': { 275 u'client_package': {
279 u'package_name': u'infra/tools/cipd/${platform}', 276 u'package_name': u'infra/tools/cipd/${platform}',
280 u'version': u'git_revision:deadbeef', 277 u'version': u'git_revision:deadbeef',
281 }, 278 },
282 u'packages': [{ 279 u'packages': [{
283 u'package_name': u'rm', 280 u'package_name': u'rm',
284 u'version': 'git_revision:deadbeef', 281 u'path': u'bin',
282 u'version': u'git_revision:deadbeef',
285 }], 283 }],
286 u'server': u'https://chrome-infra-packages.appspot.com', 284 u'server': u'https://chrome-infra-packages.appspot.com',
287 }, 285 },
288 u'command': [u'python', u'run_test.py'], 286 u'command': [u'python', u'run_test.py'],
289 u'dimensions': [ 287 u'dimensions': [
290 {u'key': u'os', u'value': u'Amiga'}, 288 {u'key': u'os', u'value': u'Amiga'},
291 {u'key': u'pool', u'value': u'default'}, 289 {u'key': u'pool', u'value': u'default'},
292 ], 290 ],
293 u'execution_timeout_secs': u'3600', 291 u'execution_timeout_secs': u'3600',
294 u'grace_period_secs': u'30', 292 u'grace_period_secs': u'30',
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 u'name': u'job1', 410 u'name': u'job1',
413 u'priority': u'200', 411 u'priority': u'200',
414 u'properties': { 412 u'properties': {
415 u'cipd_input': { 413 u'cipd_input': {
416 u'client_package': { 414 u'client_package': {
417 u'package_name': u'infra/tools/cipd/${platform}', 415 u'package_name': u'infra/tools/cipd/${platform}',
418 u'version': u'git_revision:deadbeef', 416 u'version': u'git_revision:deadbeef',
419 }, 417 },
420 u'packages': [{ 418 u'packages': [{
421 u'package_name': u'rm', 419 u'package_name': u'rm',
422 u'version': 'git_revision:deadbeef', 420 u'path': u'bin',
421 u'version': u'git_revision:deadbeef',
423 }], 422 }],
424 u'server': u'https://chrome-infra-packages.appspot.com', 423 u'server': u'https://chrome-infra-packages.appspot.com',
425 }, 424 },
426 u'command': [u'python', u'run_test.py'], 425 u'command': [u'python', u'run_test.py'],
427 u'dimensions': [ 426 u'dimensions': [
428 {u'key': u'os', u'value': u'Amiga'}, 427 {u'key': u'os', u'value': u'Amiga'},
429 {u'key': u'pool', u'value': u'default'}, 428 {u'key': u'pool', u'value': u'default'},
430 ], 429 ],
431 u'execution_timeout_secs': u'3600', 430 u'execution_timeout_secs': u'3600',
432 u'grace_period_secs': u'30', 431 u'grace_period_secs': u'30',
(...skipping 16 matching lines...) Expand all
449 u'name': u'task', 448 u'name': u'task',
450 u'priority': u'10', 449 u'priority': u'10',
451 u'properties': { 450 u'properties': {
452 u'cipd_input': { 451 u'cipd_input': {
453 u'client_package': { 452 u'client_package': {
454 u'package_name': u'infra/tools/cipd/${platform}', 453 u'package_name': u'infra/tools/cipd/${platform}',
455 u'version': u'git_revision:deadbeef', 454 u'version': u'git_revision:deadbeef',
456 }, 455 },
457 u'packages': [{ 456 u'packages': [{
458 u'package_name': u'rm', 457 u'package_name': u'rm',
459 u'version': 'git_revision:deadbeef', 458 u'path': u'bin',
459 u'version': u'git_revision:deadbeef',
460 }], 460 }],
461 u'server': u'https://chrome-infra-packages.appspot.com', 461 u'server': u'https://chrome-infra-packages.appspot.com',
462 }, 462 },
463 u'command': [u'python', u'run_test.py'], 463 u'command': [u'python', u'run_test.py'],
464 u'dimensions': [ 464 u'dimensions': [
465 {u'key': u'os', u'value': u'Amiga'}, 465 {u'key': u'os', u'value': u'Amiga'},
466 {u'key': u'pool', u'value': u'default'}, 466 {u'key': u'pool', u'value': u'default'},
467 ], 467 ],
468 u'execution_timeout_secs': u'3600', 468 u'execution_timeout_secs': u'3600',
469 u'grace_period_secs': u'30', 469 u'grace_period_secs': u'30',
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 u'priority:200', 611 u'priority:200',
612 u'user:joe@localhost', 612 u'user:joe@localhost',
613 ], 613 ],
614 u'user': u'joe@localhost', 614 u'user': u'joe@localhost',
615 }, 615 },
616 u'task_id': u'5cee488008810', 616 u'task_id': u'5cee488008810',
617 } 617 }
618 response = self.call_api('new', body=message_to_dict(request)) 618 response = self.call_api('new', body=message_to_dict(request))
619 self.assertEqual(expected, response.json) 619 self.assertEqual(expected, response.json)
620 620
621 def test_new_cipd_packages_with_defaults(self): 621 def test_new_cipd_package_with_defaults(self):
622 self.mock(random, 'getrandbits', lambda _: 0x88) 622 self.mock(random, 'getrandbits', lambda _: 0x88)
623 now = datetime.datetime(2010, 1, 2, 3, 4, 5) 623 now = datetime.datetime(2010, 1, 2, 3, 4, 5)
624 self.mock_now(now) 624 self.mock_now(now)
625 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO)) 625 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO))
626 626
627 # Define settings on the server. 627 # Define settings on the server.
628 cfg = config.settings() 628 cfg = config.settings()
629 cfg.cipd.default_client_package.package_name = ( 629 cfg.cipd.default_client_package.package_name = (
630 'infra/tools/cipd/${platform}') 630 'infra/tools/cipd/${platform}')
631 cfg.cipd.default_client_package.version = 'git_revision:deadbeef' 631 cfg.cipd.default_client_package.version = 'git_revision:deadbeef'
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 u'name': u'hi', 1241 u'name': u'hi',
1242 u'priority': u'10', 1242 u'priority': u'10',
1243 u'properties': { 1243 u'properties': {
1244 u'cipd_input': { 1244 u'cipd_input': {
1245 u'client_package': { 1245 u'client_package': {
1246 u'package_name': u'infra/tools/cipd/${platform}', 1246 u'package_name': u'infra/tools/cipd/${platform}',
1247 u'version': u'git_revision:deadbeef', 1247 u'version': u'git_revision:deadbeef',
1248 }, 1248 },
1249 u'packages': [{ 1249 u'packages': [{
1250 u'package_name': u'rm', 1250 u'package_name': u'rm',
1251 u'path': u'bin',
1251 u'version': 'git_revision:deadbeef', 1252 u'version': 'git_revision:deadbeef',
1252 }], 1253 }],
1253 u'server': u'https://chrome-infra-packages.appspot.com', 1254 u'server': u'https://chrome-infra-packages.appspot.com',
1254 }, 1255 },
1255 u'command': [u'python', u'run_test.py'], 1256 u'command': [u'python', u'run_test.py'],
1256 u'dimensions': [ 1257 u'dimensions': [
1257 {u'key': u'os', u'value': u'Amiga'}, 1258 {u'key': u'os', u'value': u'Amiga'},
1258 {u'key': u'pool', u'value': u'default'}, 1259 {u'key': u'pool', u'value': u'default'},
1259 ], 1260 ],
1260 u'execution_timeout_secs': u'3600', 1261 u'execution_timeout_secs': u'3600',
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 self.assertEqual(expected, response.json) 1567 self.assertEqual(expected, response.json)
1567 1568
1568 1569
1569 if __name__ == '__main__': 1570 if __name__ == '__main__':
1570 if '-v' in sys.argv: 1571 if '-v' in sys.argv:
1571 unittest.TestCase.maxDiff = None 1572 unittest.TestCase.maxDiff = None
1572 logging.basicConfig(level=logging.DEBUG) 1573 logging.basicConfig(level=logging.DEBUG)
1573 else: 1574 else:
1574 logging.basicConfig(level=logging.CRITICAL) 1575 logging.basicConfig(level=logging.CRITICAL)
1575 unittest.main() 1576 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_bot_test.py ('k') | appengine/swarming/server/task_request.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698