Merge "Make image upload tpool usage conditional"
This commit is contained in:
@@ -585,11 +585,10 @@ class GlanceImageServiceV2(object):
|
||||
_reraise_translated_exception()
|
||||
|
||||
def _upload_data(self, context, image_id, data):
|
||||
# NOTE(aarents) offload upload in a native thread as it can block
|
||||
# coroutine in busy environment.
|
||||
utils.tpool_execute(self._client.call,
|
||||
context, 2, 'upload',
|
||||
args=(image_id, data))
|
||||
# NOTE(aarents) In eventlet mode offload upload in a native thread as
|
||||
# it can block coroutine in busy environment.
|
||||
utils.tpool_wrap(
|
||||
self._client.call)(context, 2, 'upload', args=(image_id, data))
|
||||
|
||||
return self._client.call(context, 2, 'get', args=(image_id,))
|
||||
|
||||
|
||||
@@ -1914,13 +1914,12 @@ class TestCreate(test.NoDBTestCase):
|
||||
class TestUpdate(test.NoDBTestCase):
|
||||
|
||||
"""Tests the update method of the GlanceImageServiceV2."""
|
||||
@mock.patch('nova.utils.tpool_execute',
|
||||
side_effect=nova.utils.tpool_execute)
|
||||
@mock.patch('nova.utils.tpool_wrap')
|
||||
@mock.patch('nova.image.glance.GlanceImageServiceV2.show')
|
||||
@mock.patch('nova.image.glance._translate_from_glance')
|
||||
@mock.patch('nova.image.glance._translate_to_glance')
|
||||
def test_update_success_v2(
|
||||
self, trans_to_mock, trans_from_mock, show_mock, texec_mock):
|
||||
self, trans_to_mock, trans_from_mock, show_mock, twrap_mock):
|
||||
image = {
|
||||
'id': mock.sentinel.image_id,
|
||||
'name': mock.sentinel.name,
|
||||
@@ -1937,6 +1936,7 @@ class TestUpdate(test.NoDBTestCase):
|
||||
trans_from_mock.return_value = mock.sentinel.trans_from
|
||||
client = mock.MagicMock()
|
||||
client.call.return_value = mock.sentinel.image_meta
|
||||
twrap_mock.return_value = client.call
|
||||
ctx = mock.sentinel.ctx
|
||||
show_mock.return_value = {
|
||||
'image_id': mock.sentinel.image_id,
|
||||
@@ -1969,8 +1969,9 @@ class TestUpdate(test.NoDBTestCase):
|
||||
data=mock.sentinel.data)
|
||||
|
||||
self.assertEqual(3, client.call.call_count)
|
||||
texec_mock.assert_called_once_with(
|
||||
client.call, ctx, 2, 'upload',
|
||||
twrap_mock.assert_called_once_with(client.call)
|
||||
twrap_mock.return_value.assert_any_call(
|
||||
ctx, 2, 'upload',
|
||||
args=(mock.sentinel.image_id,
|
||||
mock.sentinel.data))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user