Merge "Retuen a reasonable response to client."
This commit is contained in:
commit
4f0226e4f8
@ -439,7 +439,9 @@ class Controller(object):
|
||||
self.app.account_ring, partition, 'PUT',
|
||||
path, [headers] * len(nodes))
|
||||
if not is_success(resp.status_int):
|
||||
raise Exception('Could not autocreate account %r' % path)
|
||||
self.app.logger.warning('Could not autocreate account %r' % \
|
||||
path)
|
||||
return None, None, None
|
||||
result_code = HTTP_OK
|
||||
if self.app.memcache and result_code in (HTTP_OK, HTTP_NOT_FOUND):
|
||||
if result_code == HTTP_OK:
|
||||
@ -1808,8 +1810,9 @@ class AccountController(Controller):
|
||||
self.app.account_ring, partition, 'PUT',
|
||||
'/' + self.account_name, [headers] * len(nodes))
|
||||
if not is_success(resp.status_int):
|
||||
raise Exception('Could not autocreate account %r' %
|
||||
self.account_name)
|
||||
self.app.logger.warning('Could not autocreate account %r' %
|
||||
self.account_name)
|
||||
return resp
|
||||
resp = self.GETorHEAD_base(req, _('Account'), partition, nodes,
|
||||
req.path_info.rstrip('/'), len(nodes))
|
||||
self.app.logger.timing_since('%s.timing' % (stats_type,), start_time)
|
||||
@ -1876,8 +1879,9 @@ class AccountController(Controller):
|
||||
self.app.account_ring, account_partition, 'PUT',
|
||||
'/' + self.account_name, [headers] * len(accounts))
|
||||
if not is_success(resp.status_int):
|
||||
raise Exception('Could not autocreate account %r' %
|
||||
self.account_name)
|
||||
self.app.logger.warning('Could not autocreate account %r' %
|
||||
self.account_name)
|
||||
return resp
|
||||
self.app.logger.timing_since('POST.timing', start_time)
|
||||
return resp
|
||||
|
||||
|
@ -450,13 +450,28 @@ class TestController(unittest.TestCase):
|
||||
proxy_server.http_connect = \
|
||||
fake_http_connect(404, 404, 404, 503, 201, 503)
|
||||
exc = None
|
||||
try:
|
||||
partition, nodes, count = \
|
||||
self.controller.account_info(self.account, autocreate=True)
|
||||
except Exception, err:
|
||||
exc = err
|
||||
self.assertEquals(str(exc),
|
||||
"Could not autocreate account '/some_account'")
|
||||
partition, nodes, count = \
|
||||
self.controller.account_info(self.account, autocreate=True)
|
||||
self.check_account_info_return(partition, nodes, is_none=True)
|
||||
self.assertEquals(None, count)
|
||||
|
||||
self.memcache.store = {}
|
||||
proxy_server.http_connect = \
|
||||
fake_http_connect(404, 404, 404, 403, 403, 403)
|
||||
exc = None
|
||||
partition, nodes, count = \
|
||||
self.controller.account_info(self.account, autocreate=True)
|
||||
self.check_account_info_return(partition, nodes, is_none=True)
|
||||
self.assertEquals(None, count)
|
||||
|
||||
self.memcache.store = {}
|
||||
proxy_server.http_connect = \
|
||||
fake_http_connect(404, 404, 404, 409, 409, 409)
|
||||
exc = None
|
||||
partition, nodes, count = \
|
||||
self.controller.account_info(self.account, autocreate=True)
|
||||
self.check_account_info_return(partition, nodes, is_none=True)
|
||||
self.assertEquals(None, count)
|
||||
|
||||
def check_container_info_return(self, ret, is_none=False):
|
||||
if is_none:
|
||||
@ -3812,6 +3827,11 @@ class TestAccountController(unittest.TestCase):
|
||||
controller.app.account_autocreate = True
|
||||
self.assert_status_map(controller.GET,
|
||||
(404, 404, 404, 201, 201, 201, 204), 204)
|
||||
self.assert_status_map(controller.GET,
|
||||
(404, 404, 404, 403, 403, 403, 403), 403)
|
||||
self.assert_status_map(controller.GET,
|
||||
(404, 404, 404, 409, 409, 409, 409), 409)
|
||||
|
||||
|
||||
def test_HEAD(self):
|
||||
with save_globals():
|
||||
@ -3840,6 +3860,10 @@ class TestAccountController(unittest.TestCase):
|
||||
controller.app.account_autocreate = True
|
||||
self.assert_status_map(controller.HEAD,
|
||||
(404, 404, 404, 201, 201, 201, 204), 204)
|
||||
self.assert_status_map(controller.HEAD,
|
||||
(404, 404, 404, 403, 403, 403, 403), 403)
|
||||
self.assert_status_map(controller.HEAD,
|
||||
(404, 404, 404, 409, 409, 409, 409), 409)
|
||||
|
||||
def test_POST_autocreate(self):
|
||||
with save_globals():
|
||||
@ -3850,6 +3874,10 @@ class TestAccountController(unittest.TestCase):
|
||||
controller.app.account_autocreate = True
|
||||
self.assert_status_map(controller.POST,
|
||||
(404, 404, 404, 201, 201, 201), 201)
|
||||
self.assert_status_map(controller.POST,
|
||||
(404, 404, 404, 403, 403, 403, 403), 403)
|
||||
self.assert_status_map(controller.POST,
|
||||
(404, 404, 404, 409, 409, 409, 409), 409)
|
||||
|
||||
def test_connection_refused(self):
|
||||
self.app.account_ring.get_nodes('account')
|
||||
|
Loading…
x
Reference in New Issue
Block a user