Merge "py3: port object controller in proxy"
This commit is contained in:
commit
80b58553e8
@ -1739,7 +1739,7 @@ class Controller(object):
|
|||||||
response.append(resp)
|
response.append(resp)
|
||||||
statuses.append(resp[0])
|
statuses.append(resp[0])
|
||||||
while len(response) < node_number:
|
while len(response) < node_number:
|
||||||
response.append((HTTP_SERVICE_UNAVAILABLE, '', '', ''))
|
response.append((HTTP_SERVICE_UNAVAILABLE, '', '', b''))
|
||||||
statuses, reasons, resp_headers, bodies = zip(*response)
|
statuses, reasons, resp_headers, bodies = zip(*response)
|
||||||
return self.best_response(req, statuses, reasons, bodies,
|
return self.best_response(req, statuses, reasons, bodies,
|
||||||
'%s %s' % (self.server_type, req.method),
|
'%s %s' % (self.server_type, req.method),
|
||||||
|
@ -1563,7 +1563,7 @@ def segment_range_to_fragment_range(segment_start, segment_end, segment_size,
|
|||||||
|
|
||||||
# the index of the first byte of the first fragment
|
# the index of the first byte of the first fragment
|
||||||
fragment_start = ((
|
fragment_start = ((
|
||||||
segment_start / segment_size * fragment_size)
|
segment_start // segment_size * fragment_size)
|
||||||
if segment_start is not None else None)
|
if segment_start is not None else None)
|
||||||
# the index of the last byte of the last fragment
|
# the index of the last byte of the last fragment
|
||||||
fragment_end = (
|
fragment_end = (
|
||||||
@ -1572,13 +1572,13 @@ def segment_range_to_fragment_range(segment_start, segment_end, segment_size,
|
|||||||
# range unbounded on the left; no -1 since we're
|
# range unbounded on the left; no -1 since we're
|
||||||
# asking for the last N bytes, not to have a
|
# asking for the last N bytes, not to have a
|
||||||
# particular byte be the last one
|
# particular byte be the last one
|
||||||
((segment_end + 1) / segment_size
|
((segment_end + 1) // segment_size
|
||||||
* fragment_size) if segment_start is None else
|
* fragment_size) if segment_start is None else
|
||||||
# range bounded on both sides; the -1 is because the
|
# range bounded on both sides; the -1 is because the
|
||||||
# rest of the expression computes the length of the
|
# rest of the expression computes the length of the
|
||||||
# fragment, and a range of N bytes starts at index M
|
# fragment, and a range of N bytes starts at index M
|
||||||
# and ends at M + N - 1.
|
# and ends at M + N - 1.
|
||||||
((segment_end + 1) / segment_size * fragment_size) - 1)
|
((segment_end + 1) // segment_size * fragment_size) - 1)
|
||||||
return (fragment_start, fragment_end)
|
return (fragment_start, fragment_end)
|
||||||
|
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ class Application(object):
|
|||||||
except (Exception, Timeout):
|
except (Exception, Timeout):
|
||||||
start_response('500 Server Error',
|
start_response('500 Server Error',
|
||||||
[('Content-Type', 'text/plain')])
|
[('Content-Type', 'text/plain')])
|
||||||
return ['Internal server error.\n']
|
return [b'Internal server error.\n']
|
||||||
|
|
||||||
def update_request(self, req):
|
def update_request(self, req):
|
||||||
if 'x-storage-token' in req.headers and \
|
if 'x-storage-token' in req.headers and \
|
||||||
|
@ -1055,10 +1055,10 @@ def fake_http_connect(*code_iter, **kwargs):
|
|||||||
expect_headers = next(expect_headers_iter)
|
expect_headers = next(expect_headers_iter)
|
||||||
timestamp = next(timestamps_iter)
|
timestamp = next(timestamps_iter)
|
||||||
|
|
||||||
if status <= 0:
|
if isinstance(status, int) and status <= 0:
|
||||||
raise HTTPException()
|
raise HTTPException()
|
||||||
if body_iter is None:
|
if body_iter is None:
|
||||||
body = static_body or ''
|
body = static_body or b''
|
||||||
else:
|
else:
|
||||||
body = next(body_iter)
|
body = next(body_iter)
|
||||||
return FakeConn(status, etag, body=body, timestamp=timestamp,
|
return FakeConn(status, etag, body=body, timestamp=timestamp,
|
||||||
@ -1143,7 +1143,7 @@ def requires_o_tmpfile_support_in_tmp(func):
|
|||||||
|
|
||||||
class StubResponse(object):
|
class StubResponse(object):
|
||||||
|
|
||||||
def __init__(self, status, body='', headers=None, frag_index=None):
|
def __init__(self, status, body=b'', headers=None, frag_index=None):
|
||||||
self.status = status
|
self.status = status
|
||||||
self.body = body
|
self.body = body
|
||||||
self.readable = BytesIO(body)
|
self.readable = BytesIO(body)
|
||||||
@ -1198,7 +1198,7 @@ def encode_frag_archive_bodies(policy, body):
|
|||||||
def make_ec_object_stub(test_body, policy, timestamp):
|
def make_ec_object_stub(test_body, policy, timestamp):
|
||||||
segment_size = policy.ec_segment_size
|
segment_size = policy.ec_segment_size
|
||||||
test_body = test_body or (
|
test_body = test_body or (
|
||||||
'test' * segment_size)[:-random.randint(1, 1000)]
|
b'test' * segment_size)[:-random.randint(1, 1000)]
|
||||||
timestamp = timestamp or utils.Timestamp.now()
|
timestamp = timestamp or utils.Timestamp.now()
|
||||||
etag = md5(test_body).hexdigest()
|
etag = md5(test_body).hexdigest()
|
||||||
ec_archive_bodies = encode_frag_archive_bodies(policy, test_body)
|
ec_archive_bodies = encode_frag_archive_bodies(policy, test_body)
|
||||||
|
File diff suppressed because it is too large
Load Diff
3
tox.ini
3
tox.ini
@ -87,7 +87,8 @@ commands =
|
|||||||
test/unit/container/test_sync_store.py \
|
test/unit/container/test_sync_store.py \
|
||||||
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_info.py}
|
test/unit/proxy/controllers/test_info.py \
|
||||||
|
test/unit/proxy/controllers/test_obj.py}
|
||||||
|
|
||||||
[testenv:py36]
|
[testenv:py36]
|
||||||
commands = {[testenv:py35]commands}
|
commands = {[testenv:py35]commands}
|
||||||
|
Loading…
Reference in New Issue
Block a user