diff --git a/rally-jobs/rally-manila-no-ss.yaml b/rally-jobs/rally-manila-no-ss.yaml new file mode 100644 index 00000000..ae7f9224 --- /dev/null +++ b/rally-jobs/rally-manila-no-ss.yaml @@ -0,0 +1,16 @@ +--- + ManilaShares.list_shares: + - + args: + detailed: True + runner: + type: "constant" + times: 10 + concurrency: 1 + context: + users: + tenants: 1 + users_per_tenant: 1 + sla: + failure_rate: + max: 0 diff --git a/rally-jobs/rally-manila.yaml b/rally-jobs/rally-manila.yaml new file mode 100644 index 00000000..ae7f9224 --- /dev/null +++ b/rally-jobs/rally-manila.yaml @@ -0,0 +1,16 @@ +--- + ManilaShares.list_shares: + - + args: + detailed: True + runner: + type: "constant" + times: 10 + concurrency: 1 + context: + users: + tenants: 1 + users_per_tenant: 1 + sla: + failure_rate: + max: 0 diff --git a/rally/consts.py b/rally/consts.py index cfd848c1..5b22ae1c 100644 --- a/rally/consts.py +++ b/rally/consts.py @@ -90,6 +90,7 @@ class _Service(utils.ImmutableMixin, utils.EnumMixin): NOVAV3 = "novav3" CINDER = "cinder" CINDERV2 = "cinderv2" + MANILA = "manila" EC2 = "ec2" GLANCE = "glance" CLOUD = "cloud" @@ -111,6 +112,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin): VOLUME = "volume" VOLUMEV2 = "volumev2" + SHARE = "share" EC2 = "ec2" IMAGE = "image" CLOUD = "cloudformation" @@ -136,6 +138,7 @@ class _ServiceType(utils.ImmutableMixin, utils.EnumMixin): self.COMPUTEV3: _Service.NOVAV3, self.VOLUME: _Service.CINDER, self.VOLUMEV2: _Service.CINDER, + self.SHARE: _Service.MANILA, self.EC2: _Service.EC2, self.IMAGE: _Service.GLANCE, self.CLOUD: _Service.CLOUD, diff --git a/rally/plugins/openstack/scenarios/manila/__init__.py b/rally/plugins/openstack/scenarios/manila/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rally/plugins/openstack/scenarios/manila/shares.py b/rally/plugins/openstack/scenarios/manila/shares.py new file mode 100644 index 00000000..e77390da --- /dev/null +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -0,0 +1,36 @@ +# Copyright 2015 Mirantis Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from rally.benchmark.scenarios import base +from rally.benchmark import validation +from rally import consts +from rally.plugins.openstack.scenarios.manila import utils + + +class ManilaShares(utils.ManilaScenario): + """Benchmark scenarios for Manila shares.""" + + @validation.required_services(consts.Service.MANILA) + @validation.required_openstack(users=True) + @base.scenario() + def list_shares(self, detailed=True, search_opts=None): + """Basic scenario for 'share list' operation. + + :param detailed: defines either to return detailed list of + objects or not. + :param search_opts: container of search opts such as + "name", "host", "share_type", etc. + """ + self._list_shares(detailed=detailed, search_opts=search_opts) diff --git a/rally/plugins/openstack/scenarios/manila/utils.py b/rally/plugins/openstack/scenarios/manila/utils.py new file mode 100644 index 00000000..8d4a3ff8 --- /dev/null +++ b/rally/plugins/openstack/scenarios/manila/utils.py @@ -0,0 +1,32 @@ +# Copyright 2015 Mirantis Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from rally.benchmark.scenarios import base + + +class ManilaScenario(base.Scenario): + """Base class for Manila scenarios with basic atomic actions.""" + + @base.atomic_action_timer("manila.list_shares") + def _list_shares(self, detailed=True, search_opts=None): + """Returns user shares list. + + :param detailed: defines either to return detailed list of + objects or not. + :param search_opts: container of search opts such as + "name", "host", "share_type", etc. + """ + return self.clients("manila").shares.list( + detailed=detailed, search_opts=search_opts) diff --git a/requirements.txt b/requirements.txt index f27b96bf..a92b8204 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,6 +26,7 @@ python-keystoneclient>=1.6.0 python-novaclient>=2.22.0 python-neutronclient>=2.3.11,<3 python-cinderclient>=1.2.1 +python-manilaclient>=1.0.4 python-heatclient>=0.3.0 python-ceilometerclient>=1.0.13 python-ironicclient>=0.2.1 diff --git a/samples/tasks/scenarios/manila/list-shares.json b/samples/tasks/scenarios/manila/list-shares.json new file mode 100644 index 00000000..0afb645d --- /dev/null +++ b/samples/tasks/scenarios/manila/list-shares.json @@ -0,0 +1,20 @@ +{ + "ManilaShares.list_shares": [ + { + "args": { + "detailed": true + }, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 1 + }, + "context": { + "users": { + "tenants": 1, + "users_per_tenant": 1 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/list-shares.yaml b/samples/tasks/scenarios/manila/list-shares.yaml new file mode 100644 index 00000000..0b89b86d --- /dev/null +++ b/samples/tasks/scenarios/manila/list-shares.yaml @@ -0,0 +1,13 @@ +--- + ManilaShares.list_shares: + - + args: + detailed: True + runner: + type: "constant" + times: 10 + concurrency: 1 + context: + users: + tenants: 1 + users_per_tenant: 1 diff --git a/test-requirements.txt b/test-requirements.txt index 7c7e080d..6694be22 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,6 +4,7 @@ hacking>=0.9.2,<0.10 coverage>=3.6 +ddt>=0.7.0 discover mock>=1.0 testrepository>=0.0.18 diff --git a/tests/unit/plugins/openstack/scenarios/manila/__init__.py b/tests/unit/plugins/openstack/scenarios/manila/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py new file mode 100644 index 00000000..2fa6a898 --- /dev/null +++ b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py @@ -0,0 +1,46 @@ +# Copyright 2015 Mirantis Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import ddt +import mock + +from rally.plugins.openstack.scenarios.manila import shares +from tests.unit import test + + +@ddt.ddt +class ManilaSharesTestCase(test.TestCase): + + @ddt.data( + {}, + {"detailed": True}, + {"detailed": False}, + {"search_opts": None}, + {"search_opts": {}}, + {"search_opts": {"foo": "bar"}}, + {"detailed": True, "search_opts": None}, + {"detailed": False, "search_opts": None}, + {"detailed": True, "search_opts": {"foo": "bar"}}, + {"detailed": False, "search_opts": {"quuz": "foo"}}, + ) + @ddt.unpack + def test_list_shares(self, detailed=True, search_opts=None): + scenario = shares.ManilaShares() + scenario._list_shares = mock.MagicMock() + + scenario.list_shares(detailed=detailed, search_opts=search_opts) + + scenario._list_shares.assert_called_once_with( + detailed=detailed, 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 new file mode 100644 index 00000000..0c7b99c9 --- /dev/null +++ b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py @@ -0,0 +1,48 @@ +# Copyright 2015 Mirantis Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import ddt +import mock + +from rally.plugins.openstack.scenarios.manila import utils +from tests.unit import test + +MANILA_UTILS = "rally.plugins.openstack.scenarios.manila.utils.ManilaScenario." + + +@ddt.ddt +class ManilaScenarioTestCase(test.TestCase): + + def setUp(self): + super(ManilaScenarioTestCase, self).setUp() + self.scenario = utils.ManilaScenario() + + @ddt.data( + {}, + {"detailed": False, "search_opts": None}, + {"detailed": True, "search_opts": {"name": "foo_sn"}}, + {"search_opts": {"project_id": "fake_project"}}, + ) + @mock.patch(MANILA_UTILS + "clients") + def test__list_shares(self, params, mock_clients): + fake_shares = ["foo", "bar"] + mock_clients.return_value.shares.list.return_value = fake_shares + + result = self.scenario._list_shares(**params) + + self.assertEqual(fake_shares, result) + mock_clients.return_value.shares.list.assert_called_once_with( + detailed=params.get("detailed", True), + search_opts=params.get("search_opts", None))