Fixes Storage-Policy AttributeError in proxy
Closes-Bug: #1989140 Change-Id: I99e4a1daf550d492b28c8a82c0b7a81b2f73dffe
This commit is contained in:
parent
d8af3d7a0d
commit
9bdb77a388
@ -1840,8 +1840,7 @@ class Controller(object):
|
||||
path_env['PATH_INFO'] = "/v1/%s/%s" % (
|
||||
str_to_wsgi(account), str_to_wsgi(container))
|
||||
info = get_container_info(path_env, self.app)
|
||||
if not info or not is_success(info.get('status')):
|
||||
info = headers_to_container_info({}, 0)
|
||||
if not is_success(info.get('status')):
|
||||
info['partition'] = None
|
||||
info['nodes'] = None
|
||||
else:
|
||||
|
@ -834,6 +834,23 @@ class TestFuncs(BaseTest):
|
||||
self.assertEqual(incomplete_expected,
|
||||
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):
|
||||
base = Controller(self.app)
|
||||
base.account_name = 'a'
|
||||
@ -844,7 +861,7 @@ class TestFuncs(BaseTest):
|
||||
container_info = \
|
||||
base.container_info(base.account_name,
|
||||
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):
|
||||
resp = headers_to_account_info({}, 404)
|
||||
|
@ -7415,6 +7415,43 @@ class BaseTestECObjectController(BaseTestObjectController):
|
||||
self.assertEqual(len(error_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):
|
||||
# sanity
|
||||
self.assertEqual('erasure_coding', self.ec_policy.policy_type)
|
||||
|
Loading…
Reference in New Issue
Block a user