| OLD | NEW |
| 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 under the Apache License, Version 2.0 | 4 # Use of this source code is governed under the Apache License, Version 2.0 |
| 5 # that can be found in the LICENSE file. | 5 # that can be found in the LICENSE file. |
| 6 | 6 |
| 7 import base64 | 7 import base64 |
| 8 import datetime | 8 import datetime |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 }, | 309 }, |
| 310 u'env': {}, | 310 u'env': {}, |
| 311 u'extra_args': [], | 311 u'extra_args': [], |
| 312 u'grace_period': 30, | 312 u'grace_period': 30, |
| 313 u'hard_timeout': 3600, | 313 u'hard_timeout': 3600, |
| 314 u'host': u'http://localhost:8080', | 314 u'host': u'http://localhost:8080', |
| 315 u'isolated': None, | 315 u'isolated': None, |
| 316 u'secret_bytes': None, | 316 u'secret_bytes': None, |
| 317 u'io_timeout': 1200, | 317 u'io_timeout': 1200, |
| 318 u'outputs': [u'foo', u'path/to/foobar'], | 318 u'outputs': [u'foo', u'path/to/foobar'], |
| 319 u'service_account': u'none', | 319 u'service_accounts': { |
| 320 u'system': {u'service_account': u'none'}, |
| 321 u'task': {u'service_account': u'none'}, |
| 322 }, |
| 320 u'task_id': task_id, | 323 u'task_id': task_id, |
| 321 }, | 324 }, |
| 322 } | 325 } |
| 323 self.assertEqual(expected, response) | 326 self.assertEqual(expected, response) |
| 324 response = self.client_get_results(task_id) | 327 response = self.client_get_results(task_id) |
| 325 expected = { | 328 expected = { |
| 326 u'bot_dimensions': [ | 329 u'bot_dimensions': [ |
| 327 {u'key': u'id', u'value': [u'bot1']}, | 330 {u'key': u'id', u'value': [u'bot1']}, |
| 328 {u'key': u'os', u'value': [u'Amiga']}, | 331 {u'key': u'os', u'value': [u'Amiga']}, |
| 329 {u'key': u'pool', u'value': [u'default']}, | 332 {u'key': u'pool', u'value': [u'default']}, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 }, | 381 }, |
| 379 u'env': {}, | 382 u'env': {}, |
| 380 u'extra_args': [], | 383 u'extra_args': [], |
| 381 u'grace_period': 30, | 384 u'grace_period': 30, |
| 382 u'hard_timeout': 3600, | 385 u'hard_timeout': 3600, |
| 383 u'host': u'http://localhost:8080', | 386 u'host': u'http://localhost:8080', |
| 384 u'isolated': None, | 387 u'isolated': None, |
| 385 u'secret_bytes': None, | 388 u'secret_bytes': None, |
| 386 u'io_timeout': 1200, | 389 u'io_timeout': 1200, |
| 387 u'outputs': [u'foo', u'path/to/foobar'], | 390 u'outputs': [u'foo', u'path/to/foobar'], |
| 388 u'service_account': u'bot', | 391 u'service_accounts': { |
| 392 u'system': {u'service_account': u'none'}, |
| 393 u'task': {u'service_account': u'bot'}, |
| 394 }, |
| 389 u'task_id': task_id, | 395 u'task_id': task_id, |
| 390 }, | 396 }, |
| 391 } | 397 } |
| 392 self.assertEqual(expected, response) | 398 self.assertEqual(expected, response) |
| 393 | 399 |
| 394 def test_poll_task_with_caches(self): | 400 def test_poll_task_with_caches(self): |
| 395 params = self.do_handshake() | 401 params = self.do_handshake() |
| 396 | 402 |
| 397 _, task_id = self.client_create_task_raw({ | 403 _, task_id = self.client_create_task_raw({ |
| 398 'caches': [{ | 404 'caches': [{ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 }, | 438 }, |
| 433 u'env': {}, | 439 u'env': {}, |
| 434 u'extra_args': [], | 440 u'extra_args': [], |
| 435 u'grace_period': 30, | 441 u'grace_period': 30, |
| 436 u'hard_timeout': 3600, | 442 u'hard_timeout': 3600, |
| 437 u'host': u'http://localhost:8080', | 443 u'host': u'http://localhost:8080', |
| 438 u'isolated': None, | 444 u'isolated': None, |
| 439 u'io_timeout': 1200, | 445 u'io_timeout': 1200, |
| 440 u'outputs': [u'foo', u'path/to/foobar'], | 446 u'outputs': [u'foo', u'path/to/foobar'], |
| 441 u'secret_bytes': None, | 447 u'secret_bytes': None, |
| 442 u'service_account': u'none', | 448 u'service_accounts': { |
| 449 u'system': {u'service_account': u'none'}, |
| 450 u'task': {u'service_account': u'none'}, |
| 451 }, |
| 443 u'task_id': task_id, | 452 u'task_id': task_id, |
| 444 }, | 453 }, |
| 445 } | 454 } |
| 446 self.assertEqual(expected, response) | 455 self.assertEqual(expected, response) |
| 447 | 456 |
| 448 def test_poll_conflicting_dimensions(self): | 457 def test_poll_conflicting_dimensions(self): |
| 449 params = self.do_handshake() | 458 params = self.do_handshake() |
| 450 self.assertEqual(params['dimensions']['pool'], ['default']) | 459 self.assertEqual(params['dimensions']['pool'], ['default']) |
| 451 | 460 |
| 452 self.mock_bot_group_config( | 461 self.mock_bot_group_config( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 u'grace_period': 30, | 536 u'grace_period': 30, |
| 528 u'host': u'http://localhost:8080', | 537 u'host': u'http://localhost:8080', |
| 529 u'isolated': { | 538 u'isolated': { |
| 530 u'input': u'0123456789012345678901234567890123456789', | 539 u'input': u'0123456789012345678901234567890123456789', |
| 531 u'server': u'http://localhost:1', | 540 u'server': u'http://localhost:1', |
| 532 u'namespace': u'default-gzip', | 541 u'namespace': u'default-gzip', |
| 533 }, | 542 }, |
| 534 u'secret_bytes': None, | 543 u'secret_bytes': None, |
| 535 u'io_timeout': 1200, | 544 u'io_timeout': 1200, |
| 536 u'outputs': [u'foo', u'path/to/foobar'], | 545 u'outputs': [u'foo', u'path/to/foobar'], |
| 537 u'service_account': u'none', | 546 u'service_accounts': { |
| 547 u'system': {u'service_account': u'none'}, |
| 548 u'task': {u'service_account': u'none'}, |
| 549 }, |
| 538 u'task_id': task_id, | 550 u'task_id': task_id, |
| 539 }, | 551 }, |
| 540 } | 552 } |
| 541 self.assertEqual(expected, response) | 553 self.assertEqual(expected, response) |
| 542 | 554 |
| 543 # Complete the isolated task. | 555 # Complete the isolated task. |
| 544 params = { | 556 params = { |
| 545 'cost_usd': 0.1, | 557 'cost_usd': 0.1, |
| 546 'duration': 3., | 558 'duration': 3., |
| 547 'bot_overhead': 0.1, | 559 'bot_overhead': 0.1, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 u'grace_period': 30, | 698 u'grace_period': 30, |
| 687 u'host': u'http://localhost:8080', | 699 u'host': u'http://localhost:8080', |
| 688 u'isolated': { | 700 u'isolated': { |
| 689 u'input': u'0123456789012345678901234567890123456789', | 701 u'input': u'0123456789012345678901234567890123456789', |
| 690 u'server': u'http://localhost:1', | 702 u'server': u'http://localhost:1', |
| 691 u'namespace': u'default-gzip', | 703 u'namespace': u'default-gzip', |
| 692 }, | 704 }, |
| 693 u'secret_bytes': None, | 705 u'secret_bytes': None, |
| 694 u'io_timeout': 1200, | 706 u'io_timeout': 1200, |
| 695 u'outputs': [u'foo', u'path/to/foobar'], | 707 u'outputs': [u'foo', u'path/to/foobar'], |
| 696 u'service_account': u'none', | 708 u'service_accounts': { |
| 709 u'system': {u'service_account': u'none'}, |
| 710 u'task': {u'service_account': u'none'}, |
| 711 }, |
| 697 u'task_id': task_id, | 712 u'task_id': task_id, |
| 698 }, | 713 }, |
| 699 } | 714 } |
| 700 self.assertEqual(expected, response) | 715 self.assertEqual(expected, response) |
| 701 | 716 |
| 702 def test_bot_ereporter2_error(self): | 717 def test_bot_ereporter2_error(self): |
| 703 # ereporter2's //client/utils/on_error.py traps unhandled exceptions | 718 # ereporter2's //client/utils/on_error.py traps unhandled exceptions |
| 704 # automatically. | 719 # automatically. |
| 705 self.mock(random, 'getrandbits', lambda _: 0x88) | 720 self.mock(random, 'getrandbits', lambda _: 0x88) |
| 706 errors = [] | 721 errors = [] |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 self.assertEqual({u'service_account': u'none'}, response) | 1341 self.assertEqual({u'service_account': u'none'}, response) |
| 1327 | 1342 |
| 1328 | 1343 |
| 1329 if __name__ == '__main__': | 1344 if __name__ == '__main__': |
| 1330 if '-v' in sys.argv: | 1345 if '-v' in sys.argv: |
| 1331 unittest.TestCase.maxDiff = None | 1346 unittest.TestCase.maxDiff = None |
| 1332 logging.basicConfig( | 1347 logging.basicConfig( |
| 1333 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, | 1348 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, |
| 1334 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') | 1349 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') |
| 1335 unittest.main() | 1350 unittest.main() |
| OLD | NEW |