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

Side by Side Diff: client/tests/swarming_test.py

Issue 2453873002: Add --output option to Swarming client and pass it through to the bot (Closed)
Patch Set: Extra help text for examples 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
« no previous file with comments | « client/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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The LUCI Authors. All rights reserved. 2 # Copyright 2013 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 json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 {'key': 'foo', 'value': 'bar'}, 96 {'key': 'foo', 'value': 'bar'},
97 {'key': 'os', 'value': 'Mac'}, 97 {'key': 'os', 'value': 'Mac'},
98 ], 98 ],
99 'env': [], 99 'env': [],
100 'execution_timeout_secs': 60, 100 'execution_timeout_secs': 60,
101 'extra_args': ['--some-arg', '123'], 101 'extra_args': ['--some-arg', '123'],
102 'grace_period_secs': 30, 102 'grace_period_secs': 30,
103 'idempotent': False, 103 'idempotent': False,
104 'inputs_ref': None, 104 'inputs_ref': None,
105 'io_timeout_secs': 60, 105 'io_timeout_secs': 60,
106 'outputs': [],
106 }, 107 },
107 'tags': ['tag:a', 'tag:b'], 108 'tags': ['tag:a', 'tag:b'],
108 'user': 'joe@localhost', 109 'user': 'joe@localhost',
109 } 110 }
110 out.update(kwargs) 111 out.update(kwargs)
111 out['properties'].update(properties or {}) 112 out['properties'].update(properties or {})
112 return out 113 return out
113 114
114 115
115 def gen_request_response(request, **kwargs): 116 def gen_request_response(request, **kwargs):
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 properties=swarming.TaskProperties( 312 properties=swarming.TaskProperties(
312 cipd_input=None, 313 cipd_input=None,
313 command=['a', 'b'], 314 command=['a', 'b'],
314 dimensions={'foo': 'bar', 'os': 'Mac'}, 315 dimensions={'foo': 'bar', 'os': 'Mac'},
315 env={}, 316 env={},
316 execution_timeout_secs=60, 317 execution_timeout_secs=60,
317 extra_args=[], 318 extra_args=[],
318 grace_period_secs=30, 319 grace_period_secs=30,
319 idempotent=False, 320 idempotent=False,
320 inputs_ref=None, 321 inputs_ref=None,
321 io_timeout_secs=60), 322 io_timeout_secs=60,
323 outputs=[]),
322 service_account_token=None, 324 service_account_token=None,
323 tags=['tag:a', 'tag:b'], 325 tags=['tag:a', 'tag:b'],
324 user='joe@localhost') 326 user='joe@localhost')
325 327
326 request_1 = swarming.task_request_to_raw_request(task_request, False) 328 request_1 = swarming.task_request_to_raw_request(task_request, False)
327 request_1['name'] = u'unit_tests:0:2' 329 request_1['name'] = u'unit_tests:0:2'
328 request_1['properties']['env'] = [ 330 request_1['properties']['env'] = [
329 {'key': 'GTEST_SHARD_INDEX', 'value': '0'}, 331 {'key': 'GTEST_SHARD_INDEX', 'value': '0'},
330 {'key': 'GTEST_TOTAL_SHARDS', 'value': '2'}, 332 {'key': 'GTEST_TOTAL_SHARDS', 'value': '2'},
331 ] 333 ]
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 properties=swarming.TaskProperties( 381 properties=swarming.TaskProperties(
380 cipd_input=None, 382 cipd_input=None,
381 command=['a', 'b'], 383 command=['a', 'b'],
382 dimensions={'foo': 'bar', 'os': 'Mac'}, 384 dimensions={'foo': 'bar', 'os': 'Mac'},
383 env={}, 385 env={},
384 execution_timeout_secs=60, 386 execution_timeout_secs=60,
385 extra_args=[], 387 extra_args=[],
386 grace_period_secs=30, 388 grace_period_secs=30,
387 idempotent=False, 389 idempotent=False,
388 inputs_ref=None, 390 inputs_ref=None,
389 io_timeout_secs=60), 391 io_timeout_secs=60,
392 outputs=[]),
390 service_account_token=None, 393 service_account_token=None,
391 tags=['tag:a', 'tag:b'], 394 tags=['tag:a', 'tag:b'],
392 user='joe@localhost') 395 user='joe@localhost')
393 396
394 request = swarming.task_request_to_raw_request(task_request, False) 397 request = swarming.task_request_to_raw_request(task_request, False)
395 self.assertEqual('123', request['parent_task_id']) 398 self.assertEqual('123', request['parent_task_id'])
396 399
397 result = gen_request_response(request) 400 result = gen_request_response(request)
398 result['request']['priority'] = 200 401 result['request']['priority'] = 200
399 self.expected_requests( 402 self.expected_requests(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 version='abc123')], 442 version='abc123')],
440 server=None), 443 server=None),
441 command=['a', 'b'], 444 command=['a', 'b'],
442 dimensions={'foo': 'bar', 'os': 'Mac'}, 445 dimensions={'foo': 'bar', 'os': 'Mac'},
443 env={}, 446 env={},
444 execution_timeout_secs=60, 447 execution_timeout_secs=60,
445 extra_args=[], 448 extra_args=[],
446 grace_period_secs=30, 449 grace_period_secs=30,
447 idempotent=False, 450 idempotent=False,
448 inputs_ref=None, 451 inputs_ref=None,
449 io_timeout_secs=60), 452 io_timeout_secs=60,
453 outputs=[]),
450 service_account_token=None, 454 service_account_token=None,
451 tags=['tag:a', 'tag:b'], 455 tags=['tag:a', 'tag:b'],
452 user='joe@localhost') 456 user='joe@localhost')
453 457
454 request = swarming.task_request_to_raw_request(task_request, False) 458 request = swarming.task_request_to_raw_request(task_request, False)
455 expected = { 459 expected = {
456 'client_package': None, 460 'client_package': None,
457 'packages': [{ 461 'packages': [{
458 'package_name': 'mypackage', 462 'package_name': 'mypackage',
459 'path': 'path/to/package', 463 'path': 'path/to/package',
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 'dimensions': [ 843 'dimensions': [
840 {'key': 'foo', 'value': 'bar'}, 844 {'key': 'foo', 'value': 'bar'},
841 ], 845 ],
842 'env': [], 846 'env': [],
843 'execution_timeout_secs': 3600, 847 'execution_timeout_secs': 3600,
844 'extra_args': None, 848 'extra_args': None,
845 'grace_period_secs': 30, 849 'grace_period_secs': 30,
846 'idempotent': False, 850 'idempotent': False,
847 'inputs_ref': None, 851 'inputs_ref': None,
848 'io_timeout_secs': 1200, 852 'io_timeout_secs': 1200,
853 'outputs': [],
849 }, 854 },
850 'tags': [], 855 'tags': [],
851 'user': None, 856 'user': None,
852 } 857 }
853 result = gen_request_response(request) 858 result = gen_request_response(request)
854 self.expected_requests( 859 self.expected_requests(
855 [ 860 [
856 ( 861 (
857 'https://localhost:1/api/swarming/v1/tasks/new', 862 'https://localhost:1/api/swarming/v1/tasks/new',
858 {'data': request}, 863 {'data': request},
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 'dimensions': [ 897 'dimensions': [
893 {'key': 'foo', 'value': 'bar'}, 898 {'key': 'foo', 'value': 'bar'},
894 ], 899 ],
895 'env': [], 900 'env': [],
896 'execution_timeout_secs': 3600, 901 'execution_timeout_secs': 3600,
897 'extra_args': None, 902 'extra_args': None,
898 'grace_period_secs': 30, 903 'grace_period_secs': 30,
899 'idempotent': False, 904 'idempotent': False,
900 'inputs_ref': None, 905 'inputs_ref': None,
901 'io_timeout_secs': 1200, 906 'io_timeout_secs': 1200,
907 'outputs': [],
902 }, 908 },
903 'service_account_token': 'bot', 909 'service_account_token': 'bot',
904 'tags': [], 910 'tags': [],
905 'user': None, 911 'user': None,
906 } 912 }
907 result = gen_request_response(request) 913 result = gen_request_response(request)
908 self.expected_requests( 914 self.expected_requests(
909 [ 915 [
910 ( 916 (
911 'https://localhost:1/api/swarming/v1/tasks/new', 917 'https://localhost:1/api/swarming/v1/tasks/new',
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 'execution_timeout_secs': 60, 1085 'execution_timeout_secs': 60,
1080 'extra_args': ['--some-arg', '123'], 1086 'extra_args': ['--some-arg', '123'],
1081 'grace_period_secs': 30, 1087 'grace_period_secs': 30,
1082 'idempotent': True, 1088 'idempotent': True,
1083 'inputs_ref': { 1089 'inputs_ref': {
1084 'isolated': isolated_hash, 1090 'isolated': isolated_hash,
1085 'isolatedserver': 'https://localhost:2', 1091 'isolatedserver': 'https://localhost:2',
1086 'namespace': 'default-gzip', 1092 'namespace': 'default-gzip',
1087 }, 1093 },
1088 'io_timeout_secs': 60, 1094 'io_timeout_secs': 60,
1095 'outputs': [],
1089 }, 1096 },
1090 'tags': ['tag:a', 'tag:b'], 1097 'tags': ['tag:a', 'tag:b'],
1091 'user': 'joe@localhost', 1098 'user': 'joe@localhost',
1092 }, 1099 },
1093 }, 1100 },
1094 True, 1101 True,
1095 ), 1102 ),
1096 ] 1103 ]
1097 self.assertEqual(expected, write_json_calls) 1104 self.assertEqual(expected, write_json_calls)
1098 1105
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 1584
1578 if __name__ == '__main__': 1585 if __name__ == '__main__':
1579 fix_encoding.fix_encoding() 1586 fix_encoding.fix_encoding()
1580 logging.basicConfig( 1587 logging.basicConfig(
1581 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) 1588 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL)
1582 if '-v' in sys.argv: 1589 if '-v' in sys.argv:
1583 unittest.TestCase.maxDiff = None 1590 unittest.TestCase.maxDiff = None
1584 for e in ('ISOLATE_SERVER', 'SWARMING_TASK_ID', 'SWARMING_SERVER'): 1591 for e in ('ISOLATE_SERVER', 'SWARMING_TASK_ID', 'SWARMING_SERVER'):
1585 os.environ.pop(e, None) 1592 os.environ.pop(e, None)
1586 unittest.main() 1593 unittest.main()
OLDNEW
« no previous file with comments | « client/swarming.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698