diff --git a/rally-jobs/cinder.yaml b/rally-jobs/cinder.yaml index 7b4ea708..694c5790 100755 --- a/rally-jobs/cinder.yaml +++ b/rally-jobs/cinder.yaml @@ -849,6 +849,26 @@ failure_rate: max: 0 + CinderVolumeTypes.create_volume_type_and_encryption_type: + - + args: + specs: + provider: "LuksEncryptor" + cipher: "aes-xts-plain64" + key_size: 512 + control_location: "front-end" + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + CinderVolumes.list_transfers: - args: diff --git a/rally/plugins/openstack/cleanup/resources.py b/rally/plugins/openstack/cleanup/resources.py index 6eb2bd8b..5a967bba 100644 --- a/rally/plugins/openstack/cleanup/resources.py +++ b/rally/plugins/openstack/cleanup/resources.py @@ -455,7 +455,7 @@ class CinderVolumeBackup(base.ResourceManager): @base.resource("cinder", "volume_types", order=next(_cinder_order), - admin_required=True) + admin_required=True, perform_for_admin_only=True) class CinderVolumeType(base.ResourceManager): def list(self): return [r for r in self._manager().list() diff --git a/rally/plugins/openstack/scenarios/cinder/utils.py b/rally/plugins/openstack/scenarios/cinder/utils.py index 2dc4d1c4..9e2b6a21 100644 --- a/rally/plugins/openstack/scenarios/cinder/utils.py +++ b/rally/plugins/openstack/scenarios/cinder/utils.py @@ -442,3 +442,14 @@ class CinderScenario(scenario.OpenStackScenario): :rtype: VolumeTransfer """ return self.clients("cinder").transfers.accept(transfer_id, auth_key) + + @atomic.action_timer("cinder.create_encryption_type") + def _create_encryption_type(self, volume_type, specs): + """Create encryption type for a volume type. Default: admin only. + + :param volume_type: the volume type on which to add an encryption type + :param specs: the encryption type specifications to add + :return: an instance of :class: VolumeEncryptionType + """ + return self.admin_clients("cinder").volume_encryption_types.create( + volume_type, specs) diff --git a/rally/plugins/openstack/scenarios/cinder/volume_types.py b/rally/plugins/openstack/scenarios/cinder/volume_types.py index 0d6a3204..821d3b71 100644 --- a/rally/plugins/openstack/scenarios/cinder/volume_types.py +++ b/rally/plugins/openstack/scenarios/cinder/volume_types.py @@ -35,3 +35,24 @@ class CreateAndDeleteVolumeType(cinder_utils.CinderScenario): """ volume_type = self._create_volume_type(**kwargs) 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_volume_type" + "_and_encryption_type") +class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderScenario): + + def run(self, specs, **kwargs): + """Create encryption type + + This scenario first creates a volume type, then creates an encryption + type for the volume type. + + :param specs: the encryption type specifications to add + :param kwargs: Optional parameters used during volume + type creation. + """ + volume_type = self._create_volume_type(**kwargs) + self._create_encryption_type(volume_type, specs) diff --git a/samples/tasks/scenarios/cinder/create-encryption-type.json b/samples/tasks/scenarios/cinder/create-encryption-type.json new file mode 100644 index 00000000..375945eb --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-encryption-type.json @@ -0,0 +1,30 @@ +{ + "CinderVolumeTypes.create_volume_type_and_encryption_type": [ + { + "args": { + "specs": { + "provider": "LuksEncryptor", + "cipher": "aes-xts-plain64", + "key_size": 512, + "control_location": "front-end" + } + }, + "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-encryption-type.yaml b/samples/tasks/scenarios/cinder/create-encryption-type.yaml new file mode 100644 index 00000000..37df80d9 --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-encryption-type.yaml @@ -0,0 +1,20 @@ +--- + CinderVolumeTypes.create_volume_type_and_encryption_type: + - + args: + specs: + provider: "LuksEncryptor" + cipher: "aes-xts-plain64" + key_size: 512 + control_location: "front-end" + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 diff --git a/tests/ci/osresources.py b/tests/ci/osresources.py index f3ab69d9..d951174a 100755 --- a/tests/ci/osresources.py +++ b/tests/ci/osresources.py @@ -259,6 +259,9 @@ class Cinder(ResourceManager): def list_volume_types(self): return self.client.volume_types.list() + def list_encryption_types(self): + return self.client.volume_encryption_types.list() + def list_transfers(self): return self.client.transfers.list() diff --git a/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py b/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py index dd8d6612..4c143d46 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py @@ -381,6 +381,25 @@ class CinderScenarioTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(self.scenario.atomic_actions(), "cinder.create_volume_type") + def test__create_encryption_type(self): + volume_type = mock.Mock() + specs = { + "provider": "foo_pro", + "cipher": "foo_cip", + "key_size": 512, + "control_location": "foo_con" + } + result = self.scenario._create_encryption_type(volume_type, specs) + + self.assertEqual( + self.admin_clients( + "cinder").volume_encryption_types.create.return_value, result) + self.admin_clients( + "cinder").volume_encryption_types.create.assert_called_once_with( + volume_type, specs) + self._test_atomic_action_timer(self.scenario.atomic_actions(), + "cinder.create_encryption_type") + def test__delete_volume_type(self): volume_type = mock.Mock() self.scenario._delete_volume_type(volume_type) 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 dcb13462..001f30c3 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py @@ -33,3 +33,13 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase): fakeargs="fakeargs") scenario._delete_volume_type.assert_called_once_with( scenario._create_volume_type.return_value) + + def test_create_volume_type_and_encryption_type(self): + scenario = volume_types.CreateVolumeTypeAndEncryptionType(self.context) + scenario._create_volume_type = mock.Mock() + scenario._create_encryption_type = mock.Mock() + scenario.run(specs="fakespecs", fakeargs="fakeargs") + scenario._create_volume_type.assert_called_once_with( + fakeargs="fakeargs") + scenario._create_encryption_type.assert_called_once_with( + scenario._create_volume_type.return_value, "fakespecs")