Merge "Switch glance wrapper to image service that cinder service calls"
This commit is contained in:
commit
a27078c085
@ -15,8 +15,8 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
from rally.plugins.openstack.services.image import image
|
||||||
from rally.plugins.openstack.services.storage import block
|
from rally.plugins.openstack.services.storage import block
|
||||||
from rally.plugins.openstack.wrappers import glance as glance_wrapper
|
|
||||||
from rally.task import atomic
|
from rally.task import atomic
|
||||||
from rally.task import utils as bench_utils
|
from rally.task import utils as bench_utils
|
||||||
|
|
||||||
@ -189,20 +189,19 @@ class CinderMixin(object):
|
|||||||
volume = self._wait_available_volume(volume)
|
volume = self._wait_available_volume(volume)
|
||||||
|
|
||||||
image_id = img["os-volume_upload_image"]["image_id"]
|
image_id = img["os-volume_upload_image"]["image_id"]
|
||||||
# NOTE(chenhb): If we imported glance service, we should switch
|
glance = image.Image(self._clients)
|
||||||
# glance wrapper to service.
|
|
||||||
wrapper = glance_wrapper.wrap(self._clients.glance, self)
|
image_inst = glance.get_image(image_id)
|
||||||
image = wrapper.client.images.get(image_id)
|
image_inst = bench_utils.wait_for_status(
|
||||||
image = bench_utils.wait_for_status(
|
image_inst,
|
||||||
image,
|
|
||||||
ready_statuses=["active"],
|
ready_statuses=["active"],
|
||||||
update_resource=wrapper.get_image,
|
update_resource=glance.get_image,
|
||||||
timeout=CONF.benchmark.glance_image_create_timeout,
|
timeout=CONF.benchmark.glance_image_create_timeout,
|
||||||
check_interval=(CONF.benchmark
|
check_interval=(CONF.benchmark
|
||||||
.glance_image_create_poll_interval)
|
.glance_image_create_poll_interval)
|
||||||
)
|
)
|
||||||
|
|
||||||
return image
|
return image_inst
|
||||||
|
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
"""Delete the given snapshot.
|
"""Delete the given snapshot.
|
||||||
|
@ -195,13 +195,12 @@ class CinderMixinTestCase(test.ScenarioTestCase):
|
|||||||
self.cinder.volumes.update_readonly_flag.assert_called_once_with(
|
self.cinder.volumes.update_readonly_flag.assert_called_once_with(
|
||||||
fake_volume, "fake_flag")
|
fake_volume, "fake_flag")
|
||||||
|
|
||||||
@mock.patch("rally.plugins.openstack.wrappers.glance.wrap")
|
@mock.patch("rally.plugins.openstack.services.image.image.Image")
|
||||||
def test_upload_volume_to_image(self, mock_wrap):
|
def test_upload_volume_to_image(self, mock_image):
|
||||||
volume = mock.Mock()
|
volume = mock.Mock()
|
||||||
image = {"os-volume_upload_image": {"image_id": 1}}
|
image = {"os-volume_upload_image": {"image_id": 1}}
|
||||||
self.cinder.volumes.upload_to_image.return_value = (None, image)
|
self.cinder.volumes.upload_to_image.return_value = (None, image)
|
||||||
glance_client = mock_wrap.return_value.client
|
glance = mock_image.return_value
|
||||||
glance_client.images.get.return_value = image
|
|
||||||
|
|
||||||
self.service.generate_random_name = mock.Mock(
|
self.service.generate_random_name = mock.Mock(
|
||||||
return_value="test_vol")
|
return_value="test_vol")
|
||||||
@ -219,14 +218,14 @@ class CinderMixinTestCase(test.ScenarioTestCase):
|
|||||||
check_interval=CONF.benchmark.
|
check_interval=CONF.benchmark.
|
||||||
cinder_volume_create_poll_interval),
|
cinder_volume_create_poll_interval),
|
||||||
mock.call(
|
mock.call(
|
||||||
glance_client.images.get.return_value,
|
glance.get_image.return_value,
|
||||||
ready_statuses=["active"],
|
ready_statuses=["active"],
|
||||||
update_resource=mock_wrap.return_value.get_image,
|
update_resource=glance.get_image,
|
||||||
timeout=CONF.benchmark.glance_image_create_timeout,
|
timeout=CONF.benchmark.glance_image_create_timeout,
|
||||||
check_interval=CONF.benchmark.
|
check_interval=CONF.benchmark.
|
||||||
glance_image_create_poll_interval)
|
glance_image_create_poll_interval)
|
||||||
])
|
])
|
||||||
glance_client.images.get.assert_called_once_with(1)
|
glance.get_image.assert_called_once_with(1)
|
||||||
|
|
||||||
def test_delete_snapshot(self):
|
def test_delete_snapshot(self):
|
||||||
snapshot = mock.Mock()
|
snapshot = mock.Mock()
|
||||||
|
Loading…
Reference in New Issue
Block a user