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

Side by Side Diff: gslib/tests/test_perfdiag.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 # -*- coding: utf-8 -*-
1 # Copyright 2013 Google Inc. All Rights Reserved. 2 # Copyright 2013 Google Inc. All Rights Reserved.
2 # 3 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
6 # 7 #
7 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
8 # 9 #
9 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and 13 # See the License for the specific language governing permissions and
13 # limitations under the License. 14 # limitations under the License.
15 """Integration tests for perfdiag command."""
16
17 from __future__ import absolute_import
14 18
15 import socket 19 import socket
16 20
17 import gslib.tests.testcase as testcase 21 import gslib.tests.testcase as testcase
18 from gslib.tests.util import ObjectToURI as suri 22 from gslib.tests.util import ObjectToURI as suri
19 from gslib.tests.util import unittest 23 from gslib.tests.util import unittest
20 from gslib.util import IS_WINDOWS 24 from gslib.util import IS_WINDOWS
21 25
26
22 class TestPerfDiag(testcase.GsUtilIntegrationTestCase): 27 class TestPerfDiag(testcase.GsUtilIntegrationTestCase):
23 """Integration tests for perfdiag command.""" 28 """Integration tests for perfdiag command."""
24 29
25 # We want to test that perfdiag works both when connecting to the standard gs 30 # We want to test that perfdiag works both when connecting to the standard gs
26 # endpoint, and when connecting to a specific IP or host while setting the 31 # endpoint, and when connecting to a specific IP or host while setting the
27 # host header. For the 2nd case we resolve storage.googleapis.com to a 32 # host header. For the 2nd case we resolve storage.googleapis.com to a
28 # specific IP and connect to that explicitly. 33 # specific IP and connect to that explicitly.
29 _gs_ip = socket.gethostbyname('storage.googleapis.com') 34 _gs_ip = socket.gethostbyname('storage.googleapis.com')
30 _custom_endpoint_flags = [ 35 _custom_endpoint_flags = [
31 '-o', 'Credentials:gs_host=' + _gs_ip, 36 '-o', 'Credentials:gs_host=' + _gs_ip,
32 '-o', 'Credentials:gs_host_header=storage.googleapis.com', 37 '-o', 'Credentials:gs_host_header=storage.googleapis.com',
38 # TODO: gsutil-beta: Add host header support for JSON
33 '-o', 'Boto:https_validate_certificates=False'] 39 '-o', 'Boto:https_validate_certificates=False']
34 40
35 def test_latency(self): 41 def test_latency(self):
36 bucket_uri = self.CreateBucket() 42 bucket_uri = self.CreateBucket()
37 cmd = ['perfdiag', '-n', '1', '-t', 'lat', suri(bucket_uri)] 43 cmd = ['perfdiag', '-n', '1', '-t', 'lat', suri(bucket_uri)]
38 self.RunGsUtil(cmd) 44 self.RunGsUtil(cmd)
39 self.RunGsUtil(self._custom_endpoint_flags + cmd) 45 if self.test_api == 'XML':
46 self.RunGsUtil(self._custom_endpoint_flags + cmd)
40 47
41 def _run_basic_wthru_or_rthru(self, test_name, num_processes, num_threads): 48 def _run_basic_wthru_or_rthru(self, test_name, num_processes, num_threads):
42 bucket_uri = self.CreateBucket() 49 bucket_uri = self.CreateBucket()
43 cmd = ['perfdiag', '-n', str(num_processes * num_threads), 50 cmd = ['perfdiag', '-n', str(num_processes * num_threads),
44 '-s', '1024', '-c', str(num_processes), 51 '-s', '1024', '-c', str(num_processes),
45 '-k', str(num_threads), '-t', test_name, suri(bucket_uri)] 52 '-k', str(num_threads), '-t', test_name, suri(bucket_uri)]
46 self.RunGsUtil(cmd) 53 self.RunGsUtil(cmd)
47 self.RunGsUtil(self._custom_endpoint_flags + cmd) 54 if self.test_api == 'XML':
55 self.RunGsUtil(self._custom_endpoint_flags + cmd)
56
57 def test_write_throughput_single_process_single_thread(self):
58 self._run_basic_wthru_or_rthru('wthru', 1, 1)
48 59
49 def test_write_throughput_single_process_multi_thread(self): 60 def test_write_throughput_single_process_multi_thread(self):
50 self._run_basic_wthru_or_rthru('wthru', 1, 2) 61 self._run_basic_wthru_or_rthru('wthru', 1, 2)
51 62
52 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows') 63 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows')
53 def test_write_throughput_multi_process_single_thread(self): 64 def test_write_throughput_multi_process_single_thread(self):
54 self._run_basic_wthru_or_rthru('wthru', 2, 1) 65 self._run_basic_wthru_or_rthru('wthru', 2, 1)
55 66
56 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows') 67 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows')
57 def test_write_throughput_multi_process_multi_thread(self): 68 def test_write_throughput_multi_process_multi_thread(self):
58 self._run_basic_wthru_or_rthru('wthru', 2, 2) 69 self._run_basic_wthru_or_rthru('wthru', 2, 2)
59 70
71 def test_read_throughput_single_process_single_thread(self):
72 self._run_basic_wthru_or_rthru('rthru', 1, 1)
73
60 def test_read_throughput_single_process_multi_thread(self): 74 def test_read_throughput_single_process_multi_thread(self):
61 self._run_basic_wthru_or_rthru('rthru', 1, 2) 75 self._run_basic_wthru_or_rthru('rthru', 1, 2)
62 76
63 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows') 77 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows')
64 def test_read_throughput_multi_process_single_thread(self): 78 def test_read_throughput_multi_process_single_thread(self):
65 self._run_basic_wthru_or_rthru('rthru', 2, 1) 79 self._run_basic_wthru_or_rthru('rthru', 2, 1)
66 80
67 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows') 81 @unittest.skipIf(IS_WINDOWS, 'Multiprocessing is not supported on Windows')
68 def test_read_throughput_multi_process_multi_thread(self): 82 def test_read_throughput_multi_process_multi_thread(self):
69 self._run_basic_wthru_or_rthru('rthru', 2, 2) 83 self._run_basic_wthru_or_rthru('rthru', 2, 2)
70 84
71 def test_input_output(self): 85 def test_input_output(self):
72 outpath = self.CreateTempFile() 86 outpath = self.CreateTempFile()
73 bucket_uri = self.CreateBucket() 87 bucket_uri = self.CreateBucket()
74 self.RunGsUtil(['perfdiag', '-o', outpath, '-n', '1', '-t', 'lat', 88 self.RunGsUtil(['perfdiag', '-o', outpath, '-n', '1', '-t', 'lat',
75 suri(bucket_uri)]) 89 suri(bucket_uri)])
76 self.RunGsUtil(['perfdiag', '-i', outpath]) 90 self.RunGsUtil(['perfdiag', '-i', outpath])
77 91
78 def test_invalid_size(self): 92 def test_invalid_size(self):
79 stderr = self.RunGsUtil( 93 stderr = self.RunGsUtil(
80 ['perfdiag', '-n', '1', '-s', 'foo', '-t', 'wthru', 'gs://foobar'], 94 ['perfdiag', '-n', '1', '-s', 'foo', '-t', 'wthru', 'gs://foobar'],
81 expected_status=1, return_stderr=True) 95 expected_status=1, return_stderr=True)
82 self.assertIn('Invalid -s', stderr) 96 self.assertIn('Invalid -s', stderr)
83 97
84 def test_toobig_size(self): 98 def test_toobig_size(self):
85 stderr = self.RunGsUtil( 99 stderr = self.RunGsUtil(
86 ['perfdiag', '-n', '1', '-s', '3pb', '-t', 'wthru', 'gs://foobar'], 100 ['perfdiag', '-n', '1', '-s', '3pb', '-t', 'wthru', 'gs://foobar'],
87 expected_status=1, return_stderr=True) 101 expected_status=1, return_stderr=True)
88 self.assertIn('Maximum throughput file size', stderr) 102 self.assertIn('Maximum throughput file size', stderr)
103
104 def test_listing(self):
105 bucket_uri = self.CreateBucket()
106 stdout = self.RunGsUtil(
107 ['perfdiag', '-n', '1', '-t', 'list', suri(bucket_uri)],
108 return_stdout=True)
109 self.assertIn('Number of listing calls made:', stdout)
OLDNEW
« no previous file with comments | « gslib/tests/test_parallelism_framework.py ('k') | gslib/tests/test_plurality_checkable_iterator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698