Add cinder.CreateAndSetVolumeType scenario

Create and set a volume type's extra specs.

Change-Id: Idb13f2e119a3798149f6fd268bad4822a45c737e
This commit is contained in:
zhangzhang 2016-12-29 10:18:55 -05:00
parent f26c025b78
commit 9d1d4a8369
7 changed files with 116 additions and 0 deletions

View File

@ -907,6 +907,23 @@
failure_rate:
max: 0
CinderVolumeTypes.create_and_set_volume_type_keys:
-
args:
volume_type_key:
volume_backend_name: "LVM_iSCSI"
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
CinderVolumes.list_transfers:
-
args:

View File

@ -423,6 +423,16 @@ class CinderScenario(scenario.OpenStackScenario):
volume_type)
return (tuple_res[0].status_code == 202)
@atomic.action_timer("cinder.set_volume_type_keys")
def _set_volume_type_keys(self, volume_type, metadata):
"""Set extra specs on a volume type.
:param volume_type: The :class:`VolumeType` to set extra spec on
:param metadata: A dict of key/value pairs to be set
:returns: extra_specs if the request has been accepted
"""
return volume_type.set_keys(metadata)
@atomic.action_timer("cinder.transfer_create")
def _transfer_create(self, volume_id):
"""Create a volume transfer.

View File

@ -80,3 +80,21 @@ class CreateAndListEncryptionType(cinder_utils.CinderScenario):
volume_type = self._create_volume_type(**kwargs)
self._create_encryption_type(volume_type, specs)
self._list_encryption_type(search_opts)
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_set_volume_type_keys")
class CreateAndSetVolumeTypeKeys(cinder_utils.CinderScenario):
def run(self, volume_type_key, **kwargs):
"""Create and set a volume type's extra specs.
:param volume_type_key: A dict of key/value pairs to be set
:param kwargs: Optional parameters used during volume
type creation.
"""
volume_type = self._create_volume_type(**kwargs)
self._set_volume_type_keys(volume_type, volume_type_key)

View File

@ -0,0 +1,27 @@
{
"CinderVolumeTypes.create_and_set_volume_type_keys": [
{
"args": {
"volume_type_key": {
"volume_backend_name": "LVM_iSCSI"
}
},
"runner": {
"type": "constant",
"times": 5,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,17 @@
---
CinderVolumeTypes.create_and_set_volume_type_keys:
-
args:
volume_type_key:
volume_backend_name: "LVM_iSCSI"
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -441,3 +441,14 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
fake_transfer.id, "fake_key")
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.transfer_accept")
def test__set_volume_type_keys(self):
volume_type = mock.MagicMock()
volume_type.set_keys = mock.MagicMock()
volume_type_key = {"volume_backend_name": "LVM_iSCSI"}
result = self.scenario._set_volume_type_keys(volume_type,
volume_type_key)
self.assertEqual(volume_type.set_keys.return_value, result)
volume_type.set_keys.assert_called_once_with(volume_type_key)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.set_volume_type_keys")

View File

@ -57,3 +57,19 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
scenario._create_volume_type.return_value, "fakespecs")
scenario._list_encryption_type.assert_called_once_with(
"fakeopts")
def test_create_and_set_volume_type_keys(self):
scenario = volume_types.CreateAndSetVolumeTypeKeys(self.context)
volume_type = mock.MagicMock()
volume_type_key = {"volume_backend_name": "LVM_iSCSI"}
scenario._create_volume_type = mock.MagicMock()
scenario._set_volume_type_keys = mock.MagicMock()
scenario._create_volume_type.return_value = volume_type
scenario.run(volume_type_key, fakeargs="fakeargs")
scenario._create_volume_type.assert_called_once_with(
fakeargs="fakeargs")
scenario._set_volume_type_keys.assert_called_once_with(volume_type,
volume_type_key)