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

Side by Side Diff: appengine/swarming/server/task_request_test.py

Issue 2453873002: Add --output option to Swarming client and pass it through to the bot (Closed)
Patch Set: Fix help text for --output Created 4 years, 1 month 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import datetime 6 import datetime
7 import logging 7 import logging
8 import random 8 import random
9 import sys 9 import sys
10 import unittest 10 import unittest
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 'extra_args': [], 247 'extra_args': [],
248 'execution_timeout_secs': 30, 248 'execution_timeout_secs': 30,
249 'grace_period_secs': 30, 249 'grace_period_secs': 30,
250 'idempotent': True, 250 'idempotent': True,
251 'inputs_ref': { 251 'inputs_ref': {
252 'isolated': None, 252 'isolated': None,
253 'isolatedserver': 'https://isolateserver.appspot.com', 253 'isolatedserver': 'https://isolateserver.appspot.com',
254 'namespace': 'default-gzip', 254 'namespace': 'default-gzip',
255 }, 255 },
256 'io_timeout_secs': None, 256 'io_timeout_secs': None,
257 'outputs': [],
257 } 258 }
258 expected_request = { 259 expected_request = {
259 'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY, 260 'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY,
260 'name': u'Request name', 261 'name': u'Request name',
261 'parent_task_id': unicode(parent_id), 262 'parent_task_id': unicode(parent_id),
262 'priority': 49, 263 'priority': 49,
263 'properties': expected_properties, 264 'properties': expected_properties,
264 # Intentionally hard code the hash value since it has to be deterministic. 265 # Intentionally hard code the hash value since it has to be deterministic.
265 # Other unit tests should use the calculated value. 266 # Other unit tests should use the calculated value.
266 'properties_hash': '411f20b8cda819b5fe47bcf26f5566c37afce0ed', 267 'properties_hash': 'ca5c7327e43431514472b081b0bbeb62dc1bd8e9',
267 'pubsub_topic': None, 268 'pubsub_topic': None,
268 'pubsub_userdata': None, 269 'pubsub_userdata': None,
269 'service_account': u'none', 270 'service_account': u'none',
270 'tags': [ 271 'tags': [
271 u'OS:Windows-3.1.1', 272 u'OS:Windows-3.1.1',
272 u'hostname:localhost', 273 u'hostname:localhost',
273 u'pool:default', 274 u'pool:default',
274 u'priority:49', 275 u'priority:49',
275 u'service_account:none', 276 u'service_account:none',
276 u'tag:1', 277 u'tag:1',
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 'extra_args': [], 322 'extra_args': [],
322 'execution_timeout_secs': 30, 323 'execution_timeout_secs': 30,
323 'grace_period_secs': 30, 324 'grace_period_secs': 30,
324 'idempotent': True, 325 'idempotent': True,
325 'inputs_ref': { 326 'inputs_ref': {
326 'isolated': None, 327 'isolated': None,
327 'isolatedserver': 'https://isolateserver.appspot.com', 328 'isolatedserver': 'https://isolateserver.appspot.com',
328 'namespace': 'default-gzip', 329 'namespace': 'default-gzip',
329 }, 330 },
330 'io_timeout_secs': None, 331 'io_timeout_secs': None,
332 'outputs': [],
331 } 333 }
332 expected_request = { 334 expected_request = {
333 'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY, 335 'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY,
334 'name': u'Request name', 336 'name': u'Request name',
335 'parent_task_id': unicode(parent_id), 337 'parent_task_id': unicode(parent_id),
336 'priority': 49, 338 'priority': 49,
337 'properties': expected_properties, 339 'properties': expected_properties,
338 # Intentionally hard code the hash value since it has to be deterministic. 340 # Intentionally hard code the hash value since it has to be deterministic.
339 # Other unit tests should use the calculated value. 341 # Other unit tests should use the calculated value.
340 'properties_hash': '411f20b8cda819b5fe47bcf26f5566c37afce0ed', 342 'properties_hash': 'ca5c7327e43431514472b081b0bbeb62dc1bd8e9',
341 'pubsub_topic': None, 343 'pubsub_topic': None,
342 'pubsub_userdata': None, 344 'pubsub_userdata': None,
343 'service_account': u'none', 345 'service_account': u'none',
344 'tags': [ 346 'tags': [
345 u'OS:Windows-3.1.1', 347 u'OS:Windows-3.1.1',
346 u'hostname:localhost', 348 u'hostname:localhost',
347 u'pool:default', 349 u'pool:default',
348 u'priority:49', 350 u'priority:49',
349 u'service_account:none', 351 u'service_account:none',
350 u'tag:1', 352 u'tag:1',
(...skipping 21 matching lines...) Expand all
372 _gen_request(parent_task_id='1d69b9f088008810') 374 _gen_request(parent_task_id='1d69b9f088008810')
373 375
374 def test_init_new_request_idempotent(self): 376 def test_init_new_request_idempotent(self):
375 request = mkreq(_gen_request(properties=dict(idempotent=True))) 377 request = mkreq(_gen_request(properties=dict(idempotent=True)))
376 as_dict = request.to_dict() 378 as_dict = request.to_dict()
377 self.assertEqual(True, as_dict['properties']['idempotent']) 379 self.assertEqual(True, as_dict['properties']['idempotent'])
378 # Intentionally hard code the hash value since it has to be deterministic. 380 # Intentionally hard code the hash value since it has to be deterministic.
379 # Other unit tests should use the calculated value. 381 # Other unit tests should use the calculated value.
380 # Ensure the algorithm is deterministic. 382 # Ensure the algorithm is deterministic.
381 self.assertEqual( 383 self.assertEqual(
382 '411f20b8cda819b5fe47bcf26f5566c37afce0ed', as_dict['properties_hash']) 384 'ca5c7327e43431514472b081b0bbeb62dc1bd8e9', as_dict['properties_hash'])
383 385
384 def test_init_new_request_bot_service_account(self): 386 def test_init_new_request_bot_service_account(self):
385 request = mkreq(_gen_request(service_account_token='bot')) 387 request = mkreq(_gen_request(service_account_token='bot'))
386 as_dict = request.to_dict() 388 as_dict = request.to_dict()
387 self.assertEqual('bot', as_dict['service_account']) 389 self.assertEqual('bot', as_dict['service_account'])
388 self.assertIn(u'service_account:bot', as_dict['tags']) 390 self.assertIn(u'service_account:bot', as_dict['tags'])
389 391
390 def test_duped(self): 392 def test_duped(self):
391 # Two TestRequest with the same properties. 393 # Two TestRequest with the same properties.
392 request_1 = mkreq(_gen_request(properties=dict(idempotent=True))) 394 request_1 = mkreq(_gen_request(properties=dict(idempotent=True)))
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 'execution_timeout_secs': 30, 580 'execution_timeout_secs': 30,
579 'extra_args': [], 581 'extra_args': [],
580 'grace_period_secs': 30, 582 'grace_period_secs': 30,
581 'idempotent': False, 583 'idempotent': False,
582 'inputs_ref': { 584 'inputs_ref': {
583 'isolated': None, 585 'isolated': None,
584 'isolatedserver': 'https://isolateserver.appspot.com', 586 'isolatedserver': 'https://isolateserver.appspot.com',
585 'namespace': 'default-gzip', 587 'namespace': 'default-gzip',
586 }, 588 },
587 'io_timeout_secs': None, 589 'io_timeout_secs': None,
590 'outputs': [],
588 } 591 }
589 # Differences from new_request() are: 592 # Differences from new_request() are:
590 # - parent_task_id was reset to None. 593 # - parent_task_id was reset to None.
591 # - tag 'user:' was replaced 594 # - tag 'user:' was replaced
592 # - user was replaced. 595 # - user was replaced.
593 expected_request = { 596 expected_request = {
594 'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY, 597 'authenticated': auth_testing.DEFAULT_MOCKED_IDENTITY,
595 'name': u'Request name (Retry #1)', 598 'name': u'Request name (Retry #1)',
596 'parent_task_id': None, 599 'parent_task_id': None,
597 'priority': 49, 600 'priority': 49,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 ndb.Key(task_request.TaskRequest, 0x7f14acec2fcfffff), 657 ndb.Key(task_request.TaskRequest, 0x7f14acec2fcfffff),
655 task_request.request_id_to_key(0xeb5313d0300000)) 658 task_request.request_id_to_key(0xeb5313d0300000))
656 659
657 660
658 if __name__ == '__main__': 661 if __name__ == '__main__':
659 if '-v' in sys.argv: 662 if '-v' in sys.argv:
660 unittest.TestCase.maxDiff = None 663 unittest.TestCase.maxDiff = None
661 logging.basicConfig( 664 logging.basicConfig(
662 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 665 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
663 unittest.main() 666 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698