py3: port proxy container controller
Change-Id: Id74a93f10bc5c641d62141af33bef68e503f7e04
This commit is contained in:
@@ -17,6 +17,7 @@ from swift import gettext_ as _
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from six.moves.urllib.parse import unquote
|
from six.moves.urllib.parse import unquote
|
||||||
|
|
||||||
from swift.common.utils import public, csv_append, Timestamp, \
|
from swift.common.utils import public, csv_append, Timestamp, \
|
||||||
config_true_value, ShardRange
|
config_true_value, ShardRange
|
||||||
from swift.common.constraints import check_metadata, CONTAINER_LISTING_LIMIT
|
from swift.common.constraints import check_metadata, CONTAINER_LISTING_LIMIT
|
||||||
@@ -26,7 +27,7 @@ from swift.proxy.controllers.base import Controller, delay_denial, \
|
|||||||
cors_validation, set_info_cache, clear_info_cache
|
cors_validation, set_info_cache, clear_info_cache
|
||||||
from swift.common.storage_policy import POLICIES
|
from swift.common.storage_policy import POLICIES
|
||||||
from swift.common.swob import HTTPBadRequest, HTTPForbidden, \
|
from swift.common.swob import HTTPBadRequest, HTTPForbidden, \
|
||||||
HTTPNotFound, HTTPServiceUnavailable
|
HTTPNotFound, HTTPServiceUnavailable, str_to_wsgi, wsgi_to_bytes
|
||||||
|
|
||||||
|
|
||||||
class ContainerController(Controller):
|
class ContainerController(Controller):
|
||||||
@@ -187,9 +188,9 @@ class ContainerController(Controller):
|
|||||||
if end_marker and end_marker in shard_range:
|
if end_marker and end_marker in shard_range:
|
||||||
params['end_marker'] = end_marker
|
params['end_marker'] = end_marker
|
||||||
elif reverse:
|
elif reverse:
|
||||||
params['end_marker'] = shard_range.lower_str
|
params['end_marker'] = str_to_wsgi(shard_range.lower_str)
|
||||||
else:
|
else:
|
||||||
params['end_marker'] = shard_range.end_marker
|
params['end_marker'] = str_to_wsgi(shard_range.end_marker)
|
||||||
|
|
||||||
if (shard_range.account == self.account_name and
|
if (shard_range.account == self.account_name and
|
||||||
shard_range.container == self.container_name):
|
shard_range.container == self.container_name):
|
||||||
@@ -212,11 +213,13 @@ class ContainerController(Controller):
|
|||||||
|
|
||||||
if limit <= 0:
|
if limit <= 0:
|
||||||
break
|
break
|
||||||
elif (end_marker and reverse and
|
if (end_marker and reverse and
|
||||||
end_marker >= objects[-1]['name'].encode('utf-8')):
|
(wsgi_to_bytes(end_marker) >=
|
||||||
|
objects[-1]['name'].encode('utf-8'))):
|
||||||
break
|
break
|
||||||
elif (end_marker and not reverse and
|
if (end_marker and not reverse and
|
||||||
end_marker <= objects[-1]['name'].encode('utf-8')):
|
(wsgi_to_bytes(end_marker) <=
|
||||||
|
objects[-1]['name'].encode('utf-8'))):
|
||||||
break
|
break
|
||||||
|
|
||||||
resp.body = json.dumps(objects).encode('ascii')
|
resp.body = json.dumps(objects).encode('ascii')
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class FakeResponse(object):
|
|||||||
|
|
||||||
base_headers = {}
|
base_headers = {}
|
||||||
|
|
||||||
def __init__(self, status_int=200, headers=None, body=''):
|
def __init__(self, status_int=200, headers=None, body=b''):
|
||||||
self.status_int = status_int
|
self.status_int = status_int
|
||||||
self._headers = headers or {}
|
self._headers = headers or {}
|
||||||
self.body = body
|
self.body = body
|
||||||
|
|||||||
@@ -450,7 +450,8 @@ class TestContainerController(TestRingBase):
|
|||||||
self.assertLess(name(prev), name(next_))
|
self.assertLess(name(prev), name(next_))
|
||||||
container_path = '/v1/a/c' + query_string
|
container_path = '/v1/a/c' + query_string
|
||||||
codes = (resp[0] for resp in mock_responses)
|
codes = (resp[0] for resp in mock_responses)
|
||||||
bodies = iter([json.dumps(resp[1]) for resp in mock_responses])
|
bodies = iter([json.dumps(resp[1]).encode('ascii')
|
||||||
|
for resp in mock_responses])
|
||||||
exp_headers = [resp[2] for resp in mock_responses]
|
exp_headers = [resp[2] for resp in mock_responses]
|
||||||
request = Request.blank(container_path)
|
request = Request.blank(container_path)
|
||||||
with mocked_http_conn(
|
with mocked_http_conn(
|
||||||
@@ -1010,7 +1011,7 @@ class TestContainerController(TestRingBase):
|
|||||||
'X-Backend-Sharding-State': 'unsharded',
|
'X-Backend-Sharding-State': 'unsharded',
|
||||||
'X-Container-Object-Count': 0,
|
'X-Container-Object-Count': 0,
|
||||||
'X-Container-Bytes-Used': 0,
|
'X-Container-Bytes-Used': 0,
|
||||||
'X-Container-Meta-Flavour': 'flavour%d' % i,
|
'X-Container-Meta-Flavour': 'flavour',
|
||||||
'X-Backend-Storage-Policy-Index': 0}
|
'X-Backend-Storage-Policy-Index': 0}
|
||||||
|
|
||||||
# empty first shard range
|
# empty first shard range
|
||||||
|
|||||||
1
tox.ini
1
tox.ini
@@ -80,6 +80,7 @@ commands =
|
|||||||
test/unit/obj/test_replicator.py \
|
test/unit/obj/test_replicator.py \
|
||||||
test/unit/obj/test_server.py \
|
test/unit/obj/test_server.py \
|
||||||
test/unit/proxy/controllers/test_base.py \
|
test/unit/proxy/controllers/test_base.py \
|
||||||
|
test/unit/proxy/controllers/test_container.py \
|
||||||
test/unit/proxy/controllers/test_info.py \
|
test/unit/proxy/controllers/test_info.py \
|
||||||
test/unit/proxy/controllers/test_obj.py}
|
test/unit/proxy/controllers/test_obj.py}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user