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

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

Issue 2060983006: luci-py/isolateserver.py: Add archive support when downloading. (Closed) Base URL: https://github.com/luci/luci-py.git@master
Patch Set: Tests now pass. 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 # 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=W0212,W0223,W0231,W0613 6 # pylint: disable=W0212,W0223,W0231,W0613
7 7
8 import base64 8 import base64
9 import collections 9 import collections
10 import hashlib 10 import hashlib
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 queue.add(item.digest) 717 queue.add(item.digest)
718 718
719 # Wait for fetch to complete. 719 # Wait for fetch to complete.
720 while pending: 720 while pending:
721 fetched = queue.wait(pending) 721 fetched = queue.wait(pending)
722 pending.discard(fetched) 722 pending.discard(fetched)
723 723
724 # Ensure fetched same data as was pushed. 724 # Ensure fetched same data as was pushed.
725 self.assertEqual( 725 self.assertEqual(
726 [i.buffer for i in items], 726 [i.buffer for i in items],
727 [cache.read(i.digest) for i in items]) 727 [cache.getfileobj(i.digest).read() for i in items])
728 728
729 def test_push_and_fetch(self): 729 def test_push_and_fetch(self):
730 self.run_push_and_fetch_test('default') 730 self.run_push_and_fetch_test('default')
731 731
732 def test_push_and_fetch_gzip(self): 732 def test_push_and_fetch_gzip(self):
733 self.run_push_and_fetch_test('default-gzip') 733 self.run_push_and_fetch_test('default-gzip')
734 734
735 if sys.maxsize == (2**31) - 1: 735 if sys.maxsize == (2**31) - 1:
736 def test_archive_multiple_huge_file(self): 736 def test_archive_multiple_huge_file(self):
737 self.server.discard_content() 737 self.server.discard_content()
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 self.assertEqual(0, isolateserver.main(cmd)) 834 self.assertEqual(0, isolateserver.main(cmd))
835 expected = { 835 expected = {
836 os.path.join(net_utils.ROOT_DIR, 'path/to/a'): 'Coucou', 836 os.path.join(net_utils.ROOT_DIR, 'path/to/a'): 'Coucou',
837 os.path.join(net_utils.ROOT_DIR, 'path/to/b'): 'Bye Bye', 837 os.path.join(net_utils.ROOT_DIR, 'path/to/b'): 'Bye Bye',
838 } 838 }
839 self.assertEqual(expected, actual) 839 self.assertEqual(expected, actual)
840 840
841 def test_download_isolated(self): 841 def test_download_isolated(self):
842 # Test downloading an isolated tree. 842 # Test downloading an isolated tree.
843 actual = {} 843 actual = {}
844 def file_write_mock(key, generator): 844 def putfile_mock(srcfileobj, dstpath, file_mode=None):
845 actual[key] = ''.join(generator) 845 actual[dstpath] = srcfileobj.read()
846 self.mock(isolateserver, 'file_write', file_write_mock) 846 self.mock(isolateserver, 'putfile', putfile_mock)
847 self.mock(os, 'makedirs', lambda _: None) 847 self.mock(os, 'makedirs', lambda _: None)
848 server = 'http://example.com' 848 server = 'http://example.com'
849 files = { 849 files = {
850 os.path.join('a', 'foo'): 'Content', 850 os.path.join('a', 'foo'): 'Content',
851 'b': 'More content', 851 'b': 'More content',
852 } 852 }
853 isolated = { 853 isolated = {
854 'command': ['Absurb', 'command'], 854 'command': ['Absurb', 'command'],
855 'relative_cwd': 'a', 855 'relative_cwd': 'a',
856 'files': dict( 856 'files': dict(
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1081
1082 1082
1083 if __name__ == '__main__': 1083 if __name__ == '__main__':
1084 fix_encoding.fix_encoding() 1084 fix_encoding.fix_encoding()
1085 if '-v' in sys.argv: 1085 if '-v' in sys.argv:
1086 unittest.TestCase.maxDiff = None 1086 unittest.TestCase.maxDiff = None
1087 logging.basicConfig( 1087 logging.basicConfig(
1088 level=(logging.DEBUG if '-v' in sys.argv else logging.CRITICAL)) 1088 level=(logging.DEBUG if '-v' in sys.argv else logging.CRITICAL))
1089 clear_env_vars() 1089 clear_env_vars()
1090 unittest.main() 1090 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