From b779c01ab23f5f88cf624102a913c756791c9a05 Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Fri, 12 Jun 2015 13:22:25 +0300 Subject: [PATCH] [Manila] Add scenario for creation and deletion of security services List of changes: - Added support of 'create' and 'delete' operations for security services. - Added benchmark for creating and deleting security services. Change-Id: I26ba499f24d0cc0036fbc3c7b2e7f7239ffad583 --- rally-jobs/rally-manila.yaml | 25 +++++++++++ .../openstack/scenarios/manila/shares.py | 32 +++++++++++++ .../openstack/scenarios/manila/utils.py | 45 +++++++++++++++++++ .../create-security-service-and-delete.json | 27 +++++++++++ .../create-security-service-and-delete.yaml | 20 +++++++++ .../openstack/scenarios/manila/test_shares.py | 34 ++++++++++++++ .../openstack/scenarios/manila/test_utils.py | 37 +++++++++++++++ 7 files changed, 220 insertions(+) create mode 100644 samples/tasks/scenarios/manila/create-security-service-and-delete.json create mode 100644 samples/tasks/scenarios/manila/create-security-service-and-delete.yaml diff --git a/rally-jobs/rally-manila.yaml b/rally-jobs/rally-manila.yaml index 4b327f2282..2d177db214 100644 --- a/rally-jobs/rally-manila.yaml +++ b/rally-jobs/rally-manila.yaml @@ -85,3 +85,28 @@ sla: failure_rate: max: 0 + + ManilaShares.create_security_service_and_delete: + {% for s in ("ldap", "kerberos", "active_directory") %} + - + args: + security_service_type: {{s}} + dns_ip: "fake_dns_ip" + server: "fake-server" + domain: "fake_domain" + user: "fake_user" + password: "fake_password" + name: "fake_name" + description: "fake_description" + runner: + type: "constant" + times: 10 + concurrency: 10 + context: + users: + tenants: 1 + users_per_tenant: 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 9c96475bff..95d010e6a3 100644 --- a/rally/plugins/openstack/scenarios/manila/shares.py +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -134,3 +134,35 @@ class ManilaShares(utils.ManilaScenario): "host", "status", "share_network" and "project_id". """ self._list_share_servers(search_opts=search_opts) + + @validation.required_services(consts.Service.MANILA) + @validation.required_openstack(users=True) + @base.scenario(context={"cleanup": ["manila"]}) + def create_security_service_and_delete(self, security_service_type, + dns_ip=None, server=None, + domain=None, user=None, + password=None, name=None, + description=None): + """Creates security service and then deletes. + + :param security_service_type: security service type, permitted values + are 'ldap', 'kerberos' or 'active_directory'. + :param dns_ip: dns ip address used inside tenant's network + :param server: security service server ip address or hostname + :param domain: security service domain + :param user: security identifier used by tenant + :param password: password used by user + :param name: security service name + :param description: security service description + """ + security_service = self._create_security_service( + security_service_type=security_service_type, + dns_ip=dns_ip, + server=server, + domain=domain, + user=user, + password=password, + name=name, + description=description, + ) + self._delete_security_service(security_service) diff --git a/rally/plugins/openstack/scenarios/manila/utils.py b/rally/plugins/openstack/scenarios/manila/utils.py index 4808c0c7f4..ef531a3446 100644 --- a/rally/plugins/openstack/scenarios/manila/utils.py +++ b/rally/plugins/openstack/scenarios/manila/utils.py @@ -172,3 +172,48 @@ class ManilaScenario(base.Scenario): share_servers = self.admin_clients("manila").share_servers.list( search_opts=search_opts) return share_servers + + @base.atomic_action_timer("manila.create_security_service") + def _create_security_service(self, security_service_type, dns_ip=None, + server=None, domain=None, user=None, + password=None, name=None, description=None): + """Create security service. + + 'Security service' is data container in Manila that stores info + about auth services 'Active Directory', 'Kerberos' and catalog + service 'LDAP' that should be used for shares. + + :param security_service_type: security service type, permitted values + are 'ldap', 'kerberos' or 'active_directory'. + :param dns_ip: dns ip address used inside tenant's network + :param server: security service server ip address or hostname + :param domain: security service domain + :param user: security identifier used by tenant + :param password: password used by user + :param name: security service name + :param description: security service description + :returns: instance of :class:`SecurityService` + """ + security_service = self.clients("manila").security_services.create( + type=security_service_type, + dns_ip=dns_ip, + server=server, + domain=domain, + user=user, + password=password, + name=name, + description=description) + return security_service + + @base.atomic_action_timer("manila.delete_security_service") + def _delete_security_service(self, security_service): + """Delete security service. + + :param security_service: instance of :class:`SecurityService`. + """ + security_service.delete() + utils.wait_for_delete( + security_service, + update_resource=utils.get_from_manager(), + timeout=CONF.benchmark.manila_share_delete_timeout, + check_interval=CONF.benchmark.manila_share_delete_poll_interval) diff --git a/samples/tasks/scenarios/manila/create-security-service-and-delete.json b/samples/tasks/scenarios/manila/create-security-service-and-delete.json new file mode 100644 index 0000000000..4d547e2b2c --- /dev/null +++ b/samples/tasks/scenarios/manila/create-security-service-and-delete.json @@ -0,0 +1,27 @@ +{ + "ManilaShares.create_security_service_and_delete": [ + { + "args": { + "security_service_type": "active_directory", + "dns_ip": "fake_dns_ip", + "server": "fake-server", + "domain": "fake_domain", + "user": "fake_user", + "password": "fake_password", + "name": "fake_name", + "description": "fake_description" + }, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 10 + }, + "context": { + "users": { + "tenants": 1, + "users_per_tenant": 1 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/create-security-service-and-delete.yaml b/samples/tasks/scenarios/manila/create-security-service-and-delete.yaml new file mode 100644 index 0000000000..09c3848a16 --- /dev/null +++ b/samples/tasks/scenarios/manila/create-security-service-and-delete.yaml @@ -0,0 +1,20 @@ +--- + ManilaShares.create_security_service_and_delete: + - + args: + security_service_type: "active_directory" + dns_ip: "fake_dns_ip" + server: "fake-server" + domain: "fake_domain" + user: "fake_user" + password: "fake_password" + name: "fake_name" + description: "fake_description" + runner: + type: "constant" + times: 10 + concurrency: 10 + context: + users: + tenants: 1 + users_per_tenant: 1 diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py index 80cdffdbe3..99d2696512 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py @@ -148,3 +148,37 @@ class ManilaSharesTestCase(test.TestCase): scenario._list_share_servers.assert_called_once_with( search_opts=search_opts) + + @ddt.data( + {"security_service_type": "fake_type"}, + {"name": "foo_name", + "security_service_type": "fake_type", + "dns_ip": "fake_dns_ip", + "server": "fake_server", + "domain": "fake_domain", + "user": "fake_user", + "password": "fake_password", + "description": "fake_description"}, + ) + def test_create_security_service_and_delete(self, params): + fake_ss = mock.MagicMock() + scenario = shares.ManilaShares() + scenario._create_security_service = mock.MagicMock( + return_value=fake_ss) + scenario._delete_security_service = mock.MagicMock() + expected_params = { + "security_service_type": params.get("security_service_type"), + "dns_ip": params.get("dns_ip"), + "server": params.get("server"), + "domain": params.get("domain"), + "user": params.get("user"), + "password": params.get("password"), + "name": params.get("name"), + "description": params.get("description"), + } + + scenario.create_security_service_and_delete(**params) + + scenario._create_security_service.assert_called_once_with( + **expected_params) + scenario._delete_security_service.assert_called_once_with(fake_ss) diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py index bfe6105498..8e6361eaa8 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py @@ -148,3 +148,40 @@ class ManilaScenarioTestCase(test.ScenarioTestCase): self.admin_clients( "manila").share_servers.list.assert_called_once_with( search_opts=params.get("search_opts", None)) + + @ddt.data("ldap", "kerberos", "active_directory") + def test__create_security_service(self, ss_type): + fake_ss = mock.Mock() + self.clients("manila").security_services.create.return_value = fake_ss + data = { + "security_service_type": ss_type, + "dns_ip": "fake_dns_ip", + "server": "fake_server", + "domain": "fake_domain", + "user": "fake_user", + "password": "fake_password", + "name": "fake_name", + "description": "fake_description", + } + expected = dict(data) + expected["type"] = expected.pop("security_service_type") + + result = self.scenario._create_security_service(**data) + + self.assertEqual(fake_ss, result) + self.clients( + "manila").security_services.create.assert_called_once_with( + **expected) + + @mock.patch(BM_UTILS + "get_from_manager") + @mock.patch(BM_UTILS + "wait_for_delete") + def test__delete_security_service(self, mock_wait_for_delete, + mock_get_from_manager): + fake_ss = mock.MagicMock() + + self.scenario._delete_security_service(fake_ss) + + fake_ss.delete.assert_called_once_with() + 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)