Add cinder.CreateAndListVolumeTypes scenario

Create a volume Type, then list all volume Types.

Change-Id: Ib66a06495241dc1b0fef24c99c01e267e1d98c2a
This commit is contained in:
zhangzhang 2017-01-17 08:01:13 -05:00
parent 545699db22
commit 41306020fc
5 changed files with 119 additions and 0 deletions

View File

@ -929,6 +929,22 @@
failure_rate:
max: 0
CinderVolumeTypes.create_and_list_volume_types:
-
args:
description: "rally tests creating types"
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
CinderVolumeTypes.create_volume_type_and_encryption_type:
-
args:

View File

@ -59,6 +59,32 @@ class CreateAndGetVolumeType(cinder_utils.CinderBasic):
self.admin_cinder.get_volume_type(volume_type)
@validation.required_services(consts.Service.CINDER)
@validation.add("required_platform", platform="openstack", admin=True)
@scenario.configure(context={"admin_cleanup": ["cinder"]},
name="CinderVolumeTypes.create_and_list_volume_types")
class CreateAndListVolumeTypes(cinder_utils.CinderBasic):
def run(self, description=None, is_public=True):
"""Create a volume Type, then list all types.
:param description: Description of the volume type
:param is_public: Volume type visibility
"""
volume_type = self.admin_cinder.create_volume_type(
description=description,
is_public=is_public)
pool_list = self.admin_cinder.list_types()
msg = ("type not included into list of available types"
"created type: {}\n"
"pool of types: {}\n").format(volume_type, pool_list)
self.assertIn(volume_type.id,
[vtype.id for vtype in pool_list],
err_msg=msg)
@validation.restricted_parameters("name")
@validation.required_services(consts.Service.CINDER)
@validation.add("required_params", params=[("create_specs", "provider")])
@validation.add("required_platform", platform="openstack", admin=True)

View File

@ -0,0 +1,25 @@
{
"CinderVolumeTypes.create_and_list_volume_types": [
{
"args": {
"description": "rally tests creating types"
},
"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,16 @@
---
CinderVolumeTypes.create_and_list_volume_types:
-
args:
description: "rally tests creating types"
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -14,6 +14,7 @@
import mock
from rally import exceptions as rally_exceptions
from rally.plugins.openstack.scenarios.cinder import volume_types
from tests.unit import test
@ -113,6 +114,41 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
mock_service.delete_encryption_type.assert_called_once_with(
"fake_id")
def test_create_and_list_volume_types(self):
mock_service = self.mock_cinder.return_value
fake_type = mock.Mock()
pool_list = [mock.Mock(), mock.Mock(), fake_type]
description = "rally tests creating types"
is_public = False
scenario = volume_types.CreateAndListVolumeTypes(self._get_context())
mock_service.create_volume_type.return_value = fake_type
mock_service.list_types.return_value = pool_list
scenario.run(description=description, is_public=is_public)
mock_service.create_volume_type.assert_called_once_with(
description=description, is_public=is_public)
mock_service.list_types.assert_called_once_with()
def test_create_and_list_volume_types_with_fails(self):
# Negative case: type isn't listed
mock_service = self.mock_cinder.return_value
fake_type = mock.Mock()
pool_list = [mock.Mock(), mock.Mock(), mock.Mock()]
description = "rally tests creating types"
is_public = False
scenario = volume_types.CreateAndListVolumeTypes(self._get_context())
mock_service.create_volume_type.return_value = fake_type
mock_service.list_types.return_value = pool_list
self.assertRaises(rally_exceptions.RallyAssertionError,
scenario.run,
description=description, is_public=is_public)
mock_service.create_volume_type.assert_called_once_with(
description=description, is_public=is_public)
mock_service.list_types.assert_called_once_with()
def test_create_volume_type_and_encryption_type(self):
mock_service = self.mock_cinder.return_value
scenario = volume_types.CreateVolumeTypeAndEncryptionType(