diff --git a/rally-jobs/cinder.yaml b/rally-jobs/cinder.yaml index 3e1df3b9..e45bd503 100755 --- a/rally-jobs/cinder.yaml +++ b/rally-jobs/cinder.yaml @@ -1140,3 +1140,32 @@ sla: failure_rate: max: 0 + + CinderVolumeTypes.create_and_update_encryption_type: + - + args: + create_provider: "LuksEncryptor" + create_cipher: "aes-xts-plain64" + create_key_size: 512 + create_control_location: "front-end" + update_provider: "CryptsetupEncryptor" + update_cipher: "aes-xts-plain" + update_key_size: 256 + update_control_location: "back-end" + runner: + type: "constant" + times: 4 + concurrency: 1 + context: + users: + tenants: 2 + users_per_tenant: 2 + volume_types: [ + "test_type1", + "test_type2", + "test_type3", + "test_type4" + ] + sla: + failure_rate: + max: 0 diff --git a/rally/plugins/openstack/scenarios/cinder/volume_types.py b/rally/plugins/openstack/scenarios/cinder/volume_types.py index d8f3d49e..293a0d6f 100644 --- a/rally/plugins/openstack/scenarios/cinder/volume_types.py +++ b/rally/plugins/openstack/scenarios/cinder/volume_types.py @@ -276,3 +276,55 @@ class CreateAndDeleteEncryptionType(cinder_utils.CinderBasic): self.admin_cinder.create_encryption_type(volume_type["id"], specs=specs) self.admin_cinder.delete_encryption_type(volume_type["id"]) + + +@validation.required_services(consts.Service.CINDER) +@validation.required_contexts("volume_types") +@validation.add("required_platform", platform="openstack", admin=True) +@scenario.configure(context={"admin_cleanup": ["cinder"]}, + name="CinderVolumeTypes.create_and_update_encryption_type") +class CreateAndUpdateEncryptionType(cinder_utils.CinderBasic): + + def run(self, create_provider=None, create_cipher=None, + create_key_size=None, create_control_location="front-end", + update_provider=None, update_cipher=None, + update_key_size=None, update_control_location=None): + """Create and update encryption type + + This scenario firstly creates a volume type, secondly creates an + encryption type for the volume type, thirdly updates the encryption + type. + + :param create_provider: The class that provides encryption support. For + example, LuksEncryptor. + :param create_cipher: The encryption algorithm or mode. + :param create_key_size: Size of encryption key, in bits. + :param create_control_location: Notional service where encryption is + performed. Valid values are "front-end" + or "back-end." + :param update_provider: The class that provides encryption support. For + example, LuksEncryptor. + :param update_cipher: The encryption algorithm or mode. + :param update_key_size: Size of encryption key, in bits. + :param update_control_location: Notional service where encryption is + performed. Valid values are "front-end" + or "back-end." + """ + vt_idx = self.context["iteration"] % len(self.context["volume_types"]) + volume_type = self.context["volume_types"][vt_idx] + create_specs = { + "provider": create_provider, + "cipher": create_cipher, + "key_size": create_key_size, + "control_location": create_control_location + } + update_specs = { + "provider": update_provider, + "cipher": update_cipher, + "key_size": update_key_size, + "control_location": update_control_location + } + self.admin_cinder.create_encryption_type(volume_type["id"], + specs=create_specs) + self.admin_cinder.update_encryption_type(volume_type["id"], + specs=update_specs) diff --git a/rally/plugins/openstack/services/storage/block.py b/rally/plugins/openstack/services/storage/block.py index 19f24fa3..d8c2e8c1 100644 --- a/rally/plugins/openstack/services/storage/block.py +++ b/rally/plugins/openstack/services/storage/block.py @@ -400,3 +400,14 @@ class BlockStorage(service.UnifiedService): must be deleted """ self._impl.delete_encryption_type(volume_type) + + @service.should_be_overridden + def update_encryption_type(self, volume_type, specs): + """Update the encryption type information for the specified volume type. + + :param volume_type: the volume type whose encryption type information + will be updated + :param specs: the encryption type specifications to update + :return: an instance of :class: VolumeEncryptionType + """ + return self._impl.update_encryption_type(volume_type, specs=specs) diff --git a/rally/plugins/openstack/services/storage/cinder_common.py b/rally/plugins/openstack/services/storage/cinder_common.py index 594ef93e..e8f150e0 100644 --- a/rally/plugins/openstack/services/storage/cinder_common.py +++ b/rally/plugins/openstack/services/storage/cinder_common.py @@ -413,6 +413,19 @@ class CinderMixin(object): if (resp[0].status_code != 202): raise exceptions.EncryptionTypeDeleteException() + def update_encryption_type(self, volume_type, specs): + """Update the encryption type information for the specified volume type. + + :param volume_type: the volume type whose encryption type information + must be updated + :param specs: the encryption type specifications to update + :return: an instance of :class: VolumeEncryptionType + """ + aname = "cinder_v%s.update_encryption_type" % self.version + with atomic.ActionTimer(self, aname): + return self._get_client().volume_encryption_types.update( + volume_type, specs) + class UnifiedCinderMixin(object): @@ -633,3 +646,13 @@ class UnifiedCinderMixin(object): must be deleted """ return self._impl.delete_encryption_type(volume_type) + + def update_encryption_type(self, volume_type, specs): + """Update the encryption type information for the specified volume type. + + :param volume_type: the volume type whose encryption type information + must be updated + :param specs: the encryption type specifications to update + :return: an instance of :class: VolumeEncryptionType + """ + return self._impl.update_encryption_type(volume_type, specs=specs) diff --git a/samples/tasks/scenarios/cinder/create-and-update-encryption-type.json b/samples/tasks/scenarios/cinder/create-and-update-encryption-type.json new file mode 100644 index 00000000..8f1368a4 --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-update-encryption-type.json @@ -0,0 +1,38 @@ +{ + "CinderVolumeTypes.create_and_update_encryption_type": [ + { + "args": { + "create_provider": "LuksEncryptor", + "create_cipher": "aes-xts-plain64", + "create_key_size": 512, + "create_control_location": "front-end", + "update_provider": "CryptsetupEncryptor", + "update_cipher": "aes-xts-plain", + "update_key_size": 256, + "update_control_location": "back-end" + }, + "runner": { + "type": "constant", + "times": 4, + "concurrency": 1 + }, + "context": { + "users": { + "tenants": 2, + "users_per_tenant": 2 + }, + "volume_types": [ + "test_type1", + "test_type2", + "test_type3", + "test_type4" + ] + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/cinder/create-and-update-encryption-type.yaml b/samples/tasks/scenarios/cinder/create-and-update-encryption-type.yaml new file mode 100644 index 00000000..161b71ed --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-update-encryption-type.yaml @@ -0,0 +1,28 @@ + CinderVolumeTypes.create_and_update_encryption_type: + - + args: + create_provider: "LuksEncryptor" + create_cipher: "aes-xts-plain64" + create_key_size: 512 + create_control_location: "front-end" + update_provider: "CryptsetupEncryptor" + update_cipher: "aes-xts-plain" + update_key_size: 256 + update_control_location: "back-end" + runner: + type: "constant" + times: 4 + concurrency: 1 + context: + users: + tenants: 2 + users_per_tenant: 2 + volume_types: [ + "test_type1", + "test_type2", + "test_type3", + "test_type4" + ] + 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 87670473..6f836d37 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py @@ -224,3 +224,36 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase): mock_service.set_volume_type_keys.assert_called_once_with( mock_service.create_volume_type.return_value, metadata=volume_type_key) + + def test_create_and_update_encryption_type(self): + mock_service = self.mock_cinder.return_value + context = self._get_context() + context.update({ + "volume_types": [{"id": "fake_id", + "name": "fake_name"}], + "iteration": 1}) + scenario = volume_types.CreateAndUpdateEncryptionType( + context) + + create_specs = { + "provider": "create_prov", + "cipher": "create_cip", + "key_size": "create_ks", + "control_location": "create_cl" + } + update_specs = { + "provider": "update_prov", + "cipher": "update_cip", + "key_size": "update_ks", + "control_location": "update_cl" + } + scenario.run(create_provider="create_prov", create_cipher="create_cip", + create_key_size="create_ks", + create_control_location="create_cl", + update_provider="update_prov", update_cipher="update_cip", + update_key_size="update_ks", + update_control_location="update_cl") + mock_service.create_encryption_type.assert_called_once_with( + "fake_id", specs=create_specs) + mock_service.update_encryption_type.assert_called_once_with( + "fake_id", specs=update_specs) diff --git a/tests/unit/plugins/openstack/services/storage/test_block.py b/tests/unit/plugins/openstack/services/storage/test_block.py index 4270a535..2010f3e4 100644 --- a/tests/unit/plugins/openstack/services/storage/test_block.py +++ b/tests/unit/plugins/openstack/services/storage/test_block.py @@ -247,3 +247,10 @@ class BlockTestCase(test.TestCase): self.service.delete_encryption_type("type") self.service._impl.delete_encryption_type.assert_called_once_with( "type") + + def test_update_encryption_type(self): + self.assertEqual( + self.service._impl.update_encryption_type.return_value, + self.service.update_encryption_type("type", specs=3)) + self.service._impl.update_encryption_type.assert_called_once_with( + "type", specs=3) diff --git a/tests/unit/plugins/openstack/services/storage/test_cinder_common.py b/tests/unit/plugins/openstack/services/storage/test_cinder_common.py index 968e9316..169b4689 100644 --- a/tests/unit/plugins/openstack/services/storage/test_cinder_common.py +++ b/tests/unit/plugins/openstack/services/storage/test_cinder_common.py @@ -405,6 +405,21 @@ class CinderMixinTestCase(test.ScenarioTestCase): self.cinder.volume_encryption_types.delete.assert_called_once_with( "type") + def test_update_encryption_type(self): + volume_type = mock.Mock() + specs = { + "provider": "foo_pro", + "cipher": "foo_cip", + "key_size": 512, + "control_location": "foo_con" + } + result = self.service.update_encryption_type(volume_type, specs) + + self.assertEqual( + self.cinder.volume_encryption_types.update.return_value, result) + self.cinder.volume_encryption_types.update.assert_called_once_with( + volume_type, specs) + class FullUnifiedCinder(cinder_common.UnifiedCinderMixin, service.Service): @@ -633,3 +648,8 @@ class UnifiedCinderMixinTestCase(test.TestCase): self.service.delete_encryption_type("type") self.service._impl.delete_encryption_type.assert_called_once_with( "type") + + def test_update_encryption_type(self): + self.service.update_encryption_type("type", specs=3) + self.service._impl.update_encryption_type.assert_called_once_with( + "type", specs=3)