diff --git a/rally-jobs/cinder.yaml b/rally-jobs/cinder.yaml index 165d8dc4..3e1df3b9 100755 --- a/rally-jobs/cinder.yaml +++ b/rally-jobs/cinder.yaml @@ -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: diff --git a/rally/plugins/openstack/scenarios/cinder/volume_types.py b/rally/plugins/openstack/scenarios/cinder/volume_types.py index 138973b8..d8f3d49e 100644 --- a/rally/plugins/openstack/scenarios/cinder/volume_types.py +++ b/rally/plugins/openstack/scenarios/cinder/volume_types.py @@ -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) diff --git a/samples/tasks/scenarios/cinder/create-and-list-volume-types.json b/samples/tasks/scenarios/cinder/create-and-list-volume-types.json new file mode 100644 index 00000000..80d70f2e --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-list-volume-types.json @@ -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 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/cinder/create-and-list-volume-types.yaml b/samples/tasks/scenarios/cinder/create-and-list-volume-types.yaml new file mode 100644 index 00000000..7c6edad5 --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-list-volume-types.yaml @@ -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 diff --git a/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py b/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py index ea83acdf..87670473 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py @@ -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(