Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: appengine/swarming/swarming_bot/bot_code/bot_main_test.py

Issue 2958853002: Propagate name of system service account to the bot. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/swarming/swarming_bot/bot_code/bot_auth_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import copy 6 import copy
7 import json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import sys 10 import sys
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 self.assertEqual(False, failure) 747 self.assertEqual(False, failure)
748 self.assertEqual(False, internal_failure) 748 self.assertEqual(False, internal_failure)
749 self.assertEqual({'os': 'Amiga', 'pool': 'default'}, dimensions) 749 self.assertEqual({'os': 'Amiga', 'pool': 'default'}, dimensions)
750 self.assertEqual(result, summary) 750 self.assertEqual(result, summary)
751 self.mock(bot_main, '_call_hook', call_hook) 751 self.mock(bot_main, '_call_hook', call_hook)
752 result = self._mock_popen( 752 result = self._mock_popen(
753 url='https://localhost:3', 753 url='https://localhost:3',
754 expected_auth_params_json={ 754 expected_auth_params_json={
755 'swarming_http_headers': {'A': 'a'}, 755 'swarming_http_headers': {'A': 'a'},
756 'swarming_http_headers_exp': int(time.time() + 3600), 756 'swarming_http_headers_exp': int(time.time() + 3600),
757 'task_service_account': 'bot', # as in task manifest 757 'system_service_account': 'robot@example.com', # as in task manifest
758 'task_service_account': 'bot',
758 }) 759 })
759 760
760 manifest = { 761 manifest = {
761 'command': ['echo', 'hi'], 762 'command': ['echo', 'hi'],
762 'dimensions': {'os': 'Amiga', 'pool': 'default'}, 763 'dimensions': {'os': 'Amiga', 'pool': 'default'},
763 'grace_period': 30, 764 'grace_period': 30,
764 'hard_timeout': 60, 765 'hard_timeout': 60,
765 'host': 'https://localhost:3', 766 'host': 'https://localhost:3',
766 'service_account': 'bot', 767 'service_accounts': {
768 'system': {'service_account': 'robot@example.com'},
769 'task': {'service_account': 'bot'},
770 },
767 'task_id': '24', 771 'task_id': '24',
768 } 772 }
769 self.assertEqual(self.root_dir, self.bot.base_dir) 773 self.assertEqual(self.root_dir, self.bot.base_dir)
770 bot_main._run_manifest(self.bot, manifest, time.time()) 774 bot_main._run_manifest(self.bot, manifest, time.time())
771 775
772 def test_run_manifest_task_failure(self): 776 def test_run_manifest_task_failure(self):
773 self.mock(bot_main, '_post_error_task', self.print_err_and_fail) 777 self.mock(bot_main, '_post_error_task', self.print_err_and_fail)
774 def call_hook(_botobj, name, *args): 778 def call_hook(_botobj, name, *args):
775 if name == 'on_after_task': 779 if name == 'on_after_task':
776 failure, internal_failure, dimensions, summary = args 780 failure, internal_failure, dimensions, summary = args
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 self.assertEqual([[bot_main.THIS_FILE, 'start_slave', '--survive']], calls) 926 self.assertEqual([[bot_main.THIS_FILE, 'start_slave', '--survive']], calls)
923 927
924 928
925 if __name__ == '__main__': 929 if __name__ == '__main__':
926 fix_encoding.fix_encoding() 930 fix_encoding.fix_encoding()
927 if '-v' in sys.argv: 931 if '-v' in sys.argv:
928 TestBotMain.maxDiff = None 932 TestBotMain.maxDiff = None
929 logging.basicConfig( 933 logging.basicConfig(
930 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) 934 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL)
931 unittest.main() 935 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/swarming_bot/bot_code/bot_auth_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698