Merge "Fixes Storage-Policy AttributeError in proxy"
This commit is contained in:
commit
ce184edd79
@ -1840,8 +1840,7 @@ class Controller(object):
|
|||||||
path_env['PATH_INFO'] = "/v1/%s/%s" % (
|
path_env['PATH_INFO'] = "/v1/%s/%s" % (
|
||||||
str_to_wsgi(account), str_to_wsgi(container))
|
str_to_wsgi(account), str_to_wsgi(container))
|
||||||
info = get_container_info(path_env, self.app)
|
info = get_container_info(path_env, self.app)
|
||||||
if not info or not is_success(info.get('status')):
|
if not is_success(info.get('status')):
|
||||||
info = headers_to_container_info({}, 0)
|
|
||||||
info['partition'] = None
|
info['partition'] = None
|
||||||
info['nodes'] = None
|
info['nodes'] = None
|
||||||
else:
|
else:
|
||||||
|
@ -834,6 +834,23 @@ class TestFuncs(BaseTest):
|
|||||||
self.assertEqual(incomplete_expected,
|
self.assertEqual(incomplete_expected,
|
||||||
headers_from_container_info(incomplete_info))
|
headers_from_container_info(incomplete_info))
|
||||||
|
|
||||||
|
def test_container_info_preserves_storage_policy(self):
|
||||||
|
base = Controller(self.app)
|
||||||
|
base.account_name = 'a'
|
||||||
|
base.container_name = 'c'
|
||||||
|
|
||||||
|
fake_info = {'status': 404, 'storage_policy': 1}
|
||||||
|
|
||||||
|
with mock.patch('swift.proxy.controllers.base.'
|
||||||
|
'get_container_info', return_value=fake_info):
|
||||||
|
container_info = \
|
||||||
|
base.container_info(base.account_name, base.container_name,
|
||||||
|
Request.blank('/'))
|
||||||
|
self.assertEqual(container_info['status'], 404)
|
||||||
|
self.assertEqual(container_info['storage_policy'], 1)
|
||||||
|
self.assertEqual(container_info['partition'], None)
|
||||||
|
self.assertEqual(container_info['nodes'], None)
|
||||||
|
|
||||||
def test_container_info_needs_req(self):
|
def test_container_info_needs_req(self):
|
||||||
base = Controller(self.app)
|
base = Controller(self.app)
|
||||||
base.account_name = 'a'
|
base.account_name = 'a'
|
||||||
@ -844,7 +861,7 @@ class TestFuncs(BaseTest):
|
|||||||
container_info = \
|
container_info = \
|
||||||
base.container_info(base.account_name,
|
base.container_info(base.account_name,
|
||||||
base.container_name, Request.blank('/'))
|
base.container_name, Request.blank('/'))
|
||||||
self.assertEqual(container_info['status'], 0)
|
self.assertEqual(container_info['status'], 503)
|
||||||
|
|
||||||
def test_headers_to_account_info_missing(self):
|
def test_headers_to_account_info_missing(self):
|
||||||
resp = headers_to_account_info({}, 404)
|
resp = headers_to_account_info({}, 404)
|
||||||
|
@ -7415,6 +7415,43 @@ class BaseTestECObjectController(BaseTestObjectController):
|
|||||||
self.assertEqual(len(error_lines), 0) # sanity
|
self.assertEqual(len(error_lines), 0) # sanity
|
||||||
self.assertEqual(len(warn_lines), 0) # sanity
|
self.assertEqual(len(warn_lines), 0) # sanity
|
||||||
|
|
||||||
|
def test_GET_ec_deleted(self):
|
||||||
|
prolis = _test_sockets[0]
|
||||||
|
prosrv = _test_servers[0]
|
||||||
|
|
||||||
|
container_name = 'ec_deleted'
|
||||||
|
self.put_container(self.ec_policy.name, container_name)
|
||||||
|
|
||||||
|
# delete container
|
||||||
|
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||||
|
fd = sock.makefile('rwb')
|
||||||
|
fd.write(('DELETE /v1/a/%s HTTP/1.1\r\n'
|
||||||
|
'Host: localhost\r\n'
|
||||||
|
'Connection: close\r\n'
|
||||||
|
'\r\n' % container_name).encode('ascii'))
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = b'HTTP/1.1 20'
|
||||||
|
self.assertEqual(headers[:len(exp)], exp)
|
||||||
|
|
||||||
|
# download from deleted container
|
||||||
|
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||||
|
fd = sock.makefile('rwb')
|
||||||
|
fd.write(('GET /v1/a/%s/no-object-there HTTP/1.1\r\n'
|
||||||
|
'Host: localhost\r\n'
|
||||||
|
'Connection: close\r\n'
|
||||||
|
'X-Storage-Token: t\r\n'
|
||||||
|
'\r\n' % container_name).encode('ascii'))
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = b'HTTP/1.1 404'
|
||||||
|
self.assertEqual(headers[:len(exp)], exp)
|
||||||
|
|
||||||
|
error_lines = prosrv.logger.get_lines_for_level('error')
|
||||||
|
warn_lines = prosrv.logger.get_lines_for_level('warning')
|
||||||
|
self.assertEqual(len(error_lines), 0) # sanity
|
||||||
|
self.assertEqual(len(warn_lines), 0) # sanity
|
||||||
|
|
||||||
def test_conditional_GET_ec(self):
|
def test_conditional_GET_ec(self):
|
||||||
# sanity
|
# sanity
|
||||||
self.assertEqual('erasure_coding', self.ec_policy.policy_type)
|
self.assertEqual('erasure_coding', self.ec_policy.policy_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user