sharding: Tolerate blank limits when listing

Otherwise, we can 500 with

   ValueError: invalid literal for int() with base 10: ''

Change-Id: I35614aa4b42e61d97929579dcb16f7dfc9fef96f
This commit is contained in:
Tim Burke 2019-12-19 22:27:27 -08:00
parent 5e9d5d101a
commit d246bf20ed
2 changed files with 6 additions and 5 deletions

View File

@ -159,7 +159,7 @@ class ContainerController(Controller):
return resp
objects = []
req_limit = int(req.params.get('limit', CONTAINER_LISTING_LIMIT))
req_limit = int(req.params.get('limit') or CONTAINER_LISTING_LIMIT)
params = req.params.copy()
params.pop('states', None)
req.headers.pop('X-Backend-Record-Type', None)

View File

@ -640,7 +640,7 @@ class TestContainerController(TestRingBase):
self.check_response(resp, root_resp_hdrs,
expected_objects=expected_objects)
# GET all objects in reverse
# GET all objects in reverse and *blank* limit
mock_responses = [
# status, body, headers
(200, list(reversed(sr_dicts)), root_shard_resp_hdrs),
@ -653,7 +653,7 @@ class TestContainerController(TestRingBase):
expected_requests = [
# path, headers, params
('a/c', {'X-Backend-Record-Type': 'auto'},
dict(states='listing', reverse='true')),
dict(states='listing', reverse='true', limit='')),
(wsgi_quote(str_to_wsgi(shard_ranges[4].name)),
{'X-Backend-Record-Type': 'auto'},
dict(marker='', end_marker='\xf0\x9f\x8c\xb4', states='listing',
@ -683,7 +683,8 @@ class TestContainerController(TestRingBase):
resp = self._check_GET_shard_listing(
mock_responses, list(reversed(expected_objects)),
expected_requests, query_string='?reverse=true', reverse=True)
expected_requests, query_string='?reverse=true&limit=',
reverse=True)
# root object count will overridden by actual length of listing
self.check_response(resp, root_resp_hdrs,
expected_objects=expected_objects)
@ -831,7 +832,7 @@ class TestContainerController(TestRingBase):
% (marker, end_marker, limit))
self.check_response(resp, root_resp_hdrs)
# reverse with marker, end_marker
# reverse with marker, end_marker, and limit
expected_objects.reverse()
mock_responses = [
(200, sr_dicts[3:4], root_shard_resp_hdrs),