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

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

Issue 1910713002: swarming: add support for cipd on the server side (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: nits Created 4 years, 7 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/message_conversion.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 by the Apache v2.0 license that can be 4 # Use of this source code is governed by the Apache v2.0 license that can be
5 # found in the LICENSE file. 5 # 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 self.mock(random, 'getrandbits', lambda _: 0x88) 141 self.mock(random, 'getrandbits', lambda _: 0x88)
142 now = datetime.datetime(2010, 1, 2, 3, 4, 5) 142 now = datetime.datetime(2010, 1, 2, 3, 4, 5)
143 self.mock_now(now) 143 self.mock_now(now)
144 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO)) 144 str_now = unicode(now.strftime(self.DATETIME_NO_MICRO))
145 request = swarming_rpcs.NewTaskRequest( 145 request = swarming_rpcs.NewTaskRequest(
146 expiration_secs=30, 146 expiration_secs=30,
147 name='job1', 147 name='job1',
148 priority=200, 148 priority=200,
149 properties=swarming_rpcs.TaskProperties( 149 properties=swarming_rpcs.TaskProperties(
150 command=['rm', '-rf', '/'], 150 command=['rm', '-rf', '/'],
151 packages=[
152 swarming_rpcs.CipdPackage(package_name='rm', version='latest'),
153 ],
151 dimensions=[ 154 dimensions=[
152 swarming_rpcs.StringPair(key='pool', value='default'), 155 swarming_rpcs.StringPair(key='pool', value='default'),
153 ], 156 ],
154 env=[ 157 env=[
155 swarming_rpcs.StringPair(key='PATH', value='/'), 158 swarming_rpcs.StringPair(key='PATH', value='/'),
156 ], 159 ],
157 execution_timeout_secs=30, 160 execution_timeout_secs=30,
158 io_timeout_secs=30), 161 io_timeout_secs=30),
159 tags=['foo:bar'], 162 tags=['foo:bar'],
160 user='joe@localhost', 163 user='joe@localhost',
161 pubsub_topic='projects/abc/topics/def', 164 pubsub_topic='projects/abc/topics/def',
162 pubsub_auth_token='secret that must not be shown', 165 pubsub_auth_token='secret that must not be shown',
163 pubsub_userdata='userdata') 166 pubsub_userdata='userdata')
164 expected = { 167 expected = {
165 u'request': { 168 u'request': {
166 u'authenticated': u'user:user@example.com', 169 u'authenticated': u'user:user@example.com',
167 u'created_ts': str_now, 170 u'created_ts': str_now,
168 u'expiration_secs': u'30', 171 u'expiration_secs': u'30',
169 u'name': u'job1', 172 u'name': u'job1',
170 u'priority': u'200', 173 u'priority': u'200',
171 u'properties': { 174 u'properties': {
172 u'command': [u'rm', u'-rf', u'/'], 175 u'command': [u'rm', u'-rf', u'/'],
176 u'packages': [{
177 u'package_name': u'rm',
178 u'version': u'latest',
179 }],
173 u'dimensions': [ 180 u'dimensions': [
174 {u'key': u'pool', u'value': u'default'}, 181 {u'key': u'pool', u'value': u'default'},
175 ], 182 ],
176 u'env': [ 183 u'env': [
177 {u'key': u'PATH', u'value': u'/'}, 184 {u'key': u'PATH', u'value': u'/'},
178 ], 185 ],
179 u'execution_timeout_secs': u'30', 186 u'execution_timeout_secs': u'30',
180 u'grace_period_secs': u'30', 187 u'grace_period_secs': u'30',
181 u'idempotent': False, 188 u'idempotent': False,
182 u'io_timeout_secs': u'30', 189 u'io_timeout_secs': u'30',
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 expiration_secs=30, 224 expiration_secs=30,
218 name='job1', 225 name='job1',
219 priority=200, 226 priority=200,
220 properties=swarming_rpcs.TaskProperties( 227 properties=swarming_rpcs.TaskProperties(
221 command=['python', 'run_test.py'], 228 command=['python', 'run_test.py'],
222 dimensions=[ 229 dimensions=[
223 swarming_rpcs.StringPair(key='os', value='Amiga'), 230 swarming_rpcs.StringPair(key='os', value='Amiga'),
224 swarming_rpcs.StringPair(key='pool', value='default'), 231 swarming_rpcs.StringPair(key='pool', value='default'),
225 ], 232 ],
226 execution_timeout_secs=3600, 233 execution_timeout_secs=3600,
234 idempotent=True,
227 io_timeout_secs=1200, 235 io_timeout_secs=1200,
228 idempotent=True), 236 packages=[
237 swarming_rpcs.CipdPackage(
238 package_name='rm',
239 version=test_env_handlers.PINNED_PACKAGE_VERSION),
240 ]),
229 tags=['foo:bar'], 241 tags=['foo:bar'],
230 user='joe@localhost') 242 user='joe@localhost')
231 expected = { 243 expected = {
232 u'request': { 244 u'request': {
233 u'authenticated': u'user:user@example.com', 245 u'authenticated': u'user:user@example.com',
234 u'created_ts': str_now_30, 246 u'created_ts': str_now_30,
235 u'expiration_secs': u'30', 247 u'expiration_secs': u'30',
236 u'name': u'job1', 248 u'name': u'job1',
237 u'priority': u'200', 249 u'priority': u'200',
238 u'properties': { 250 u'properties': {
239 u'command': [u'python', u'run_test.py'], 251 u'command': [u'python', u'run_test.py'],
240 u'dimensions': [ 252 u'dimensions': [
241 {u'key': u'os', u'value': u'Amiga'}, 253 {u'key': u'os', u'value': u'Amiga'},
242 {u'key': u'pool', u'value': u'default'}, 254 {u'key': u'pool', u'value': u'default'},
243 ], 255 ],
244 u'execution_timeout_secs': u'3600', 256 u'execution_timeout_secs': u'3600',
245 u'grace_period_secs': u'30', 257 u'grace_period_secs': u'30',
246 u'idempotent': True, 258 u'idempotent': True,
247 u'io_timeout_secs': u'1200', 259 u'io_timeout_secs': u'1200',
260 u'packages': [{
261 u'package_name': u'rm',
262 u'version': test_env_handlers.PINNED_PACKAGE_VERSION,
263 }],
248 }, 264 },
249 u'tags': [ 265 u'tags': [
250 u'foo:bar', 266 u'foo:bar',
251 u'os:Amiga', 267 u'os:Amiga',
252 u'pool:default', 268 u'pool:default',
253 u'priority:200', 269 u'priority:200',
254 u'user:joe@localhost', 270 u'user:joe@localhost',
255 ], 271 ],
256 u'user': u'joe@localhost', 272 u'user': u'joe@localhost',
257 }, 273 },
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 u'properties': { 381 u'properties': {
366 u'command': [u'python', u'run_test.py'], 382 u'command': [u'python', u'run_test.py'],
367 u'dimensions': [ 383 u'dimensions': [
368 {u'key': u'os', u'value': u'Amiga'}, 384 {u'key': u'os', u'value': u'Amiga'},
369 {u'key': u'pool', u'value': u'default'}, 385 {u'key': u'pool', u'value': u'default'},
370 ], 386 ],
371 u'execution_timeout_secs': u'3600', 387 u'execution_timeout_secs': u'3600',
372 u'grace_period_secs': u'30', 388 u'grace_period_secs': u'30',
373 u'idempotent': True, 389 u'idempotent': True,
374 u'io_timeout_secs': u'1200', 390 u'io_timeout_secs': u'1200',
391 u'packages': [{
392 u'package_name': u'rm',
393 u'version': test_env_handlers.PINNED_PACKAGE_VERSION,
394 }],
375 }, 395 },
376 u'tags': [ 396 u'tags': [
377 u'foo:bar', 397 u'foo:bar',
378 u'os:Amiga', 398 u'os:Amiga',
379 u'pool:default', 399 u'pool:default',
380 u'priority:200', 400 u'priority:200',
381 u'user:joe@localhost', 401 u'user:joe@localhost',
382 ], 402 ],
383 u'user': u'joe@localhost', 403 u'user': u'joe@localhost',
384 }, 404 },
385 { 405 {
386 u'authenticated': u'user:user@example.com', 406 u'authenticated': u'user:user@example.com',
387 u'created_ts': str_now, 407 u'created_ts': str_now,
388 u'expiration_secs': u'86400', 408 u'expiration_secs': u'86400',
389 u'name': u'task', 409 u'name': u'task',
390 u'priority': u'10', 410 u'priority': u'10',
391 u'properties': { 411 u'properties': {
392 u'command': [u'python', u'run_test.py'], 412 u'command': [u'python', u'run_test.py'],
393 u'dimensions': [ 413 u'dimensions': [
394 {u'key': u'os', u'value': u'Amiga'}, 414 {u'key': u'os', u'value': u'Amiga'},
395 {u'key': u'pool', u'value': u'default'}, 415 {u'key': u'pool', u'value': u'default'},
396 ], 416 ],
397 u'execution_timeout_secs': u'3600', 417 u'execution_timeout_secs': u'3600',
398 u'grace_period_secs': u'30', 418 u'grace_period_secs': u'30',
399 u'idempotent': True, 419 u'idempotent': True,
400 u'io_timeout_secs': u'1200', 420 u'io_timeout_secs': u'1200',
421 u'packages': [{
422 u'package_name': u'rm',
423 u'version': test_env_handlers.PINNED_PACKAGE_VERSION,
424 }],
401 }, 425 },
402 u'tags': [ 426 u'tags': [
403 u'commit:post', 427 u'commit:post',
404 u'os:Amiga', 428 u'os:Amiga',
405 u'os:Win', 429 u'os:Win',
406 u'pool:default', 430 u'pool:default',
407 u'priority:10', 431 u'priority:10',
408 u'project:yay', 432 u'project:yay',
409 u'user:joe@localhost', 433 u'user:joe@localhost',
410 ], 434 ],
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 u'properties': { 1044 u'properties': {
1021 u'command': [u'python', u'run_test.py'], 1045 u'command': [u'python', u'run_test.py'],
1022 u'dimensions': [ 1046 u'dimensions': [
1023 {u'key': u'os', u'value': u'Amiga'}, 1047 {u'key': u'os', u'value': u'Amiga'},
1024 {u'key': u'pool', u'value': u'default'}, 1048 {u'key': u'pool', u'value': u'default'},
1025 ], 1049 ],
1026 u'execution_timeout_secs': u'3600', 1050 u'execution_timeout_secs': u'3600',
1027 u'grace_period_secs': u'30', 1051 u'grace_period_secs': u'30',
1028 u'idempotent': False, 1052 u'idempotent': False,
1029 u'io_timeout_secs': u'1200', 1053 u'io_timeout_secs': u'1200',
1054 u'packages': [{
1055 u'package_name': u'rm',
1056 u'version': test_env_handlers.PINNED_PACKAGE_VERSION,
1057 }],
1030 }, 1058 },
1031 u'tags': [ 1059 u'tags': [
1032 u'os:Amiga', 1060 u'os:Amiga',
1033 u'pool:default', 1061 u'pool:default',
1034 u'priority:10', 1062 u'priority:10',
1035 u'user:joe@localhost', 1063 u'user:joe@localhost',
1036 ], 1064 ],
1037 u'user': u'joe@localhost', 1065 u'user': u'joe@localhost',
1038 } 1066 }
1039 self.assertEqual(expected, response.json) 1067 self.assertEqual(expected, response.json)
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 self.assertEqual(expected, response.json) 1363 self.assertEqual(expected, response.json)
1336 1364
1337 1365
1338 if __name__ == '__main__': 1366 if __name__ == '__main__':
1339 if '-v' in sys.argv: 1367 if '-v' in sys.argv:
1340 unittest.TestCase.maxDiff = None 1368 unittest.TestCase.maxDiff = None
1341 logging.basicConfig(level=logging.DEBUG) 1369 logging.basicConfig(level=logging.DEBUG)
1342 else: 1370 else:
1343 logging.basicConfig(level=logging.CRITICAL) 1371 logging.basicConfig(level=logging.CRITICAL)
1344 unittest.main() 1372 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_bot_test.py ('k') | appengine/swarming/message_conversion.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698