| OLD | NEW |
| 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 by the Apache v2.0 license that can be | 3 # Use of this source code is governed by the Apache v2.0 license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import datetime | 6 import datetime |
| 7 import hashlib | 7 import hashlib |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 | 302 |
| 303 class TestSwarmingTrigger(NetTestCase): | 303 class TestSwarmingTrigger(NetTestCase): |
| 304 def test_trigger_task_shards_2_shards(self): | 304 def test_trigger_task_shards_2_shards(self): |
| 305 task_request = swarming.NewTaskRequest( | 305 task_request = swarming.NewTaskRequest( |
| 306 expiration_secs=60*60, | 306 expiration_secs=60*60, |
| 307 name=TEST_NAME, | 307 name=TEST_NAME, |
| 308 parent_task_id=None, | 308 parent_task_id=None, |
| 309 priority=101, | 309 priority=101, |
| 310 properties=swarming.TaskProperties( | 310 properties=swarming.TaskProperties( |
| 311 command=['a', 'b'], | 311 command=['a', 'b'], |
| 312 dimensions={'foo': 'bar', 'os': 'Mac'}, | 312 dimensions={'foo': 'bar', 'os': 'Mac'}, |
| 313 env={}, | 313 env={}, |
| 314 execution_timeout_secs=60, | 314 execution_timeout_secs=60, |
| 315 extra_args=[], | 315 extra_args=[], |
| 316 grace_period_secs=30, | 316 grace_period_secs=30, |
| 317 idempotent=False, | 317 idempotent=False, |
| 318 inputs_ref=None, | 318 inputs_ref=None, |
| 319 io_timeout_secs=60), | 319 io_timeout_secs=60), |
| 320 tags=['tag:a', 'tag:b'], | 320 tags=['tag:a', 'tag:b'], |
| 321 user='joe@localhost') | 321 user='joe@localhost') |
| 322 | 322 |
| 323 request_1 = swarming.task_request_to_raw_request(task_request) | 323 request_1 = swarming.task_request_to_raw_request(task_request) |
| 324 request_1['name'] = u'unit_tests:0:2' | 324 request_1['name'] = u'unit_tests:0:2' |
| 325 request_1['properties']['env'] = [ | 325 request_1['properties']['env'] = [ |
| 326 {'key': 'GTEST_SHARD_INDEX', 'value': '0'}, | 326 {'key': 'GTEST_SHARD_INDEX', 'value': '0'}, |
| 327 {'key': 'GTEST_TOTAL_SHARDS', 'value': '2'}, | 327 {'key': 'GTEST_TOTAL_SHARDS', 'value': '2'}, |
| 328 ] | 328 ] |
| 329 result_1 = gen_request_response(request_1) | 329 result_1 = gen_request_response(request_1) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 } | 367 } |
| 368 self.assertEqual(expected, tasks) | 368 self.assertEqual(expected, tasks) |
| 369 | 369 |
| 370 def test_trigger_task_shards_priority_override(self): | 370 def test_trigger_task_shards_priority_override(self): |
| 371 task_request = swarming.NewTaskRequest( | 371 task_request = swarming.NewTaskRequest( |
| 372 expiration_secs=60*60, | 372 expiration_secs=60*60, |
| 373 name=TEST_NAME, | 373 name=TEST_NAME, |
| 374 parent_task_id='123', | 374 parent_task_id='123', |
| 375 priority=101, | 375 priority=101, |
| 376 properties=swarming.TaskProperties( | 376 properties=swarming.TaskProperties( |
| 377 command=['a', 'b'], | 377 command=['a', 'b'], |
| 378 dimensions={'foo': 'bar', 'os': 'Mac'}, | 378 dimensions={'foo': 'bar', 'os': 'Mac'}, |
| 379 env={}, | 379 env={}, |
| 380 execution_timeout_secs=60, | 380 execution_timeout_secs=60, |
| 381 extra_args=[], | 381 extra_args=[], |
| 382 grace_period_secs=30, | 382 grace_period_secs=30, |
| 383 idempotent=False, | 383 idempotent=False, |
| 384 inputs_ref=None, | 384 inputs_ref=None, |
| 385 io_timeout_secs=60), | 385 io_timeout_secs=60), |
| 386 tags=['tag:a', 'tag:b'], | 386 tags=['tag:a', 'tag:b'], |
| 387 user='joe@localhost') | 387 user='joe@localhost') |
| 388 | 388 |
| 389 request = swarming.task_request_to_raw_request(task_request) | 389 request = swarming.task_request_to_raw_request(task_request) |
| 390 self.assertEqual('123', request['parent_task_id']) | 390 self.assertEqual('123', request['parent_task_id']) |
| 391 | 391 |
| 392 result = gen_request_response(request) | 392 result = gen_request_response(request) |
| 393 result['request']['priority'] = 200 | 393 result['request']['priority'] = 200 |
| 394 self.expected_requests( | 394 self.expected_requests( |
| 395 [ | 395 [ |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 | 1384 |
| 1385 if __name__ == '__main__': | 1385 if __name__ == '__main__': |
| 1386 fix_encoding.fix_encoding() | 1386 fix_encoding.fix_encoding() |
| 1387 logging.basicConfig( | 1387 logging.basicConfig( |
| 1388 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) | 1388 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) |
| 1389 if '-v' in sys.argv: | 1389 if '-v' in sys.argv: |
| 1390 unittest.TestCase.maxDiff = None | 1390 unittest.TestCase.maxDiff = None |
| 1391 for e in ('ISOLATE_SERVER', 'SWARMING_TASK_ID', 'SWARMING_SERVER'): | 1391 for e in ('ISOLATE_SERVER', 'SWARMING_TASK_ID', 'SWARMING_SERVER'): |
| 1392 os.environ.pop(e, None) | 1392 os.environ.pop(e, None) |
| 1393 unittest.main() | 1393 unittest.main() |
| OLD | NEW |