Merge "Add Cinder create_and_update_volume scenario"

This commit is contained in:
Jenkins 2015-08-26 01:27:46 +00:00 committed by Gerrit Code Review
commit 32d609c258
7 changed files with 139 additions and 0 deletions

View File

@ -96,6 +96,44 @@
failure_rate:
max: 0
CinderVolumes.create_and_update_volume:
-
args:
update_volume_kwargs:
display_name: "name_updated"
display_description: "desc_updated"
size: 1
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
-
args:
update_volume_kwargs:
display_name: "name_updated"
display_description: "desc_updated"
size: 1
image:
name: {{image_name}}
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
CinderVolumes.create_and_list_volume:
-
args:

View File

@ -148,6 +148,22 @@ class CinderScenario(scenario.OpenStackScenario):
)
return volume
@atomic.action_timer("cinder.update_volume")
def _update_volume(self, volume, **update_volume_args):
"""Update name and description for this volume
This atomic function updates volume display name and description
:param volume: volume object
:param update_volume_args: dict, contains values to be updated.
"""
kwargs = {}
kwargs["display_name"] = update_volume_args.get(
"display_name", self._generate_random_name("_"))
kwargs["display_description"] = update_volume_args.get(
"display_description", self._generate_random_name("_"))
self.clients("cinder").volumes.update(volume, **kwargs)
@atomic.action_timer("cinder.delete_volume")
def _delete_volume(self, volume):
"""Delete the given volume.

View File

@ -80,6 +80,28 @@ class CinderVolumes(utils.CinderScenario,
self._list_volumes(detailed)
@types.set(image=types.ImageResourceType)
@validation.image_exists("image", nullable=True)
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["cinder"]})
def create_and_update_volume(self, size, image=None,
create_volume_kwargs=None,
update_volume_kwargs=None):
"""Create a volume and update its name and description.
:param size: volume size (integer, in GB)
:param image: image to be used to create volume
:param create_volume_kwargs: dict, to be used to create volume
:param update_volume_kwargs: dict, to be used to update volume
"""
create_volume_kwargs = create_volume_kwargs or {}
update_volume_kwargs = update_volume_kwargs or {}
if image:
create_volume_kwargs["imageRef"] = image
volume = self._create_volume(size, **create_volume_kwargs)
self._update_volume(volume, **update_volume_kwargs)
@types.set(image=types.ImageResourceType)
@validation.image_exists("image", nullable=True)
@validation.required_services(consts.Service.CINDER)

View File

@ -0,0 +1,24 @@
{
"CinderVolumes.create_and_update_volume": [
{
"args": {
"update_volume_kwargs": {
"display_name": "name_updated",
"display_description": "desc_updated"
},
"size": 1
},
"runner": {
"type": "constant",
"times": 3,
"concurrency": 1
},
"context": {
"users": {
"tenants": 1,
"users_per_tenant": 1
}
}
}
]
}

View File

@ -0,0 +1,16 @@
---
CinderVolumes.create_and_update_volume:
-
args:
update_volume_kwargs:
display_name: "name_updated"
display_description: "desc_updated"
size: 1
runner:
type: "constant"
times: 3
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1

View File

@ -127,6 +127,17 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.create_volume")
def test__update_volume(self):
fake_volume = mock.MagicMock()
volume_update_args = {"display_name": "_updated",
"display_description": "_updated"}
self.scenario._update_volume(fake_volume, **volume_update_args)
self.clients("cinder").volumes.update.assert_called_once_with(
fake_volume, display_name="_updated",
display_description="_updated")
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.update_volume")
def test__delete_volume(self):
cinder = mock.Mock()
self.scenario._delete_volume(cinder)

View File

@ -49,6 +49,18 @@ class CinderServersTestCase(test.ScenarioTestCase):
scenario.list_volumes(True)
scenario._list_volumes.assert_called_once_with(True)
def test_create_and_update_volume(self):
volume_update_args = {"dispaly_name": "_updated"}
scenario = volumes.CinderVolumes()
fake_volume = mock.MagicMock()
scenario._create_volume = mock.MagicMock(return_value=fake_volume)
scenario._update_volume = mock.MagicMock()
scenario.create_and_update_volume(
1, update_volume_kwargs=volume_update_args)
scenario._create_volume.assert_called_once_with(1)
scenario._update_volume.assert_called_once_with(fake_volume,
**volume_update_args)
def test_create_and_delete_volume(self):
fake_volume = mock.MagicMock()