From 043c73273a5f9bc3af96e9bd3b98936bb9f9aadc Mon Sep 17 00:00:00 2001 From: maxinjian Date: Tue, 17 Jan 2017 05:42:59 -0500 Subject: [PATCH] Add CinderVolumeTypes.create_and_list_encryption_type This scenario firstly creates a volume type, secondly creates an encryption type for the volume type, thirdly lists all encryption types. Change-Id: I437a3cd01f68c3cd28c1e2fff6ea81d395fd64c1 --- rally-jobs/cinder.yaml | 20 +++++++++++++ .../openstack/scenarios/cinder/utils.py | 10 +++++++ .../scenarios/cinder/volume_types.py | 24 +++++++++++++++ .../create-and-list-encryption-type.json | 30 +++++++++++++++++++ .../create-and-list-encryption-type.yaml | 19 ++++++++++++ .../openstack/scenarios/cinder/test_utils.py | 8 +++++ .../scenarios/cinder/test_volume_types.py | 14 +++++++++ 7 files changed, 125 insertions(+) create mode 100644 samples/tasks/scenarios/cinder/create-and-list-encryption-type.json create mode 100644 samples/tasks/scenarios/cinder/create-and-list-encryption-type.yaml diff --git a/rally-jobs/cinder.yaml b/rally-jobs/cinder.yaml index fb17a9eb..edd6e243 100755 --- a/rally-jobs/cinder.yaml +++ b/rally-jobs/cinder.yaml @@ -869,6 +869,26 @@ failure_rate: max: 0 + CinderVolumeTypes.create_and_list_encryption_type: + - + args: + specs: + provider: "LuksEncryptor" + cipher: "aes-xts-plain64" + key_size: 512 + control_location: "front-end" + runner: + type: "constant" + times: 4 + 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/scenarios/cinder/utils.py b/rally/plugins/openstack/scenarios/cinder/utils.py index 9e2b6a21..e543ec14 100644 --- a/rally/plugins/openstack/scenarios/cinder/utils.py +++ b/rally/plugins/openstack/scenarios/cinder/utils.py @@ -453,3 +453,13 @@ class CinderScenario(scenario.OpenStackScenario): """ return self.admin_clients("cinder").volume_encryption_types.create( volume_type, specs) + + @atomic.action_timer("cinder.list_encryption_type") + def _list_encryption_type(self, search_opts=None): + """List all volume encryption types. + + :param search_opts: Options used when search for encryption types + :return: a list of :class: VolumeEncryptionType instances + """ + return self.admin_clients("cinder").volume_encryption_types.list( + search_opts) diff --git a/rally/plugins/openstack/scenarios/cinder/volume_types.py b/rally/plugins/openstack/scenarios/cinder/volume_types.py index 821d3b71..23175915 100644 --- a/rally/plugins/openstack/scenarios/cinder/volume_types.py +++ b/rally/plugins/openstack/scenarios/cinder/volume_types.py @@ -56,3 +56,27 @@ class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderScenario): """ volume_type = self._create_volume_type(**kwargs) self._create_encryption_type(volume_type, specs) + + +@validation.required_services(consts.Service.CINDER) +@validation.required_openstack(admin=True) +@scenario.configure(context={"admin_cleanup": ["cinder"]}, + name="CinderVolumeTypes.create_and_list_" + "encryption_type") +class CreateAndListEncryptionType(cinder_utils.CinderScenario): + + def run(self, specs, search_opts=None, **kwargs): + """Create and list encryption type + + This scenario firstly creates a volume type, secondly creates an + encryption type for the volume type, thirdly lists all encryption + types. + + :param specs: the encryption type specifications to add + :param search_opts: Options used when search for encryption types + :param kwargs: Optional parameters used during volume + type creation. + """ + volume_type = self._create_volume_type(**kwargs) + self._create_encryption_type(volume_type, specs) + self._list_encryption_type(search_opts) diff --git a/samples/tasks/scenarios/cinder/create-and-list-encryption-type.json b/samples/tasks/scenarios/cinder/create-and-list-encryption-type.json new file mode 100644 index 00000000..10abfadd --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-list-encryption-type.json @@ -0,0 +1,30 @@ +{ + "CinderVolumeTypes.create_and_list_encryption_type": [ + { + "args": { + "specs": { + "provider": "LuksEncryptor", + "cipher": "aes-xts-plain64", + "key_size": 512, + "control_location": "front-end" + } + }, + "runner": { + "type": "constant", + "times": 4, + "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-encryption-type.yaml b/samples/tasks/scenarios/cinder/create-and-list-encryption-type.yaml new file mode 100644 index 00000000..2b2ce29e --- /dev/null +++ b/samples/tasks/scenarios/cinder/create-and-list-encryption-type.yaml @@ -0,0 +1,19 @@ + CinderVolumeTypes.create_and_list_encryption_type: + - + args: + specs: + provider: "LuksEncryptor" + cipher: "aes-xts-plain64" + key_size: 512 + control_location: "front-end" + runner: + type: "constant" + times: 4 + 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_utils.py b/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py index 4c143d46..2c558889 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_utils.py @@ -400,6 +400,14 @@ class CinderScenarioTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(self.scenario.atomic_actions(), "cinder.create_encryption_type") + def test__list_encryption_type(self): + return_encryption_types_list = self.scenario._list_encryption_type() + client = self.admin_clients("cinder") + self.assertEqual(client.volume_encryption_types.list.return_value, + return_encryption_types_list) + self._test_atomic_action_timer(self.scenario.atomic_actions(), + "cinder.list_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 001f30c3..3cef8758 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py @@ -43,3 +43,17 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase): fakeargs="fakeargs") scenario._create_encryption_type.assert_called_once_with( scenario._create_volume_type.return_value, "fakespecs") + + def test_create_and_list_encryption_type(self): + scenario = volume_types.CreateAndListEncryptionType(self.context) + scenario._create_volume_type = mock.Mock() + scenario._create_encryption_type = mock.Mock() + scenario._list_encryption_type = mock.Mock() + scenario.run(specs="fakespecs", search_opts="fakeopts", + 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") + scenario._list_encryption_type.assert_called_once_with( + "fakeopts")