Made failed account autocreate raise exception to cause 5xx.
This commit is contained in:
parent
bb48838404
commit
818c4faa73
@ -394,7 +394,8 @@ class Controller(object):
|
|||||||
resp = self.make_requests(Request.blank('/v1' + path),
|
resp = self.make_requests(Request.blank('/v1' + path),
|
||||||
self.app.account_ring, partition, 'PUT',
|
self.app.account_ring, partition, 'PUT',
|
||||||
path, [headers] * len(nodes))
|
path, [headers] * len(nodes))
|
||||||
if resp.status_int // 100 == 2:
|
if resp.status_int // 100 != 2:
|
||||||
|
raise Exception('Could not autocreate account %r' % path)
|
||||||
result_code = 200
|
result_code = 200
|
||||||
if self.app.memcache and result_code in (200, 404):
|
if self.app.memcache and result_code in (200, 404):
|
||||||
if result_code == 200:
|
if result_code == 200:
|
||||||
|
@ -395,24 +395,46 @@ class TestController(unittest.TestCase):
|
|||||||
|
|
||||||
def test_account_info_account_autocreate(self):
|
def test_account_info_account_autocreate(self):
|
||||||
with save_globals():
|
with save_globals():
|
||||||
|
self.memcache.store = {}
|
||||||
proxy_server.http_connect = \
|
proxy_server.http_connect = \
|
||||||
fake_http_connect(404, 404, 404, 201, 201, 201)
|
fake_http_connect(404, 404, 404, 201, 201, 201)
|
||||||
partition, nodes = \
|
partition, nodes = \
|
||||||
self.controller.account_info(self.account, autocreate=False)
|
self.controller.account_info(self.account, autocreate=False)
|
||||||
self.check_account_info_return(partition, nodes, is_none=True)
|
self.check_account_info_return(partition, nodes, is_none=True)
|
||||||
|
|
||||||
|
self.memcache.store = {}
|
||||||
proxy_server.http_connect = \
|
proxy_server.http_connect = \
|
||||||
fake_http_connect(404, 404, 404, 201, 201, 201)
|
fake_http_connect(404, 404, 404, 201, 201, 201)
|
||||||
partition, nodes = \
|
partition, nodes = \
|
||||||
self.controller.account_info(self.account)
|
self.controller.account_info(self.account)
|
||||||
self.check_account_info_return(partition, nodes, is_none=True)
|
self.check_account_info_return(partition, nodes, is_none=True)
|
||||||
|
|
||||||
|
self.memcache.store = {}
|
||||||
proxy_server.http_connect = \
|
proxy_server.http_connect = \
|
||||||
fake_http_connect(404, 404, 404, 201, 201, 201)
|
fake_http_connect(404, 404, 404, 201, 201, 201)
|
||||||
partition, nodes = \
|
partition, nodes = \
|
||||||
self.controller.account_info(self.account, autocreate=True)
|
self.controller.account_info(self.account, autocreate=True)
|
||||||
self.check_account_info_return(partition, nodes)
|
self.check_account_info_return(partition, nodes)
|
||||||
|
|
||||||
|
self.memcache.store = {}
|
||||||
|
proxy_server.http_connect = \
|
||||||
|
fake_http_connect(404, 404, 404, 503, 201, 201)
|
||||||
|
partition, nodes = \
|
||||||
|
self.controller.account_info(self.account, autocreate=True)
|
||||||
|
self.check_account_info_return(partition, nodes)
|
||||||
|
|
||||||
|
self.memcache.store = {}
|
||||||
|
proxy_server.http_connect = \
|
||||||
|
fake_http_connect(404, 404, 404, 503, 201, 503)
|
||||||
|
exc = None
|
||||||
|
try:
|
||||||
|
partition, nodes = \
|
||||||
|
self.controller.account_info(self.account, autocreate=True)
|
||||||
|
except Exception, err:
|
||||||
|
exc = err
|
||||||
|
self.assertEquals(str(exc),
|
||||||
|
"Could not autocreate account '/some_account'")
|
||||||
|
|
||||||
def check_container_info_return(self, ret, is_none=False):
|
def check_container_info_return(self, ret, is_none=False):
|
||||||
if is_none:
|
if is_none:
|
||||||
partition, nodes, read_acl, write_acl = None, None, None, None
|
partition, nodes, read_acl, write_acl = None, None, None, None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user