direct_client not passing args between some functions
The call to _get_direct_account_container in direct_get_account has several of its args =None instead of set to the value passed to direct_get_account. The same applies to _get_direct_account_container in direct_get_container. The direct_get_container is only called by the account-reaper and this bug will have limited impact on it. The marker, maintained in reap_container, is ignored by direct_get_container. This is not as bad as it sounds, if the account-reaper successfully deletes the first 10K objects, assuming the container has > 10K objects, the next call to direct_get_container will in fact return the next 10K objects even though it sets marker=None (assuming the first 10K objects were successfully deleted). This patch also updates test_direct_get_account and test_direct_get_container to ensure the appropriate args are included in the connection query_string. Closes-Bug: #1369558 Change-Id: If1c8aa1240d38354ebc9b1ebca92dc1c8c36cb5f
This commit is contained in:
parent
61e2b5235a
commit
6354e2da57
@ -108,7 +108,7 @@ def direct_get_account(node, part, account, marker=None, limit=None,
|
||||
:param marker: marker query
|
||||
:param limit: query limit
|
||||
:param prefix: prefix query
|
||||
:param delimeter: delimeter for the query
|
||||
:param delimiter: delimiter for the query
|
||||
:param conn_timeout: timeout in seconds for establishing the connection
|
||||
:param response_timeout: timeout in seconds for getting the response
|
||||
:returns: a tuple of (response headers, a list of containers) The response
|
||||
@ -116,11 +116,11 @@ def direct_get_account(node, part, account, marker=None, limit=None,
|
||||
"""
|
||||
path = '/' + account
|
||||
return _get_direct_account_container(path, "Account", node, part,
|
||||
account, marker=None,
|
||||
limit=None, prefix=None,
|
||||
delimiter=None,
|
||||
conn_timeout=5,
|
||||
response_timeout=15)
|
||||
account, marker=marker,
|
||||
limit=limit, prefix=prefix,
|
||||
delimiter=delimiter,
|
||||
conn_timeout=conn_timeout,
|
||||
response_timeout=response_timeout)
|
||||
|
||||
|
||||
def direct_delete_account(node, part, account, conn_timeout=5,
|
||||
@ -183,7 +183,7 @@ def direct_get_container(node, part, account, container, marker=None,
|
||||
:param marker: marker query
|
||||
:param limit: query limit
|
||||
:param prefix: prefix query
|
||||
:param delimeter: delimeter for the query
|
||||
:param delimiter: delimiter for the query
|
||||
:param conn_timeout: timeout in seconds for establishing the connection
|
||||
:param response_timeout: timeout in seconds for getting the response
|
||||
:returns: a tuple of (response headers, a list of objects) The response
|
||||
@ -191,11 +191,11 @@ def direct_get_container(node, part, account, container, marker=None,
|
||||
"""
|
||||
path = '/%s/%s' % (account, container)
|
||||
return _get_direct_account_container(path, "Container", node,
|
||||
part, account, marker=None,
|
||||
limit=None, prefix=None,
|
||||
delimiter=None,
|
||||
conn_timeout=5,
|
||||
response_timeout=15)
|
||||
part, account, marker=marker,
|
||||
limit=limit, prefix=prefix,
|
||||
delimiter=delimiter,
|
||||
conn_timeout=conn_timeout,
|
||||
response_timeout=response_timeout)
|
||||
|
||||
|
||||
def direct_delete_container(node, part, account, container, conn_timeout=5,
|
||||
|
@ -161,13 +161,19 @@ class TestDirectClient(unittest.TestCase):
|
||||
|
||||
with mocked_http_conn(200, stub_headers, body) as conn:
|
||||
resp_headers, resp = direct_client.direct_get_account(
|
||||
self.node, self.part, self.account)
|
||||
self.node, self.part, self.account, marker='marker',
|
||||
prefix='prefix', delimiter='delimiter', limit=1000)
|
||||
self.assertEqual(conn.method, 'GET')
|
||||
self.assertEqual(conn.path, self.account_path)
|
||||
|
||||
self.assertEqual(conn.req_headers['user-agent'], self.user_agent)
|
||||
self.assertEqual(resp_headers, stub_headers)
|
||||
self.assertEqual(json.loads(body), resp)
|
||||
self.assertTrue('marker=marker' in conn.query_string)
|
||||
self.assertTrue('delimiter=delimiter' in conn.query_string)
|
||||
self.assertTrue('limit=1000' in conn.query_string)
|
||||
self.assertTrue('prefix=prefix' in conn.query_string)
|
||||
self.assertTrue('format=json' in conn.query_string)
|
||||
|
||||
def test_direct_client_exception(self):
|
||||
stub_headers = {'X-Trans-Id': 'txb5f59485c578460f8be9e-0053478d09'}
|
||||
@ -302,12 +308,19 @@ class TestDirectClient(unittest.TestCase):
|
||||
|
||||
with mocked_http_conn(200, headers, body) as conn:
|
||||
resp_headers, resp = direct_client.direct_get_container(
|
||||
self.node, self.part, self.account, self.container)
|
||||
self.node, self.part, self.account, self.container,
|
||||
marker='marker', prefix='prefix', delimiter='delimiter',
|
||||
limit=1000)
|
||||
|
||||
self.assertEqual(conn.req_headers['user-agent'],
|
||||
'direct-client %s' % os.getpid())
|
||||
self.assertEqual(headers, resp_headers)
|
||||
self.assertEqual(json.loads(body), resp)
|
||||
self.assertTrue('marker=marker' in conn.query_string)
|
||||
self.assertTrue('delimiter=delimiter' in conn.query_string)
|
||||
self.assertTrue('limit=1000' in conn.query_string)
|
||||
self.assertTrue('prefix=prefix' in conn.query_string)
|
||||
self.assertTrue('format=json' in conn.query_string)
|
||||
|
||||
def test_direct_get_container_no_content_does_not_decode_body(self):
|
||||
headers = {}
|
||||
|
Loading…
Reference in New Issue
Block a user