From 764c584fa98f4d586c18fd929f38eff8d27285c6 Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Fri, 12 Jun 2015 14:14:55 +0300 Subject: [PATCH] [Manila] Add scenario for attach of security service to share network List of changes: - Added support of 'attach-security-service-to-share-network' operation. - Added benchmark for creating security service and share network and attaching the former to the latter. Change-Id: Icc6fe65ddf796603e7f507b62c2f6c76a030c400 --- rally-jobs/rally-manila.yaml | 21 ++++++++++++++++ .../openstack/scenarios/manila/shares.py | 16 ++++++++++++ .../openstack/scenarios/manila/utils.py | 14 +++++++++++ ...ach-security-service-to-share-network.json | 25 +++++++++++++++++++ ...ach-security-service-to-share-network.yaml | 16 ++++++++++++ .../openstack/scenarios/manila/test_shares.py | 18 +++++++++++++ .../openstack/scenarios/manila/test_utils.py | 15 +++++++++++ 7 files changed, 125 insertions(+) create mode 100644 samples/tasks/scenarios/manila/attach-security-service-to-share-network.json create mode 100644 samples/tasks/scenarios/manila/attach-security-service-to-share-network.yaml diff --git a/rally-jobs/rally-manila.yaml b/rally-jobs/rally-manila.yaml index 2d177db2..b489ed25 100644 --- a/rally-jobs/rally-manila.yaml +++ b/rally-jobs/rally-manila.yaml @@ -110,3 +110,24 @@ failure_rate: max: 0 {% endfor %} + + ManilaShares.attach_security_service_to_share_network: + {% for s in ("ldap", "kerberos", "active_directory") %} + - + args: + security_service_type: {{s}} + runner: + type: "constant" + times: 10 + concurrency: 10 + context: + users: + tenants: 1 + users_per_tenant: 1 + quotas: + manila: + share_networks: -1 + sla: + failure_rate: + max: 0 + {% endfor %} diff --git a/rally/plugins/openstack/scenarios/manila/shares.py b/rally/plugins/openstack/scenarios/manila/shares.py index 95d010e6..3009f995 100644 --- a/rally/plugins/openstack/scenarios/manila/shares.py +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -166,3 +166,19 @@ class ManilaShares(utils.ManilaScenario): description=description, ) self._delete_security_service(security_service) + + @validation.required_services(consts.Service.MANILA) + @validation.required_openstack(users=True) + @base.scenario(context={"cleanup": ["manila"]}) + def attach_security_service_to_share_network(self, + security_service_type="ldap"): + """Attaches security service to share network. + + :param security_service_type: type of security service to use. + Should be one of following: 'ldap', 'kerberos' or + 'active_directory'. + """ + sn = self._create_share_network() + ss = self._create_security_service( + security_service_type=security_service_type) + self._add_security_service_to_share_network(sn, ss) diff --git a/rally/plugins/openstack/scenarios/manila/utils.py b/rally/plugins/openstack/scenarios/manila/utils.py index ef531a34..e2d2cf7b 100644 --- a/rally/plugins/openstack/scenarios/manila/utils.py +++ b/rally/plugins/openstack/scenarios/manila/utils.py @@ -217,3 +217,17 @@ class ManilaScenario(base.Scenario): update_resource=utils.get_from_manager(), timeout=CONF.benchmark.manila_share_delete_timeout, check_interval=CONF.benchmark.manila_share_delete_poll_interval) + + @base.atomic_action_timer("manila.add_security_service_to_share_network") + def _add_security_service_to_share_network(self, share_network, + security_service): + """Associate given security service with a share network. + + :param share_network: ID or instance of :class:`ShareNetwork`. + :param security_service: ID or instance of :class:`SecurityService`. + :returns: instance of :class:`ShareNetwork`. + """ + share_network = self.clients( + "manila").share_networks.add_security_service( + share_network, security_service) + return share_network diff --git a/samples/tasks/scenarios/manila/attach-security-service-to-share-network.json b/samples/tasks/scenarios/manila/attach-security-service-to-share-network.json new file mode 100644 index 00000000..3b35181e --- /dev/null +++ b/samples/tasks/scenarios/manila/attach-security-service-to-share-network.json @@ -0,0 +1,25 @@ +{ + "ManilaShares.attach_security_service_to_share_network": [ + { + "args": { + "security_service_type": "active_directory" + }, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 10 + }, + "context": { + "users": { + "tenants": 1, + "users_per_tenant": 1 + }, + "quotas": { + "manila": { + "share_networks": -1 + } + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/attach-security-service-to-share-network.yaml b/samples/tasks/scenarios/manila/attach-security-service-to-share-network.yaml new file mode 100644 index 00000000..bf16af73 --- /dev/null +++ b/samples/tasks/scenarios/manila/attach-security-service-to-share-network.yaml @@ -0,0 +1,16 @@ +--- + ManilaShares.attach_security_service_to_share_network: + - + args: + security_service_type: "active_directory" + runner: + type: "constant" + times: 10 + concurrency: 10 + context: + users: + tenants: 1 + users_per_tenant: 1 + quotas: + manila: + share_networks: -1 diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py index 99d26965..fdaeda02 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py @@ -182,3 +182,21 @@ class ManilaSharesTestCase(test.TestCase): scenario._create_security_service.assert_called_once_with( **expected_params) scenario._delete_security_service.assert_called_once_with(fake_ss) + + @ddt.data("ldap", "kerberos", "active_directory") + def test_attach_security_service_to_share_network(self, + security_service_type): + scenario = shares.ManilaShares() + scenario._create_share_network = mock.MagicMock() + scenario._create_security_service = mock.MagicMock() + scenario._add_security_service_to_share_network = mock.MagicMock() + + scenario.attach_security_service_to_share_network( + security_service_type=security_service_type) + + scenario._create_share_network.assert_called_once_with() + scenario._create_security_service.assert_called_once_with( + security_service_type=security_service_type) + scenario._add_security_service_to_share_network.assert_has_calls([ + mock.call(scenario._create_share_network.return_value, + scenario._create_security_service.return_value)]) diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py index 8e6361ea..d422c0dd 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py @@ -185,3 +185,18 @@ class ManilaScenarioTestCase(test.ScenarioTestCase): mock_get_from_manager.assert_called_once_with() mock_wait_for_delete.assert_called_once_with( fake_ss, update_resource=mock.ANY, timeout=180, check_interval=2) + + def test__add_security_service_to_share_network(self): + fake_sn = mock.MagicMock() + fake_ss = mock.MagicMock() + + result = self.scenario._add_security_service_to_share_network( + share_network=fake_sn, security_service=fake_ss) + + self.assertEqual( + self.clients( + "manila").share_networks.add_security_service.return_value, + result) + self.clients( + "manila").share_networks.add_security_service.assert_has_calls([ + mock.call(fake_sn, fake_ss)])