| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 u'os': u'Amiga', | 287 u'os': u'Amiga', |
| 288 u'pool': u'default', | 288 u'pool': u'default', |
| 289 }, | 289 }, |
| 290 u'env': {}, | 290 u'env': {}, |
| 291 u'extra_args': [], | 291 u'extra_args': [], |
| 292 u'grace_period': 30, | 292 u'grace_period': 30, |
| 293 u'hard_timeout': 3600, | 293 u'hard_timeout': 3600, |
| 294 u'host': u'http://localhost:8080', | 294 u'host': u'http://localhost:8080', |
| 295 u'isolated': None, | 295 u'isolated': None, |
| 296 u'io_timeout': 1200, | 296 u'io_timeout': 1200, |
| 297 u'outputs': [u'foo', u'path/to/foobar'], |
| 297 u'service_account': u'none', | 298 u'service_account': u'none', |
| 298 u'task_id': task_id, | 299 u'task_id': task_id, |
| 299 }, | 300 }, |
| 300 } | 301 } |
| 301 self.assertEqual(expected, response) | 302 self.assertEqual(expected, response) |
| 302 response = self.client_get_results(task_id) | 303 response = self.client_get_results(task_id) |
| 303 expected = { | 304 expected = { |
| 304 u'bot_dimensions': [ | 305 u'bot_dimensions': [ |
| 305 {u'key': u'id', u'value': [u'bot1']}, | 306 {u'key': u'id', u'value': [u'bot1']}, |
| 306 {u'key': u'os', u'value': [u'Amiga']}, | 307 {u'key': u'os', u'value': [u'Amiga']}, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 u'os': u'Amiga', | 354 u'os': u'Amiga', |
| 354 u'pool': u'default', | 355 u'pool': u'default', |
| 355 }, | 356 }, |
| 356 u'env': {}, | 357 u'env': {}, |
| 357 u'extra_args': [], | 358 u'extra_args': [], |
| 358 u'grace_period': 30, | 359 u'grace_period': 30, |
| 359 u'hard_timeout': 3600, | 360 u'hard_timeout': 3600, |
| 360 u'host': u'http://localhost:8080', | 361 u'host': u'http://localhost:8080', |
| 361 u'isolated': None, | 362 u'isolated': None, |
| 362 u'io_timeout': 1200, | 363 u'io_timeout': 1200, |
| 364 u'outputs': [u'foo', u'path/to/foobar'], |
| 363 u'service_account': u'bot', | 365 u'service_account': u'bot', |
| 364 u'task_id': task_id, | 366 u'task_id': task_id, |
| 365 }, | 367 }, |
| 366 } | 368 } |
| 367 self.assertEqual(expected, response) | 369 self.assertEqual(expected, response) |
| 368 | 370 |
| 369 def test_poll_task_with_caches(self): | 371 def test_poll_task_with_caches(self): |
| 370 params = self.do_handshake() | 372 params = self.do_handshake() |
| 371 | 373 |
| 372 _, task_id = self.client_create_task_raw({ | 374 _, task_id = self.client_create_task_raw({ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 u'os': u'Amiga', | 407 u'os': u'Amiga', |
| 406 u'pool': u'default', | 408 u'pool': u'default', |
| 407 }, | 409 }, |
| 408 u'env': {}, | 410 u'env': {}, |
| 409 u'extra_args': [], | 411 u'extra_args': [], |
| 410 u'grace_period': 30, | 412 u'grace_period': 30, |
| 411 u'hard_timeout': 3600, | 413 u'hard_timeout': 3600, |
| 412 u'host': u'http://localhost:8080', | 414 u'host': u'http://localhost:8080', |
| 413 u'isolated': None, | 415 u'isolated': None, |
| 414 u'io_timeout': 1200, | 416 u'io_timeout': 1200, |
| 417 u'outputs': [u'foo', u'path/to/foobar'], |
| 415 u'service_account': u'none', | 418 u'service_account': u'none', |
| 416 u'task_id': task_id, | 419 u'task_id': task_id, |
| 417 }, | 420 }, |
| 418 } | 421 } |
| 419 self.assertEqual(expected, response) | 422 self.assertEqual(expected, response) |
| 420 | 423 |
| 421 def test_poll_confliciting_dimensions(self): | 424 def test_poll_confliciting_dimensions(self): |
| 422 params = self.do_handshake() | 425 params = self.do_handshake() |
| 423 self.assertEqual(params['dimensions']['pool'], ['default']) | 426 self.assertEqual(params['dimensions']['pool'], ['default']) |
| 424 | 427 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 u'extra_args': [], | 498 u'extra_args': [], |
| 496 u'hard_timeout': 3600, | 499 u'hard_timeout': 3600, |
| 497 u'grace_period': 30, | 500 u'grace_period': 30, |
| 498 u'host': u'http://localhost:8080', | 501 u'host': u'http://localhost:8080', |
| 499 u'isolated': { | 502 u'isolated': { |
| 500 u'input': u'0123456789012345678901234567890123456789', | 503 u'input': u'0123456789012345678901234567890123456789', |
| 501 u'server': u'http://localhost:1', | 504 u'server': u'http://localhost:1', |
| 502 u'namespace': u'default-gzip', | 505 u'namespace': u'default-gzip', |
| 503 }, | 506 }, |
| 504 u'io_timeout': 1200, | 507 u'io_timeout': 1200, |
| 508 u'outputs': [u'foo', u'path/to/foobar'], |
| 505 u'service_account': u'none', | 509 u'service_account': u'none', |
| 506 u'task_id': task_id, | 510 u'task_id': task_id, |
| 507 }, | 511 }, |
| 508 } | 512 } |
| 509 self.assertEqual(expected, response) | 513 self.assertEqual(expected, response) |
| 510 | 514 |
| 511 # Complete the isolated task. | 515 # Complete the isolated task. |
| 512 params = { | 516 params = { |
| 513 'cost_usd': 0.1, | 517 'cost_usd': 0.1, |
| 514 'duration': 3., | 518 'duration': 3., |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 u'extra_args': [], | 652 u'extra_args': [], |
| 649 u'hard_timeout': 3600, | 653 u'hard_timeout': 3600, |
| 650 u'grace_period': 30, | 654 u'grace_period': 30, |
| 651 u'host': u'http://localhost:8080', | 655 u'host': u'http://localhost:8080', |
| 652 u'isolated': { | 656 u'isolated': { |
| 653 u'input': u'0123456789012345678901234567890123456789', | 657 u'input': u'0123456789012345678901234567890123456789', |
| 654 u'server': u'http://localhost:1', | 658 u'server': u'http://localhost:1', |
| 655 u'namespace': u'default-gzip', | 659 u'namespace': u'default-gzip', |
| 656 }, | 660 }, |
| 657 u'io_timeout': 1200, | 661 u'io_timeout': 1200, |
| 662 u'outputs': [u'foo', u'path/to/foobar'], |
| 658 u'service_account': u'none', | 663 u'service_account': u'none', |
| 659 u'task_id': task_id, | 664 u'task_id': task_id, |
| 660 }, | 665 }, |
| 661 } | 666 } |
| 662 self.assertEqual(expected, response) | 667 self.assertEqual(expected, response) |
| 663 | 668 |
| 664 def test_bot_ereporter2_error(self): | 669 def test_bot_ereporter2_error(self): |
| 665 # ereporter2's //client/utils/on_error.py traps unhandled exceptions | 670 # ereporter2's //client/utils/on_error.py traps unhandled exceptions |
| 666 # automatically. | 671 # automatically. |
| 667 self.mock(random, 'getrandbits', lambda _: 0x88) | 672 self.mock(random, 'getrandbits', lambda _: 0x88) |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 self.app.get('/bot_code?tok=%s' % tok, status=200) | 1103 self.app.get('/bot_code?tok=%s' % tok, status=200) |
| 1099 | 1104 |
| 1100 | 1105 |
| 1101 if __name__ == '__main__': | 1106 if __name__ == '__main__': |
| 1102 if '-v' in sys.argv: | 1107 if '-v' in sys.argv: |
| 1103 unittest.TestCase.maxDiff = None | 1108 unittest.TestCase.maxDiff = None |
| 1104 logging.basicConfig( | 1109 logging.basicConfig( |
| 1105 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, | 1110 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, |
| 1106 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') | 1111 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') |
| 1107 unittest.main() | 1112 unittest.main() |
| OLD | NEW |