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

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

Issue 2636993002: swarming: Fix named cache support. (Closed)
Patch Set: Fix swarming_test.py Created 3 years, 11 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 | « 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return dispatcher.execute(swarming.OptionParserSwarming(), args) 83 return dispatcher.execute(swarming.OptionParserSwarming(), args)
84 84
85 85
86 def gen_request_data(properties=None, **kwargs): 86 def gen_request_data(properties=None, **kwargs):
87 out = { 87 out = {
88 'expiration_secs': 3600, 88 'expiration_secs': 3600,
89 'name': 'unit_tests', 89 'name': 'unit_tests',
90 'parent_task_id': '', 90 'parent_task_id': '',
91 'priority': 101, 91 'priority': 101,
92 'properties': { 92 'properties': {
93 'caches': [],
93 'cipd_input': None, 94 'cipd_input': None,
94 'command': None, 95 'command': None,
95 'dimensions': [ 96 'dimensions': [
96 {'key': 'foo', 'value': 'bar'}, 97 {'key': 'foo', 'value': 'bar'},
97 {'key': 'os', 'value': 'Mac'}, 98 {'key': 'os', 'value': 'Mac'},
98 ], 99 ],
99 'env': [], 100 'env': [],
100 'execution_timeout_secs': 60, 101 'execution_timeout_secs': 60,
101 'extra_args': ['--some-arg', '123'], 102 'extra_args': ['--some-arg', '123'],
102 'grace_period_secs': 30, 103 'grace_period_secs': 30,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 306
306 307
307 class TestSwarmingTrigger(NetTestCase): 308 class TestSwarmingTrigger(NetTestCase):
308 def test_trigger_task_shards_2_shards(self): 309 def test_trigger_task_shards_2_shards(self):
309 task_request = swarming.NewTaskRequest( 310 task_request = swarming.NewTaskRequest(
310 expiration_secs=60*60, 311 expiration_secs=60*60,
311 name=TEST_NAME, 312 name=TEST_NAME,
312 parent_task_id=None, 313 parent_task_id=None,
313 priority=101, 314 priority=101,
314 properties=swarming.TaskProperties( 315 properties=swarming.TaskProperties(
316 caches=[],
315 cipd_input=None, 317 cipd_input=None,
316 command=['a', 'b'], 318 command=['a', 'b'],
317 dimensions={'foo': 'bar', 'os': 'Mac'}, 319 dimensions={'foo': 'bar', 'os': 'Mac'},
318 env={}, 320 env={},
319 execution_timeout_secs=60, 321 execution_timeout_secs=60,
320 extra_args=[], 322 extra_args=[],
321 grace_period_secs=30, 323 grace_period_secs=30,
322 idempotent=False, 324 idempotent=False,
323 inputs_ref=None, 325 inputs_ref=None,
324 io_timeout_secs=60, 326 io_timeout_secs=60,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 377 }
376 self.assertEqual(expected, tasks) 378 self.assertEqual(expected, tasks)
377 379
378 def test_trigger_task_shards_priority_override(self): 380 def test_trigger_task_shards_priority_override(self):
379 task_request = swarming.NewTaskRequest( 381 task_request = swarming.NewTaskRequest(
380 expiration_secs=60*60, 382 expiration_secs=60*60,
381 name=TEST_NAME, 383 name=TEST_NAME,
382 parent_task_id='123', 384 parent_task_id='123',
383 priority=101, 385 priority=101,
384 properties=swarming.TaskProperties( 386 properties=swarming.TaskProperties(
387 caches=[],
385 cipd_input=None, 388 cipd_input=None,
386 command=['a', 'b'], 389 command=['a', 'b'],
387 dimensions={'foo': 'bar', 'os': 'Mac'}, 390 dimensions={'foo': 'bar', 'os': 'Mac'},
388 env={}, 391 env={},
389 execution_timeout_secs=60, 392 execution_timeout_secs=60,
390 extra_args=[], 393 extra_args=[],
391 grace_period_secs=30, 394 grace_period_secs=30,
392 idempotent=False, 395 idempotent=False,
393 inputs_ref=None, 396 inputs_ref=None,
394 io_timeout_secs=60, 397 io_timeout_secs=60,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 self.assertEqual(expected, tasks) 433 self.assertEqual(expected, tasks)
431 self._check_output('', 'Priority was reset to 200\n') 434 self._check_output('', 'Priority was reset to 200\n')
432 435
433 def test_trigger_cipd_package(self): 436 def test_trigger_cipd_package(self):
434 task_request = swarming.NewTaskRequest( 437 task_request = swarming.NewTaskRequest(
435 expiration_secs=60*60, 438 expiration_secs=60*60,
436 name=TEST_NAME, 439 name=TEST_NAME,
437 parent_task_id='123', 440 parent_task_id='123',
438 priority=101, 441 priority=101,
439 properties=swarming.TaskProperties( 442 properties=swarming.TaskProperties(
443 caches=[],
440 cipd_input=swarming.CipdInput( 444 cipd_input=swarming.CipdInput(
441 client_package=None, 445 client_package=None,
442 packages=[ 446 packages=[
443 swarming.CipdPackage( 447 swarming.CipdPackage(
444 package_name='mypackage', 448 package_name='mypackage',
445 path='path/to/package', 449 path='path/to/package',
446 version='abc123')], 450 version='abc123')],
447 server=None), 451 server=None),
448 command=['a', 'b'], 452 command=['a', 'b'],
449 dimensions={'foo': 'bar', 'os': 'Mac'}, 453 dimensions={'foo': 'bar', 'os': 'Mac'},
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 self.assertEqual(0, ret) 840 self.assertEqual(0, ret)
837 841
838 def test_run_raw_cmd(self): 842 def test_run_raw_cmd(self):
839 # Minimalist use. 843 # Minimalist use.
840 request = { 844 request = {
841 'expiration_secs': 21600, 845 'expiration_secs': 21600,
842 'name': u'None/foo=bar', 846 'name': u'None/foo=bar',
843 'parent_task_id': '', 847 'parent_task_id': '',
844 'priority': 100, 848 'priority': 100,
845 'properties': { 849 'properties': {
850 'caches': [],
846 'cipd_input': None, 851 'cipd_input': None,
847 'command': ['python', '-c', 'print(\'hi\')'], 852 'command': ['python', '-c', 'print(\'hi\')'],
848 'dimensions': [ 853 'dimensions': [
849 {'key': 'foo', 'value': 'bar'}, 854 {'key': 'foo', 'value': 'bar'},
850 ], 855 ],
851 'env': [], 856 'env': [],
852 'execution_timeout_secs': 3600, 857 'execution_timeout_secs': 3600,
853 'extra_args': None, 858 'extra_args': None,
854 'grace_period_secs': 30, 859 'grace_period_secs': 30,
855 'idempotent': False, 860 'idempotent': False,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 '') 896 '')
892 897
893 def test_run_raw_cmd_with_service_account(self): 898 def test_run_raw_cmd_with_service_account(self):
894 # Minimalist use. 899 # Minimalist use.
895 request = { 900 request = {
896 'expiration_secs': 21600, 901 'expiration_secs': 21600,
897 'name': u'None/foo=bar', 902 'name': u'None/foo=bar',
898 'parent_task_id': '', 903 'parent_task_id': '',
899 'priority': 100, 904 'priority': 100,
900 'properties': { 905 'properties': {
906 'caches': [],
901 'cipd_input': None, 907 'cipd_input': None,
902 'command': ['python', '-c', 'print(\'hi\')'], 908 'command': ['python', '-c', 'print(\'hi\')'],
903 'dimensions': [ 909 'dimensions': [
904 {'key': 'foo', 'value': 'bar'}, 910 {'key': 'foo', 'value': 'bar'},
905 ], 911 ],
906 'env': [], 912 'env': [],
907 'execution_timeout_secs': 3600, 913 'execution_timeout_secs': 3600,
908 'extra_args': None, 914 'extra_args': None,
909 'grace_period_secs': 30, 915 'grace_period_secs': 30,
910 'idempotent': False, 916 'idempotent': False,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 'task_id': '12300', 1083 'task_id': '12300',
1078 'view_url': 'https://localhost:1/user/task/12300', 1084 'view_url': 'https://localhost:1/user/task/12300',
1079 } 1085 }
1080 }, 1086 },
1081 'request': { 1087 'request': {
1082 'expiration_secs': 3600, 1088 'expiration_secs': 3600,
1083 'name': 'unit_tests', 1089 'name': 'unit_tests',
1084 'parent_task_id': '', 1090 'parent_task_id': '',
1085 'priority': 101, 1091 'priority': 101,
1086 'properties': { 1092 'properties': {
1093 'caches': [],
1087 'cipd_input': None, 1094 'cipd_input': None,
1088 'command': None, 1095 'command': None,
1089 'dimensions': [ 1096 'dimensions': [
1090 {'key': 'foo', 'value': 'bar'}, 1097 {'key': 'foo', 'value': 'bar'},
1091 {'key': 'os', 'value': 'Mac'}, 1098 {'key': 'os', 'value': 'Mac'},
1092 ], 1099 ],
1093 'env': [], 1100 'env': [],
1094 'execution_timeout_secs': 60, 1101 'execution_timeout_secs': 60,
1095 'extra_args': ['--some-arg', '123'], 1102 'extra_args': ['--some-arg', '123'],
1096 'grace_period_secs': 30, 1103 'grace_period_secs': 30,
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 1604
1598 if __name__ == '__main__': 1605 if __name__ == '__main__':
1599 fix_encoding.fix_encoding() 1606 fix_encoding.fix_encoding()
1600 logging.basicConfig( 1607 logging.basicConfig(
1601 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) 1608 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL)
1602 if '-v' in sys.argv: 1609 if '-v' in sys.argv:
1603 unittest.TestCase.maxDiff = None 1610 unittest.TestCase.maxDiff = None
1604 for e in ('ISOLATE_SERVER', 'SWARMING_TASK_ID', 'SWARMING_SERVER'): 1611 for e in ('ISOLATE_SERVER', 'SWARMING_TASK_ID', 'SWARMING_SERVER'):
1605 os.environ.pop(e, None) 1612 os.environ.pop(e, None)
1606 unittest.main() 1613 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