From 1f62a97138aa82dd8997b987dc3620837c72d5eb Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Fri, 12 Jun 2015 11:57:35 +0300 Subject: [PATCH] [Manila] Add benchmark for Manila list share servers operation List of changes: - Added support of 'list' operation for share servers. - Added benchmark for listing of share servers. Change-Id: Iea34c51eaf3cf73de52f882b09592a793a3159c1 --- rally-jobs/rally-manila.yaml | 12 ++++++++++++ .../openstack/scenarios/manila/shares.py | 13 +++++++++++++ .../plugins/openstack/scenarios/manila/utils.py | 12 ++++++++++++ .../scenarios/manila/list-share-servers.json | 14 ++++++++++++++ .../scenarios/manila/list-share-servers.yaml | 9 +++++++++ .../openstack/scenarios/manila/test_shares.py | 16 ++++++++++++++++ .../openstack/scenarios/manila/test_utils.py | 17 +++++++++++++++++ 7 files changed, 93 insertions(+) create mode 100644 samples/tasks/scenarios/manila/list-share-servers.json create mode 100644 samples/tasks/scenarios/manila/list-share-servers.yaml diff --git a/rally-jobs/rally-manila.yaml b/rally-jobs/rally-manila.yaml index b59087e8..4b327f22 100644 --- a/rally-jobs/rally-manila.yaml +++ b/rally-jobs/rally-manila.yaml @@ -73,3 +73,15 @@ sla: failure_rate: max: 0 + + ManilaShares.list_share_servers: + - + args: + search_opts: {} + runner: + type: "constant" + times: 10 + concurrency: 10 + sla: + failure_rate: + max: 0 diff --git a/rally/plugins/openstack/scenarios/manila/shares.py b/rally/plugins/openstack/scenarios/manila/shares.py index 39788db0..dad80dc6 100644 --- a/rally/plugins/openstack/scenarios/manila/shares.py +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -121,3 +121,16 @@ class ManilaShares(utils.ManilaScenario): detailed=detailed, search_opts=search_opts, ) + + @validation.required_services(consts.Service.MANILA) + @validation.required_openstack(admin=True) + @base.scenario() + def list_share_servers(self, search_opts=None): + """Lists share servers. + + Requires admin creds. + + :param search_opts: container of following search opts: + "host", "status", "share_network" and "project_id". + """ + self._list_share_servers(search_opts=search_opts) diff --git a/rally/plugins/openstack/scenarios/manila/utils.py b/rally/plugins/openstack/scenarios/manila/utils.py index 6679c9d6..c6df3458 100644 --- a/rally/plugins/openstack/scenarios/manila/utils.py +++ b/rally/plugins/openstack/scenarios/manila/utils.py @@ -160,3 +160,15 @@ class ManilaScenario(base.Scenario): share_networks = self.clients("manila").share_networks.list( detailed=detailed, search_opts=search_opts) return share_networks + + @base.atomic_action_timer("manila.list_share_servers") + def _list_share_servers(self, search_opts=None): + """List share servers. Admin only. + + :param search_opts: set of key-value pairs to filter share servers by. + Example: {"share_network": "share_network_name_or_id"} + :returns: list of instances of :class:`ShareServer` + """ + share_servers = self.admin_clients("manila").share_servers.list( + search_opts=search_opts) + return share_servers diff --git a/samples/tasks/scenarios/manila/list-share-servers.json b/samples/tasks/scenarios/manila/list-share-servers.json new file mode 100644 index 00000000..9f2a9e5b --- /dev/null +++ b/samples/tasks/scenarios/manila/list-share-servers.json @@ -0,0 +1,14 @@ +{ + "ManilaShares.list_share_servers": [ + { + "args": { + "search_opts": {} + }, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 10 + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/list-share-servers.yaml b/samples/tasks/scenarios/manila/list-share-servers.yaml new file mode 100644 index 00000000..b251e67d --- /dev/null +++ b/samples/tasks/scenarios/manila/list-share-servers.yaml @@ -0,0 +1,9 @@ +--- + ManilaShares.list_share_servers: + - + args: + search_opts: {} + runner: + type: "constant" + times: 10 + concurrency: 10 diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py index 85cbcc41..80cdffdb 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py @@ -132,3 +132,19 @@ class ManilaSharesTestCase(test.TestCase): **expected_create_params) scenario._list_share_networks.assert_called_once_with( **expected_list_params) + + @ddt.data( + {}, + {"search_opts": None}, + {"search_opts": {}}, + {"search_opts": {"foo": "bar"}}, + ) + def test_list_share_servers(self, search_opts): + scenario = shares.ManilaShares() + scenario.context = {"admin": {"endpoint": "fake_endpoint"}} + scenario._list_share_servers = mock.MagicMock() + + scenario.list_share_servers(search_opts=search_opts) + + scenario._list_share_servers.assert_called_once_with( + search_opts=search_opts) diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py index f715cebe..050710fa 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py @@ -131,3 +131,20 @@ class ManilaScenarioTestCase(test.ClientsTestCase): self.clients("manila").share_networks.list.assert_called_once_with( detailed=params.get("detailed", True), search_opts=params.get("search_opts", None)) + + @ddt.data( + {}, + {"search_opts": None}, + {"search_opts": {"project_id": "fake_project"}}, + ) + def test__list_share_servers(self, params): + fake_share_servers = ["foo", "bar"] + self.admin_clients("manila").share_servers.list.return_value = ( + fake_share_servers) + + result = self.scenario._list_share_servers(**params) + + self.assertEqual(fake_share_servers, result) + self.admin_clients( + "manila").share_servers.list.assert_called_once_with( + search_opts=params.get("search_opts", None))