Add cinder.CreateAndGetVolumeType scenario

Create a volume Type, then get the details of the type

Change-Id: I1e4468008e00d4ca5efaf6838e8b0eed56c807e7
This commit is contained in:
zhangzhang 2017-01-17 11:31:34 -05:00
parent 14fc512110
commit 02559f1373
7 changed files with 99 additions and 0 deletions

View File

@ -852,6 +852,21 @@
failure_rate: failure_rate:
max: 0 max: 0
CinderVolumeTypes.create_and_get_volume_type:
-
args: {}
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
CinderVolumeTypes.create_and_delete_volume_type: CinderVolumeTypes.create_and_delete_volume_type:
- -
args: {} args: {}

View File

@ -448,6 +448,15 @@ class CinderScenario(scenario.OpenStackScenario):
""" """
return volume_type.set_keys(metadata) return volume_type.set_keys(metadata)
@atomic.action_timer("cinder.get_volume_type")
def _get_volume_type(self, volume_type):
"""get details of volume_type.
:param volume_type: The ID of the :class:`VolumeType` to get
:rtype: :class:`VolumeType`
"""
return self.admin_clients("cinder").volume_types.get(volume_type)
@atomic.action_timer("cinder.transfer_create") @atomic.action_timer("cinder.transfer_create")
def _transfer_create(self, volume_id): def _transfer_create(self, volume_id):
"""Create a volume transfer. """Create a volume transfer.

View File

@ -39,6 +39,22 @@ class CreateAndDeleteVolumeType(cinder_utils.CinderScenario):
self._delete_volume_type(volume_type) self._delete_volume_type(volume_type)
@validation.required_services(consts.Service.CINDER)
@validation.required_openstack(admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_get_volume_type")
class CreateAndGetVolumeType(cinder_utils.CinderScenario):
def run(self, **kwargs):
"""Create a volume Type, then get the details of the type.
:param kwargs: Optional parameters used during volume
type creation.
"""
volume_type = self._create_volume_type(**kwargs)
self._get_volume_type(volume_type)
@validation.required_services(consts.Service.CINDER) @validation.required_services(consts.Service.CINDER)
@validation.required_openstack(admin=True) @validation.required_openstack(admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]}, @scenario.configure(context={"admin_cleanup": ["cinder"]},

View File

@ -0,0 +1,23 @@
{
"CinderVolumeTypes.create_and_get_volume_type": [
{
"args": {},
"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,15 @@
---
CinderVolumeTypes.create_and_get_volume_type:
-
args: {}
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -427,6 +427,18 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(self.scenario.atomic_actions(), self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.list_encryption_type") "cinder.list_encryption_type")
def test__get_volume_type(self):
volume_type = mock.Mock()
result = self.scenario._get_volume_type(volume_type)
self.assertEqual(
self.admin_clients("cinder").volume_types.get.return_value,
result)
self.admin_clients("cinder").volume_types.get.assert_called_once_with(
volume_type)
self._test_atomic_action_timer(self.scenario.atomic_actions(),
"cinder.get_volume_type")
def test__delete_volume_type(self): def test__delete_volume_type(self):
volume_type = mock.Mock() volume_type = mock.Mock()
self.scenario._delete_volume_type(volume_type) self.scenario._delete_volume_type(volume_type)

View File

@ -31,6 +31,15 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
"name": "fake_name"}]}) "name": "fake_name"}]})
return context return context
def test_create_and_get_volume_type(self):
scenario = volume_types.CreateAndGetVolumeType(self.context)
scenario._create_volume_type = mock.Mock()
scenario._get_volume_type = mock.Mock()
scenario.run(fakeargs="f")
scenario._create_volume_type.assert_called_once_with(fakeargs="f")
scenario._get_volume_type.assert_called_once_with(
scenario._create_volume_type.return_value)
def test_create_and_delete_volume_type(self): def test_create_and_delete_volume_type(self):
scenario = volume_types.CreateAndDeleteVolumeType(self.context) scenario = volume_types.CreateAndDeleteVolumeType(self.context)
scenario._create_volume_type = mock.Mock() scenario._create_volume_type = mock.Mock()