Merge "Fix bulk heartbeating when emitting XML"

This commit is contained in:
Zuul 2018-01-27 01:37:04 +00:00 committed by Gerrit Code Review
commit b0cd86676d
2 changed files with 12 additions and 7 deletions

View File

@ -387,6 +387,7 @@ class Bulk(object):
'Response Body': '',
'Number Deleted': 0,
'Number Not Found': 0}
req.environ['eventlet.minimum_write_chunk_size'] = 0
try:
if not out_content_type:
raise HTTPNotAcceptable(request=req)
@ -407,7 +408,6 @@ class Bulk(object):
if objs_to_delete is None:
objs_to_delete = self.get_objs_to_delete(req)
failed_file_response = {'type': HTTPBadRequest}
req.environ['eventlet.minimum_write_chunk_size'] = 0
def delete_filter(predicate, objs_to_delete):
for obj_to_delete in objs_to_delete:
@ -515,6 +515,7 @@ class Bulk(object):
last_yield = time()
separator = ''
containers_accessed = set()
req.environ['eventlet.minimum_write_chunk_size'] = 0
try:
if not out_content_type:
raise HTTPNotAcceptable(request=req)
@ -534,7 +535,6 @@ class Bulk(object):
tar = tarfile.open(mode='r|' + compress_type,
fileobj=req.body_file)
failed_response_type = HTTPBadRequest
req.environ['eventlet.minimum_write_chunk_size'] = 0
containers_created = 0
while True:
if last_yield + self.yield_frequency < time():

View File

@ -243,9 +243,11 @@ class TestUntar(unittest.TestCase):
def handle_extract_and_iter(self, req, compress_format,
out_content_type='application/json'):
resp_body = ''.join(
self.bulk.handle_extract_iter(req, compress_format,
out_content_type=out_content_type))
iter = self.bulk.handle_extract_iter(
req, compress_format, out_content_type=out_content_type)
first_chunk = next(iter)
self.assertEqual(req.environ['eventlet.minimum_write_chunk_size'], 0)
resp_body = first_chunk + ''.join(iter)
return resp_body
def test_create_container_for_path(self):
@ -627,8 +629,11 @@ class TestDelete(unittest.TestCase):
self.app.delete_paths = []
def handle_delete_and_iter(self, req, out_content_type='application/json'):
resp_body = ''.join(self.bulk.handle_delete_iter(
req, out_content_type=out_content_type))
iter = self.bulk.handle_delete_iter(
req, out_content_type=out_content_type)
first_chunk = next(iter)
self.assertEqual(req.environ['eventlet.minimum_write_chunk_size'], 0)
resp_body = first_chunk + ''.join(iter)
return resp_body
def test_bulk_delete_uses_predefined_object_errors(self):