Skip to content

Commit

Permalink
Do not need to set max-keys, max-uploads and max-parts (#819)
Browse files Browse the repository at this point in the history
MinIO server supports now 10k elements in the list output,
there is no reason for client to limit itself let the
default set of keys be returned and limited by server
implementation
  • Loading branch information
harshavardhana authored and kannappanr committed Nov 1, 2019
1 parent 1c2eda0 commit d5cd5da
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
3 changes: 0 additions & 3 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,6 @@ def list_objects(self, bucket_name, prefix='', recursive=False):

# Initialize query parameters.
query = {
'max-keys': '1000',
'prefix': prefix
}

Expand Down Expand Up @@ -1218,7 +1217,6 @@ def _list_incomplete_uploads(self, bucket_name, prefix='',
# Initialize query parameters.
query = {
'uploads': '',
'max-uploads': '1000',
'prefix': prefix
}

Expand Down Expand Up @@ -1275,7 +1273,6 @@ def _list_object_parts(self, bucket_name, object_name, upload_id):

query = {
'uploadId': upload_id,
'max-parts': '1000'
}

is_truncated = True
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/list_incomplete_uploads_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_empty_list_uploads_test(self, mock_connection):
mock_connection.return_value = mock_server
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/?max-uploads=1000&prefix=&uploads=',
'https://localhost:9000/bucket/?prefix=&uploads=',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data))
client = Minio('localhost:9000')
upload_iter = client._list_incomplete_uploads('bucket', '', True, False)
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_list_uploads_works(self, mock_connection):
mock_connection.return_value = mock_server
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/?delimiter=%2F&max-uploads=1000&prefix=&uploads=',
'https://localhost:9000/bucket/?delimiter=%2F&prefix=&uploads=',
{'User-Agent': _DEFAULT_USER_AGENT},
200, content=mock_data))

Expand Down Expand Up @@ -203,7 +203,7 @@ def test_list_multipart_uploads_works(self, mock_connection):
mock_connection.return_value = mock_server
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/?max-uploads=1000&prefix=&uploads=',
'https://localhost:9000/bucket/?prefix=&uploads=',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data1))

client = Minio('localhost:9000')
Expand All @@ -213,7 +213,7 @@ def test_list_multipart_uploads_works(self, mock_connection):
mock_server.mock_add_request(MockResponse('GET',
'https://localhost:9000/bucket/?'
'key-marker=keymarker&'
'max-uploads=1000&prefix=&'
'prefix=&'
'upload-id-marker=uploadidmarker&uploads=',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data2))
uploads.append(upload)
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/list_objects_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_empty_list_objects_works(self, mock_connection):
mock_server = MockConnection()
mock_connection.return_value = mock_server
mock_server.mock_add_request(MockResponse('GET',
'https://localhost:9000/bucket/?max-keys=1000&prefix=',
'https://localhost:9000/bucket/?prefix=',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data))
client = Minio('localhost:9000')
bucket_iter = client.list_objects('bucket', recursive=True)
Expand Down Expand Up @@ -87,15 +87,15 @@ def test_list_objects_works(self, mock_connection):
mock_server = MockConnection()
mock_connection.return_value = mock_server
mock_server.mock_add_request(MockResponse('GET',
'https://localhost:9000/bucket/?delimiter=%2F&max-keys=1000&prefix=',
'https://localhost:9000/bucket/?delimiter=%2F&prefix=',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data))
client = Minio('localhost:9000')
bucket_iter = client.list_objects('bucket')
buckets = []
for bucket in bucket_iter:
# cause an xml exception and fail if we try retrieving again
mock_server.mock_add_request(MockResponse('GET',
'https://localhost:9000/bucket/?delimiter=%2F&max-keys=1000&prefix=',
'https://localhost:9000/bucket/?delimiter=%2F&prefix=',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=''))
buckets.append(bucket)

Expand Down Expand Up @@ -172,13 +172,13 @@ def test_list_objects_works_well(self, mock_connection):
mock_server = MockConnection()
mock_connection.return_value = mock_server
mock_server.mock_add_request(MockResponse('GET',
'https://localhost:9000/bucket/?max-keys=1000&prefix=',
'https://localhost:9000/bucket/?prefix=',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data1))
client = Minio('localhost:9000')
bucket_iter = client.list_objects('bucket', recursive=True)
buckets = []
for bucket in bucket_iter:
url = 'https://localhost:9000/bucket/?marker=marker&max-keys=1000&prefix='
url = 'https://localhost:9000/bucket/?marker=marker&prefix='
mock_server.mock_add_request(MockResponse('GET', url,
{'User-Agent': _DEFAULT_USER_AGENT}, 200,
content=mock_data2))
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/list_uploaded_parts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_empty_list_parts_works(self, mock_connection):
mock_connection.return_value = mock_server
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/key?max-parts=1000&uploadId=upload_id',
'https://localhost:9000/bucket/key?uploadId=upload_id',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data))

client = Minio('localhost:9000')
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_list_object_parts_works(self, mock_connection):
mock_server = MockConnection()
mock_connection.return_value = mock_server
mock_server.mock_add_request(MockResponse('GET',
'https://localhost:9000/bucket/key?max-parts=1000&uploadId=upload_id',
'https://localhost:9000/bucket/key?uploadId=upload_id',
{'User-Agent': _DEFAULT_USER_AGENT}, 200,
content=mock_data))
client = Minio('localhost:9000')
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_list_objects_works(self, mock_connection):
mock_connection.return_value = mock_server
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/key?max-parts=1000&uploadId=upload_id',
'https://localhost:9000/bucket/key?uploadId=upload_id',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data1))


Expand All @@ -190,7 +190,7 @@ def test_list_objects_works(self, mock_connection):
for part in part_iter:
mock_server.mock_add_request(
MockResponse('GET',
'https://localhost:9000/bucket/key?max-parts=1000&part-number-marker=2&uploadId=upload_id',
'https://localhost:9000/bucket/key?part-number-marker=2&uploadId=upload_id',
{'User-Agent': _DEFAULT_USER_AGENT}, 200, content=mock_data2))
parts.append(part)
eq_(4, len(parts))

0 comments on commit d5cd5da

Please sign in to comment.