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

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

Issue 2024313003: Send authorization headers when calling Swarming backend. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: rebase Created 4 years, 6 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding=utf-8 2 # coding=utf-8
3 # Copyright 2013 The LUCI Authors. All rights reserved. 3 # Copyright 2013 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 json 8 import json
9 import logging 9 import logging
10 import os 10 import os
11 import re 11 import re
12 import signal 12 import signal
13 import sys 13 import sys
14 import tempfile 14 import tempfile
15 import time 15 import time
16 import unittest 16 import unittest
17 17
18 import test_env_bot_code 18 import test_env_bot_code
19 test_env_bot_code.setup_test_env() 19 test_env_bot_code.setup_test_env()
20 20
21 # Creates a server mock for functions in net.py. 21 # Creates a server mock for functions in net.py.
22 import net_utils 22 import net_utils
23 23
24 from api import os_utilities
25 from depot_tools import fix_encoding 24 from depot_tools import fix_encoding
26 from utils import file_path 25 from utils import file_path
27 from utils import large 26 from utils import large
28 from utils import logging_utils 27 from utils import logging_utils
29 from utils import subprocess42 28 from utils import subprocess42
30 from utils import tools
31 import fake_swarming 29 import fake_swarming
32 import task_runner 30 import task_runner
33 31
34 CLIENT_DIR = os.path.normpath( 32 CLIENT_DIR = os.path.normpath(
35 os.path.join(test_env_bot_code.BOT_DIR, '..', '..', '..', 'client')) 33 os.path.join(test_env_bot_code.BOT_DIR, '..', '..', '..', 'client'))
36 34
37 sys.path.insert(0, os.path.join(CLIENT_DIR, 'tests')) 35 sys.path.insert(0, os.path.join(CLIENT_DIR, 'tests'))
38 import isolateserver_mock 36 import isolateserver_mock
39 37
40 38
(...skipping 23 matching lines...) Expand all
64 self.work_dir = os.path.join(self.root_dir, 'work') 62 self.work_dir = os.path.join(self.root_dir, 'work')
65 os.chdir(self.root_dir) 63 os.chdir(self.root_dir)
66 os.mkdir(self.work_dir) 64 os.mkdir(self.work_dir)
67 # Create the logs directory so run_isolated.py can put its log there. 65 # Create the logs directory so run_isolated.py can put its log there.
68 os.mkdir(os.path.join(self.root_dir, 'logs')) 66 os.mkdir(os.path.join(self.root_dir, 'logs'))
69 67
70 self.mock( 68 self.mock(
71 task_runner, 'get_run_isolated', 69 task_runner, 'get_run_isolated',
72 lambda: [sys.executable, os.path.join(CLIENT_DIR, 'run_isolated.py')]) 70 lambda: [sys.executable, os.path.join(CLIENT_DIR, 'run_isolated.py')])
73 71
72 # In case this test itself is running one Swarming, clear the bots
73 # environment.
74 os.environ.pop('SWARMING_BOT_ID', None)
75 os.environ.pop('SWARMING_TASK_ID', None)
76 os.environ.pop('SWARMING_AUTH_PARAMS', None)
77
74 def tearDown(self): 78 def tearDown(self):
75 os.chdir(test_env_bot_code.BOT_DIR) 79 os.chdir(test_env_bot_code.BOT_DIR)
76 try: 80 try:
77 file_path.rmtree(self.root_dir) 81 file_path.rmtree(self.root_dir)
78 except OSError: 82 except OSError:
79 print >> sys.stderr, 'Failed to delete %s' % self.root_dir 83 print >> sys.stderr, 'Failed to delete %s' % self.root_dir
80 finally: 84 finally:
81 super(TestTaskRunnerBase, self).tearDown() 85 super(TestTaskRunnerBase, self).tearDown()
82 86
83 @classmethod 87 @classmethod
84 def get_task_details(cls, *args, **kwargs): 88 def get_task_details(cls, *args, **kwargs):
85 return task_runner.TaskDetails(get_manifest(*args, **kwargs)) 89 return task_runner.TaskDetails(get_manifest(*args, **kwargs))
86 90
87 def gen_requests(self, cost_usd=0., **kwargs): 91 def gen_requests(self, cost_usd=0., auth_headers=None, **kwargs):
88 return [ 92 return [
89 ( 93 (
90 'https://localhost:1/swarming/api/v1/bot/task_update/23', 94 'https://localhost:1/swarming/api/v1/bot/task_update/23',
91 self.get_check_first(cost_usd), 95 self.get_check_first(cost_usd, auth_headers=auth_headers),
92 {'ok': True}, 96 {'ok': True},
93 ), 97 ),
94 ( 98 (
95 'https://localhost:1/swarming/api/v1/bot/task_update/23', 99 'https://localhost:1/swarming/api/v1/bot/task_update/23',
96 self.get_check_final(**kwargs), 100 self.get_check_final(auth_headers=auth_headers, **kwargs),
97 {'ok': True}, 101 {'ok': True},
98 ), 102 ),
99 ] 103 ]
100 104
101 def requests(self, **kwargs): 105 def requests(self, **kwargs):
102 """Generates the expected HTTP requests for a task run.""" 106 """Generates the expected HTTP requests for a task run."""
103 self.expected_requests(self.gen_requests(**kwargs)) 107 self.expected_requests(self.gen_requests(**kwargs))
104 108
105 def get_check_first(self, cost_usd): 109 def get_check_first(self, cost_usd, auth_headers=None):
106 def check_first(kwargs): 110 def check_first(kwargs):
107 self.assertLessEqual(cost_usd, kwargs['data'].pop('cost_usd')) 111 self.assertLessEqual(cost_usd, kwargs['data'].pop('cost_usd'))
108 self.assertEqual( 112 self.assertEqual(
109 { 113 {
110 'data': { 114 'data': {
111 'id': 'localhost', 115 'id': 'localhost',
112 'task_id': 23, 116 'task_id': 23,
113 }, 117 },
118 'follow_redirects': False,
119 'headers': auth_headers or {},
114 }, 120 },
115 kwargs) 121 kwargs)
116 return check_first 122 return check_first
117 123
118 124
119 class TestTaskRunner(TestTaskRunnerBase): 125 class TestTaskRunner(TestTaskRunnerBase):
120 def setUp(self): 126 def setUp(self):
121 super(TestTaskRunner, self).setUp() 127 super(TestTaskRunner, self).setUp()
122 self.mock(time, 'time', lambda: 1000000000.) 128 self.mock(time, 'time', lambda: 1000000000.)
123 129
124 def get_check_final(self, exit_code=0, output_re=r'^hi\n$', outputs_ref=None): 130 def get_check_final(
131 self, exit_code=0, output_re=r'^hi\n$', outputs_ref=None,
132 auth_headers=None):
125 def check_final(kwargs): 133 def check_final(kwargs):
126 # Ignore these values. 134 # Ignore these values.
127 kwargs['data'].pop('bot_overhead', None) 135 kwargs['data'].pop('bot_overhead', None)
128 kwargs['data'].pop('duration', None) 136 kwargs['data'].pop('duration', None)
129 137
130 output = '' 138 output = ''
131 if 'output' in kwargs['data']: 139 if 'output' in kwargs['data']:
132 output = base64.b64decode(kwargs['data'].pop('output')) 140 output = base64.b64decode(kwargs['data'].pop('output'))
133 self.assertTrue(re.match(output_re, output)) 141 self.assertTrue(re.match(output_re, output))
134 142
135 expected = { 143 expected = {
136 'data': { 144 'data': {
137 'cost_usd': 10., 145 'cost_usd': 10.,
138 'exit_code': exit_code, 146 'exit_code': exit_code,
139 'hard_timeout': False, 147 'hard_timeout': False,
140 'id': 'localhost', 148 'id': 'localhost',
141 'io_timeout': False, 149 'io_timeout': False,
142 'output_chunk_start': 0, 150 'output_chunk_start': 0,
143 'task_id': 23, 151 'task_id': 23,
144 }, 152 },
153 'follow_redirects': False,
154 'headers': auth_headers or {},
145 } 155 }
146 if outputs_ref: 156 if outputs_ref:
147 expected['data']['outputs_ref'] = outputs_ref 157 expected['data']['outputs_ref'] = outputs_ref
148 self.assertEqual(expected, kwargs) 158 self.assertEqual(expected, kwargs)
149 return check_final 159 return check_final
150 160
151 def _run_command(self, task_details): 161 def _run_command(self, task_details):
152 start = time.time() 162 start = time.time()
153 self.mock(time, 'time', lambda: start + 10) 163 self.mock(time, 'time', lambda: start + 10)
154 server = 'https://localhost:1' 164 server = 'https://localhost:1'
155 return task_runner.run_command( 165 return task_runner.run_command(
156 server, task_details, self.work_dir, 3600., start, 1) 166 server, task_details, self.work_dir, 3600., start, 1)
157 167
158 def test_load_and_run_raw(self): 168 def test_load_and_run_raw(self):
159 server = 'https://localhost:1' 169 server = 'https://localhost:1'
160 170
161 def run_command( 171 def run_command(
162 swarming_server, task_details, work_dir, cost_usd_hour, start, 172 swarming_server, task_details, work_dir,
163 min_free_space): 173 cost_usd_hour, start, min_free_space):
164 self.assertEqual(server, swarming_server) 174 self.assertEqual(server, swarming_server)
175 self.assertTrue(isinstance(task_details, task_runner.TaskDetails))
165 # Necessary for OSX. 176 # Necessary for OSX.
166 self.assertEqual( 177 self.assertEqual(
167 os.path.realpath(self.work_dir), os.path.realpath(work_dir)) 178 os.path.realpath(self.work_dir), os.path.realpath(work_dir))
168 self.assertTrue(isinstance(task_details, task_runner.TaskDetails))
169 self.assertEqual(3600., cost_usd_hour) 179 self.assertEqual(3600., cost_usd_hour)
170 self.assertEqual(time.time(), start) 180 self.assertEqual(time.time(), start)
171 self.assertEqual(1, min_free_space) 181 self.assertEqual(1, min_free_space)
172 return { 182 return {
173 u'exit_code': 1, 183 u'exit_code': 1,
174 u'hard_timeout': False, 184 u'hard_timeout': False,
175 u'io_timeout': False, 185 u'io_timeout': False,
176 u'must_signal_internal_failure': None, 186 u'must_signal_internal_failure': None,
177 u'version': task_runner.OUT_VERSION, 187 u'version': task_runner.OUT_VERSION,
178 } 188 }
(...skipping 24 matching lines...) Expand all
203 u'version': task_runner.OUT_VERSION, 213 u'version': task_runner.OUT_VERSION,
204 } 214 }
205 with open(out_file, 'rb') as f: 215 with open(out_file, 'rb') as f:
206 self.assertEqual(expected, json.load(f)) 216 self.assertEqual(expected, json.load(f))
207 217
208 def test_load_and_run_isolated(self): 218 def test_load_and_run_isolated(self):
209 self.expected_requests([]) 219 self.expected_requests([])
210 server = 'https://localhost:1' 220 server = 'https://localhost:1'
211 221
212 def run_command( 222 def run_command(
213 swarming_server, task_details, work_dir, cost_usd_hour, start, 223 swarming_server, task_details, work_dir,
214 min_free_space): 224 cost_usd_hour, start, min_free_space):
215 self.assertEqual(server, swarming_server) 225 self.assertEqual(server, swarming_server)
226 self.assertTrue(isinstance(task_details, task_runner.TaskDetails))
216 # Necessary for OSX. 227 # Necessary for OSX.
217 self.assertEqual( 228 self.assertEqual(
218 os.path.realpath(self.work_dir), os.path.realpath(work_dir)) 229 os.path.realpath(self.work_dir), os.path.realpath(work_dir))
219 self.assertTrue(isinstance(task_details, task_runner.TaskDetails))
220 self.assertEqual(3600., cost_usd_hour) 230 self.assertEqual(3600., cost_usd_hour)
221 self.assertEqual(time.time(), start) 231 self.assertEqual(time.time(), start)
222 self.assertEqual(1, min_free_space) 232 self.assertEqual(1, min_free_space)
223 return { 233 return {
224 u'exit_code': 0, 234 u'exit_code': 0,
225 u'hard_timeout': False, 235 u'hard_timeout': False,
226 u'io_timeout': False, 236 u'io_timeout': False,
227 u'must_signal_internal_failure': None, 237 u'must_signal_internal_failure': None,
228 u'version': task_runner.OUT_VERSION, 238 u'version': task_runner.OUT_VERSION,
229 } 239 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 task_details = self.get_task_details('print(\'hi\')') 276 task_details = self.get_task_details('print(\'hi\')')
267 expected = { 277 expected = {
268 u'exit_code': 0, 278 u'exit_code': 0,
269 u'hard_timeout': False, 279 u'hard_timeout': False,
270 u'io_timeout': False, 280 u'io_timeout': False,
271 u'must_signal_internal_failure': None, 281 u'must_signal_internal_failure': None,
272 u'version': task_runner.OUT_VERSION, 282 u'version': task_runner.OUT_VERSION,
273 } 283 }
274 self.assertEqual(expected, self._run_command(task_details)) 284 self.assertEqual(expected, self._run_command(task_details))
275 285
286 def test_run_command_raw_with_auth(self):
287 auth_params_file = os.path.join(self.root_dir, 'auth_params.json')
288 with open(auth_params_file, 'wb') as f:
289 json.dump({'swarming_http_headers': {'A': 'a'}}, f)
290 os.environ['SWARMING_AUTH_PARAMS'] = auth_params_file
291
292 # This runs the command for real.
293 self.requests(cost_usd=1, exit_code=0, auth_headers={'A': 'a'})
294 task_details = self.get_task_details('print(\'hi\')')
295 expected = {
296 u'exit_code': 0,
297 u'hard_timeout': False,
298 u'io_timeout': False,
299 u'must_signal_internal_failure': None,
300 u'version': task_runner.OUT_VERSION,
301 }
302 self.assertEqual(expected, self._run_command(task_details))
303
276 def test_run_command_isolated(self): 304 def test_run_command_isolated(self):
277 # This runs the command for real. 305 # This runs the command for real.
278 self.requests( 306 self.requests(
279 cost_usd=1, exit_code=0, 307 cost_usd=1, exit_code=0,
280 outputs_ref={ 308 outputs_ref={
281 u'isolated': u'123', 309 u'isolated': u'123',
282 u'isolatedserver': u'http://localhost:1', 310 u'isolatedserver': u'http://localhost:1',
283 u'namespace': u'default-gzip', 311 u'namespace': u'default-gzip',
284 }) 312 })
285 task_details = self.get_task_details(isolated={ 313 task_details = self.get_task_details(isolated={
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 'cost_usd': 10., 437 'cost_usd': 10.,
410 'duration': 0., 438 'duration': 0.,
411 'exit_code': 0, 439 'exit_code': 0,
412 'hard_timeout': False, 440 'hard_timeout': False,
413 'id': 'localhost', 441 'id': 'localhost',
414 'io_timeout': False, 442 'io_timeout': False,
415 'output': base64.b64encode('hi!\n'), 443 'output': base64.b64encode('hi!\n'),
416 'output_chunk_start': 100002*4, 444 'output_chunk_start': 100002*4,
417 'task_id': 23, 445 'task_id': 23,
418 }, 446 },
447 'follow_redirects': False,
448 'headers': {},
419 }, 449 },
420 kwargs) 450 kwargs)
421 451
422 requests = [ 452 requests = [
423 ( 453 (
424 'https://localhost:1/swarming/api/v1/bot/task_update/23', 454 'https://localhost:1/swarming/api/v1/bot/task_update/23',
425 { 455 {
426 'data': { 456 'data': {
427 'cost_usd': 10., 457 'cost_usd': 10.,
428 'id': 'localhost', 458 'id': 'localhost',
429 'task_id': 23, 459 'task_id': 23,
430 }, 460 },
461 'follow_redirects': False,
462 'headers': {},
431 }, 463 },
432 {'ok': True}, 464 {'ok': True},
433 ), 465 ),
434 ( 466 (
435 'https://localhost:1/swarming/api/v1/bot/task_update/23', 467 'https://localhost:1/swarming/api/v1/bot/task_update/23',
436 { 468 {
437 'data': { 469 'data': {
438 'cost_usd': 10., 470 'cost_usd': 10.,
439 'id': 'localhost', 471 'id': 'localhost',
440 'output': base64.b64encode('hi!\n' * 100002), 472 'output': base64.b64encode('hi!\n' * 100002),
441 'output_chunk_start': 0, 473 'output_chunk_start': 0,
442 'task_id': 23, 474 'task_id': 23,
443 }, 475 },
476 'follow_redirects': False,
477 'headers': {},
444 }, 478 },
445 {'ok': True}, 479 {'ok': True},
446 ), 480 ),
447 ( 481 (
448 'https://localhost:1/swarming/api/v1/bot/task_update/23', 482 'https://localhost:1/swarming/api/v1/bot/task_update/23',
449 check_final, 483 check_final,
450 {'ok': True}, 484 {'ok': True},
451 ), 485 ),
452 ] 486 ]
453 self.expected_requests(requests) 487 self.expected_requests(requests)
(...skipping 13 matching lines...) Expand all
467 u'exit_code': 0, 501 u'exit_code': 0,
468 u'hard_timeout': False, 502 u'hard_timeout': False,
469 u'io_timeout': False, 503 u'io_timeout': False,
470 u'must_signal_internal_failure': None, 504 u'must_signal_internal_failure': None,
471 u'version': task_runner.OUT_VERSION, 505 u'version': task_runner.OUT_VERSION,
472 } 506 }
473 self.assertEqual(expected, self._run_command(task_details)) 507 self.assertEqual(expected, self._run_command(task_details))
474 508
475 def test_main(self): 509 def test_main(self):
476 def load_and_run( 510 def load_and_run(
477 manifest, swarming_server, cost_usd_hour, start, json_file, 511 manifest, swarming_server, cost_usd_hour, start,
478 min_free_space): 512 json_file, min_free_space):
479 self.assertEqual('foo', manifest) 513 self.assertEqual('foo', manifest)
480 self.assertEqual('http://localhost', swarming_server) 514 self.assertEqual('http://localhost', swarming_server)
481 self.assertEqual(3600., cost_usd_hour) 515 self.assertEqual(3600., cost_usd_hour)
482 self.assertEqual(time.time(), start) 516 self.assertEqual(time.time(), start)
483 self.assertEqual('task_summary.json', json_file) 517 self.assertEqual('task_summary.json', json_file)
484 self.assertEqual(1, min_free_space) 518 self.assertEqual(1, min_free_space)
485 519
486 self.mock(task_runner, 'load_and_run', load_and_run) 520 self.mock(task_runner, 'load_and_run', load_and_run)
487 cmd = [ 521 cmd = [
488 '--swarming-server', 'http://localhost', 522 '--swarming-server', 'http://localhost',
489 '--in-file', 'foo', 523 '--in-file', 'foo',
490 '--out-file', 'task_summary.json', 524 '--out-file', 'task_summary.json',
491 '--cost-usd-hour', '3600', 525 '--cost-usd-hour', '3600',
492 '--start', str(time.time()), 526 '--start', str(time.time()),
493 '--min-free-space', '1', 527 '--min-free-space', '1',
494 ] 528 ]
495 self.assertEqual(0, task_runner.main(cmd)) 529 self.assertEqual(0, task_runner.main(cmd))
496 530
497 def test_main_reboot(self): 531 def test_main_reboot(self):
498 def load_and_run( 532 def load_and_run(
499 manifest, swarming_server, cost_usd_hour, start, json_file, 533 manifest, swarming_server, cost_usd_hour, start,
500 min_free_space): 534 json_file, min_free_space):
501 self.assertEqual('foo', manifest) 535 self.assertEqual('foo', manifest)
502 self.assertEqual('http://localhost', swarming_server) 536 self.assertEqual('http://localhost', swarming_server)
503 self.assertEqual(3600., cost_usd_hour) 537 self.assertEqual(3600., cost_usd_hour)
504 self.assertEqual(time.time(), start) 538 self.assertEqual(time.time(), start)
505 self.assertEqual('task_summary.json', json_file) 539 self.assertEqual('task_summary.json', json_file)
506 self.assertEqual(1, min_free_space) 540 self.assertEqual(1, min_free_space)
507 541
508 self.mock(task_runner, 'load_and_run', load_and_run) 542 self.mock(task_runner, 'load_and_run', load_and_run)
509 cmd = [ 543 cmd = [
510 '--swarming-server', 'http://localhost', 544 '--swarming-server', 'http://localhost',
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 ' except IOError:\n' 595 ' except IOError:\n'
562 ' pass;\n' 596 ' pass;\n'
563 'print(\'bye\');\n' 597 'print(\'bye\');\n'
564 'time.sleep(100)') % ( 598 'time.sleep(100)') % (
565 'signal.SIGBREAK' if sys.platform == 'win32' else 'signal.SIGTERM') 599 'signal.SIGBREAK' if sys.platform == 'win32' else 'signal.SIGTERM')
566 600
567 SCRIPT_HANG = 'import time; print(\'hi\'); time.sleep(100)' 601 SCRIPT_HANG = 'import time; print(\'hi\'); time.sleep(100)'
568 602
569 def get_check_final( 603 def get_check_final(
570 self, hard_timeout=False, io_timeout=False, exit_code=None, 604 self, hard_timeout=False, io_timeout=False, exit_code=None,
571 output_re='^hi\n$'): 605 output_re='^hi\n$', auth_headers=None):
572 def check_final(kwargs): 606 def check_final(kwargs):
573 kwargs['data'].pop('bot_overhead', None) 607 kwargs['data'].pop('bot_overhead', None)
574 if hard_timeout or io_timeout: 608 if hard_timeout or io_timeout:
575 self.assertLess(self.SHORT_TIME_OUT, kwargs['data'].pop('cost_usd')) 609 self.assertLess(self.SHORT_TIME_OUT, kwargs['data'].pop('cost_usd'))
576 self.assertLess(self.SHORT_TIME_OUT, kwargs['data'].pop('duration')) 610 self.assertLess(self.SHORT_TIME_OUT, kwargs['data'].pop('duration'))
577 else: 611 else:
578 self.assertLess(0., kwargs['data'].pop('cost_usd')) 612 self.assertLess(0., kwargs['data'].pop('cost_usd'))
579 self.assertLess(0., kwargs['data'].pop('duration')) 613 self.assertLess(0., kwargs['data'].pop('duration'))
580 614
581 output = '' 615 output = ''
582 if 'output' in kwargs['data']: 616 if 'output' in kwargs['data']:
583 output = base64.b64decode(kwargs['data'].pop('output')) 617 output = base64.b64decode(kwargs['data'].pop('output'))
584 self.assertTrue(re.match(output_re, output)) 618 self.assertTrue(re.match(output_re, output))
585 619
586 self.assertEqual( 620 self.assertEqual(
587 { 621 {
588 'data': { 622 'data': {
589 'exit_code': exit_code, 623 'exit_code': exit_code,
590 'hard_timeout': hard_timeout, 624 'hard_timeout': hard_timeout,
591 'id': 'localhost', 625 'id': 'localhost',
592 'io_timeout': io_timeout, 626 'io_timeout': io_timeout,
593 'output_chunk_start': 0, 627 'output_chunk_start': 0,
594 'task_id': 23, 628 'task_id': 23,
595 }, 629 },
630 'follow_redirects': False,
631 'headers': auth_headers or {},
596 }, 632 },
597 kwargs) 633 kwargs)
598 return check_final 634 return check_final
599 635
600 def _load_and_run(self, manifest): 636 def _load_and_run(self, manifest):
601 # Dot not mock time since this test class is testing timeouts. 637 # Dot not mock time since this test class is testing timeouts.
602 server = 'https://localhost:1' 638 server = 'https://localhost:1'
603 in_file = os.path.join(self.work_dir, 'task_runner_in.json') 639 in_file = os.path.join(self.work_dir, 'task_runner_in.json')
604 with open(in_file, 'wb') as f: 640 with open(in_file, 'wb') as f:
605 json.dump(manifest, f) 641 json.dump(manifest, f)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 }, 830 },
795 u'upload': { 831 u'upload': {
796 u'items_cold': [], 832 u'items_cold': [],
797 u'items_hot': [], 833 u'items_hot': [],
798 }, 834 },
799 }, 835 },
800 'output': 'hi\n', 836 'output': 'hi\n',
801 'output_chunk_start': 0, 837 'output_chunk_start': 0,
802 'task_id': 23, 838 'task_id': 23,
803 }, 839 },
840 'follow_redirects': False,
841 'headers': {},
804 }, 842 },
805 kwargs) 843 kwargs)
806 requests = [ 844 requests = [
807 ( 845 (
808 'https://localhost:1/swarming/api/v1/bot/task_update/23', 846 'https://localhost:1/swarming/api/v1/bot/task_update/23',
809 self.get_check_first(0.), 847 self.get_check_first(0.),
810 {'ok': True}, 848 {'ok': True},
811 ), 849 ),
812 ( 850 (
813 'https://localhost:1/swarming/api/v1/bot/task_update/23', 851 'https://localhost:1/swarming/api/v1/bot/task_update/23',
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 u'items_hot': [], 951 u'items_hot': [],
914 }, 952 },
915 u'upload': { 953 u'upload': {
916 u'items_cold': [], 954 u'items_cold': [],
917 u'items_hot': [], 955 u'items_hot': [],
918 }, 956 },
919 }, 957 },
920 'output_chunk_start': 0, 958 'output_chunk_start': 0,
921 'task_id': 23, 959 'task_id': 23,
922 }, 960 },
961 'follow_redirects': False,
962 'headers': {},
923 }, 963 },
924 kwargs) 964 kwargs)
925 requests = [ 965 requests = [
926 ( 966 (
927 'https://localhost:1/swarming/api/v1/bot/task_update/23', 967 'https://localhost:1/swarming/api/v1/bot/task_update/23',
928 self.get_check_first(0.), 968 self.get_check_first(0.),
929 {'ok': True}, 969 {'ok': True},
930 ), 970 ),
931 ( 971 (
932 'https://localhost:1/swarming/api/v1/bot/task_update/23', 972 'https://localhost:1/swarming/api/v1/bot/task_update/23',
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 fix_encoding.fix_encoding() 1136 fix_encoding.fix_encoding()
1097 if '-v' in sys.argv: 1137 if '-v' in sys.argv:
1098 unittest.TestCase.maxDiff = None 1138 unittest.TestCase.maxDiff = None
1099 logging_utils.prepare_logging(None) 1139 logging_utils.prepare_logging(None)
1100 logging_utils.set_console_level( 1140 logging_utils.set_console_level(
1101 logging.DEBUG if '-v' in sys.argv else logging.CRITICAL+1) 1141 logging.DEBUG if '-v' in sys.argv else logging.CRITICAL+1)
1102 # Fix litteral text expectation. 1142 # Fix litteral text expectation.
1103 os.environ['LANG'] = 'en_US.UTF-8' 1143 os.environ['LANG'] = 'en_US.UTF-8'
1104 os.environ['LANGUAGE'] = 'en_US.UTF-8' 1144 os.environ['LANGUAGE'] = 'en_US.UTF-8'
1105 unittest.main() 1145 unittest.main()
OLDNEW
« no previous file with comments | « appengine/swarming/swarming_bot/bot_code/task_runner.py ('k') | appengine/swarming/swarming_bot/config/bot_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698