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

Side by Side Diff: client/tests/run_isolated_test.py

Issue 2847153002: Cache/retrieve extracted CIPD packages in local isolate cache (Closed)
Patch Set: Address more comments Created 3 years, 7 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 # 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 # pylint: disable=R0201 6 # pylint: disable=R0201
7 7
8 import StringIO 8 import StringIO
9 import base64 9 import base64
10 import contextlib 10 import contextlib
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 subdir: [ 421 subdir: [
422 {'package': pkg, 'instance_id': ver} 422 {'package': pkg, 'instance_id': ver}
423 for pkg, ver in packages 423 for pkg, ver in packages
424 ] 424 ]
425 for subdir, packages in pins.iteritems() 425 for subdir, packages in pins.iteritems()
426 } 426 }
427 }, json_out) 427 }, json_out)
428 return 0 428 return 0
429 429
430 self.popen_mocks.append(fake_ensure) 430 self.popen_mocks.append(fake_ensure)
431 self._fake_isolated_cache = {}
432 self.mock(cipd.CipdClient, '_ensure_from_isolate',
433 self.fake_ensure_from_isolate)
434 self.mock(cipd.CipdClient, '_isolate_cipd', self.fake_isolate_cipd)
435
431 cipd_cache = os.path.join(self.tempdir, 'cipd_cache') 436 cipd_cache = os.path.join(self.tempdir, 'cipd_cache')
437
432 cmd = [ 438 cmd = [
433 '--no-log', 439 '--no-log',
434 '--cache', os.path.join(self.tempdir, 'cache'), 440 '--cache', os.path.join(self.tempdir, 'cache'),
435 '--cipd-client-version', 'git:wowza', 441 '--cipd-client-version', 'git:wowza',
436 '--cipd-package', 'bin:infra/tools/echo/${platform}:latest', 442 '--cipd-package', 'bin:infra/tools/echo/${platform}:latest',
437 '--cipd-package', '.:infra/data/x:latest', 443 '--cipd-package', '.:infra/data/x:latest',
438 '--cipd-package', '.:infra/data/y:canary', 444 '--cipd-package', '.:infra/data/y:canary',
439 '--cipd-server', self.cipd_server.url, 445 '--cipd-server', self.cipd_server.url,
440 '--cipd-cache', cipd_cache, 446 '--cipd-cache', cipd_cache,
441 '--named-cache-root', os.path.join(self.tempdir, 'c'), 447 '--named-cache-root', os.path.join(self.tempdir, 'c'),
(...skipping 29 matching lines...) Expand all
471 cipd_cache, 'clients', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')) 477 cipd_cache, 'clients', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))
472 self.assertTrue(fs.isfile(client_binary_file)) 478 self.assertTrue(fs.isfile(client_binary_file))
473 479
474 # Test echo call. 480 # Test echo call.
475 echo_cmd, _ = self.popen_calls[1] 481 echo_cmd, _ = self.popen_calls[1]
476 self.assertTrue(echo_cmd[0].endswith( 482 self.assertTrue(echo_cmd[0].endswith(
477 os.path.sep + 'bin' + os.path.sep + 'echo' + cipd.EXECUTABLE_SUFFIX), 483 os.path.sep + 'bin' + os.path.sep + 'echo' + cipd.EXECUTABLE_SUFFIX),
478 echo_cmd[0]) 484 echo_cmd[0])
479 self.assertEqual(echo_cmd[1:], ['hello', 'world']) 485 self.assertEqual(echo_cmd[1:], ['hello', 'world'])
480 486
487 def fake_ensure_from_isolate(self, target_dir, cipd_isolated, isolate_cache):
488 # Not seen first time, then seen all other times
489 if cipd_isolated not in self._fake_isolated_cache:
490 self._fake_isolated_cache[cipd_isolated] = True
491 return False
492 return True
493
494 def fake_isolate_cipd(self, root, pkgs, isolate_cache, cipd_cache):
495 pass
496
481 def test_main_naked_with_cipd_client_no_packages(self): 497 def test_main_naked_with_cipd_client_no_packages(self):
482 cipd_cache = os.path.join(self.tempdir, 'cipd_cache') 498 cipd_cache = os.path.join(self.tempdir, 'cipd_cache')
483 cmd = [ 499 cmd = [
484 '--no-log', 500 '--no-log',
485 '--cache', os.path.join(self.tempdir, 'cache'), 501 '--cache', os.path.join(self.tempdir, 'cache'),
486 '--cipd-enabled', 502 '--cipd-enabled',
487 '--cipd-client-version', 'git:wowza', 503 '--cipd-client-version', 'git:wowza',
488 '--cipd-server', self.cipd_server.url, 504 '--cipd-server', self.cipd_server.url,
489 '--cipd-cache', cipd_cache, 505 '--cipd-cache', cipd_cache,
490 '--named-cache-root', os.path.join(self.tempdir, 'c'), 506 '--named-cache-root', os.path.join(self.tempdir, 'c'),
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 self.assertEqual(expected, actual) 1001 self.assertEqual(expected, actual)
986 1002
987 1003
988 if __name__ == '__main__': 1004 if __name__ == '__main__':
989 fix_encoding.fix_encoding() 1005 fix_encoding.fix_encoding()
990 if '-v' in sys.argv: 1006 if '-v' in sys.argv:
991 unittest.TestCase.maxDiff = None 1007 unittest.TestCase.maxDiff = None
992 logging.basicConfig( 1008 logging.basicConfig(
993 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) 1009 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
994 unittest.main() 1010 unittest.main()
OLDNEW
« client/run_isolated.py ('K') | « client/run_isolated.py ('k') | client/utils/fs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698