| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 'items_hot': '', | 390 'items_hot': '', |
| 391 }, | 391 }, |
| 392 }, | 392 }, |
| 393 'output': base64.b64encode('Ahahah'), | 393 'output': base64.b64encode('Ahahah'), |
| 394 'output_chunk_start': 0, | 394 'output_chunk_start': 0, |
| 395 'outputs_ref': { | 395 'outputs_ref': { |
| 396 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', | 396 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', |
| 397 u'isolatedserver': u'http://localhost:1', | 397 u'isolatedserver': u'http://localhost:1', |
| 398 u'namespace': u'default-gzip', | 398 u'namespace': u'default-gzip', |
| 399 }, | 399 }, |
| 400 'cipd_pins': [{ |
| 401 u'package_name': u'rm', |
| 402 u'path': u'bin', |
| 403 u'version': u'badc0fee'*5, |
| 404 }], |
| 400 'task_id': task_id, | 405 'task_id': task_id, |
| 401 } | 406 } |
| 402 response = self.post_json('/swarming/api/v1/bot/task_update', params) | 407 response = self.post_json('/swarming/api/v1/bot/task_update', params) |
| 403 self.assertEqual({u'must_stop': False, u'ok': True}, response) | 408 self.assertEqual({u'must_stop': False, u'ok': True}, response) |
| 404 | 409 |
| 405 response = self.client_get_results(task_id) | 410 response = self.client_get_results(task_id) |
| 406 expected = { | 411 expected = { |
| 407 u'bot_dimensions': [ | 412 u'bot_dimensions': [ |
| 408 {u'key': u'id', u'value': [u'bot1']}, | 413 {u'key': u'id', u'value': [u'bot1']}, |
| 409 {u'key': u'os', u'value': [u'Amiga']}, | 414 {u'key': u'os', u'value': [u'Amiga']}, |
| 410 {u'key': u'pool', u'value': [u'default']}, | 415 {u'key': u'pool', u'value': [u'default']}, |
| 411 ], | 416 ], |
| 412 u'bot_id': u'bot1', | 417 u'bot_id': u'bot1', |
| 413 u'bot_version': self.bot_version, | 418 u'bot_version': self.bot_version, |
| 414 u'completed_ts': str_now, | 419 u'completed_ts': str_now, |
| 415 u'costs_usd': [0.1], | 420 u'costs_usd': [0.1], |
| 416 u'created_ts': str_now, | 421 u'created_ts': str_now, |
| 417 u'duration': 3., | 422 u'duration': 3., |
| 418 u'exit_code': u'0', | 423 u'exit_code': u'0', |
| 419 u'failure': False, | 424 u'failure': False, |
| 420 u'internal_failure': False, | 425 u'internal_failure': False, |
| 421 u'modified_ts': str_now, | 426 u'modified_ts': str_now, |
| 422 u'name': u'hi', | 427 u'name': u'hi', |
| 423 u'outputs_ref': { | 428 u'outputs_ref': { |
| 424 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', | 429 u'isolated': u'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', |
| 425 u'isolatedserver': u'http://localhost:1', | 430 u'isolatedserver': u'http://localhost:1', |
| 426 u'namespace': u'default-gzip', | 431 u'namespace': u'default-gzip', |
| 427 }, | 432 }, |
| 433 'cipd_pins': [{ |
| 434 u'package_name': u'rm', |
| 435 u'path': u'bin', |
| 436 u'version': u'badc0fee'*5, |
| 437 }], |
| 428 u'server_versions': [u'v1a'], | 438 u'server_versions': [u'v1a'], |
| 429 u'started_ts': str_now, | 439 u'started_ts': str_now, |
| 430 u'state': u'COMPLETED', | 440 u'state': u'COMPLETED', |
| 431 u'task_id': u'5cee488008811', | 441 u'task_id': u'5cee488008811', |
| 432 u'try_number': u'1', | 442 u'try_number': u'1', |
| 433 } | 443 } |
| 434 self.assertEqual(expected, response) | 444 self.assertEqual(expected, response) |
| 435 | 445 |
| 436 def test_poll_not_enough_time(self): | 446 def test_poll_not_enough_time(self): |
| 437 # Make sure there's a task that we don't get. | 447 # Make sure there's a task that we don't get. |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 self.app.get('/bot_code?tok=%s' % tok, status=200) | 941 self.app.get('/bot_code?tok=%s' % tok, status=200) |
| 932 | 942 |
| 933 | 943 |
| 934 if __name__ == '__main__': | 944 if __name__ == '__main__': |
| 935 if '-v' in sys.argv: | 945 if '-v' in sys.argv: |
| 936 unittest.TestCase.maxDiff = None | 946 unittest.TestCase.maxDiff = None |
| 937 logging.basicConfig( | 947 logging.basicConfig( |
| 938 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, | 948 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL, |
| 939 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') | 949 format='%(levelname)-7s %(filename)s:%(lineno)3d %(message)s') |
| 940 unittest.main() | 950 unittest.main() |
| OLD | NEW |