| 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 'items_hot': '', | 429 'items_hot': '', |
| 430 }, | 430 }, |
| 431 }, | 431 }, |
| 432 'output': base64.b64encode('Ahahah'), | 432 'output': base64.b64encode('Ahahah'), |
| 433 'output_chunk_start': 0, | 433 'output_chunk_start': 0, |
| 434 'outputs_ref': { | 434 'outputs_ref': { |
| 435 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', | 435 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', |
| 436 u'isolatedserver': u'http://localhost:1', | 436 u'isolatedserver': u'http://localhost:1', |
| 437 u'namespace': u'default-gzip', | 437 u'namespace': u'default-gzip', |
| 438 }, | 438 }, |
| 439 'cipd_pins': { |
| 440 u'client_package': { |
| 441 u'package_name': u'infra/tools/cipd/windows-amd64', |
| 442 u'version': u'deadbeef'*5, |
| 443 }, |
| 444 u'packages': [{ |
| 445 u'package_name': u'rm', |
| 446 u'path': u'bin', |
| 447 u'version': u'badc0fee'*5, |
| 448 }] |
| 449 }, |
| 439 'task_id': task_id, | 450 'task_id': task_id, |
| 440 } | 451 } |
| 441 response = self.post_json('/swarming/api/v1/bot/task_update', params) | 452 response = self.post_json('/swarming/api/v1/bot/task_update', params) |
| 442 self.assertEqual({u'must_stop': False, u'ok': True}, response) | 453 self.assertEqual({u'must_stop': False, u'ok': True}, response) |
| 443 | 454 |
| 444 response = self.client_get_results(task_id) | 455 response = self.client_get_results(task_id) |
| 445 expected = { | 456 expected = { |
| 446 u'bot_dimensions': [ | 457 u'bot_dimensions': [ |
| 447 {u'key': u'id', u'value': [u'bot1']}, | 458 {u'key': u'id', u'value': [u'bot1']}, |
| 448 {u'key': u'os', u'value': [u'Amiga']}, | 459 {u'key': u'os', u'value': [u'Amiga']}, |
| 449 {u'key': u'pool', u'value': [u'default']}, | 460 {u'key': u'pool', u'value': [u'default']}, |
| 450 ], | 461 ], |
| 451 u'bot_id': u'bot1', | 462 u'bot_id': u'bot1', |
| 452 u'bot_version': self.bot_version, | 463 u'bot_version': self.bot_version, |
| 453 u'completed_ts': str_now, | 464 u'completed_ts': str_now, |
| 454 u'costs_usd': [0.1], | 465 u'costs_usd': [0.1], |
| 455 u'created_ts': str_now, | 466 u'created_ts': str_now, |
| 456 u'duration': 3., | 467 u'duration': 3., |
| 457 u'exit_code': u'0', | 468 u'exit_code': u'0', |
| 458 u'failure': False, | 469 u'failure': False, |
| 459 u'internal_failure': False, | 470 u'internal_failure': False, |
| 460 u'modified_ts': str_now, | 471 u'modified_ts': str_now, |
| 461 u'name': u'hi', | 472 u'name': u'hi', |
| 462 u'outputs_ref': { | 473 u'outputs_ref': { |
| 463 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', | 474 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', |
| 464 u'isolatedserver': u'http://localhost:1', | 475 u'isolatedserver': u'http://localhost:1', |
| 465 u'namespace': u'default-gzip', | 476 u'namespace': u'default-gzip', |
| 466 }, | 477 }, |
| 478 'cipd_pins': { |
| 479 u'client_package': { |
| 480 u'package_name': u'infra/tools/cipd/windows-amd64', |
| 481 u'version': u'deadbeef'*5, |
| 482 }, |
| 483 u'packages': [{ |
| 484 u'package_name': u'rm', |
| 485 u'path': u'bin', |
| 486 u'version': u'badc0fee'*5, |
| 487 }] |
| 488 }, |
| 467 u'server_versions': [u'v1a'], | 489 u'server_versions': [u'v1a'], |
| 468 u'started_ts': str_now, | 490 u'started_ts': str_now, |
| 469 u'state': u'COMPLETED', | 491 u'state': u'COMPLETED', |
| 470 u'task_id': u'5cee488008811', | 492 u'task_id': u'5cee488008811', |
| 471 u'try_number': u'1', | 493 u'try_number': u'1', |
| 472 } | 494 } |
| 473 self.assertEqual(expected, response) | 495 self.assertEqual(expected, response) |
| 474 | 496 |
| 475 def test_poll_not_enough_time(self): | 497 def test_poll_not_enough_time(self): |
| 476 # Make sure there's a task that we don't get. | 498 # Make sure there's a task that we don't get. |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 self.app.get('/bot_code?tok=%s' % tok, status=200) | 992 self.app.get('/bot_code?tok=%s' % tok, status=200) |
| 971 | 993 |
| 972 | 994 |
| 973 if __name__ == '__main__': | 995 if __name__ == '__main__': |
| 974 if '-v' in sys.argv: | 996 if '-v' in sys.argv: |
| 975 unittest.TestCase.maxDiff = None | 997 unittest.TestCase.maxDiff = None |
| 976 logging.basicConfig( | 998 logging.basicConfig( |
| 977 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, | 999 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, |
| 978 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') | 1000 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') |
| 979 unittest.main() | 1001 unittest.main() |
| OLD | NEW |