diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index a713fbb1d2..6419626f9f 100644 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -860,3 +860,19 @@ sla: failure_rate: max: 0 + + NovaFlavors.list_flavors: + - + args: + detailed: True + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 diff --git a/rally/plugins/openstack/scenarios/nova/flavors.py b/rally/plugins/openstack/scenarios/nova/flavors.py new file mode 100644 index 0000000000..65a7cc1fa2 --- /dev/null +++ b/rally/plugins/openstack/scenarios/nova/flavors.py @@ -0,0 +1,38 @@ +# Copyright 2015: 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 import consts +from rally.plugins.openstack import scenario +from rally.plugins.openstack.scenarios.nova import utils +from rally.task import validation + + +class NovaFlavors(utils.NovaScenario): + """Benchmark scenarios for Nova flavors.""" + + @validation.required_services(consts.Service.NOVA) + @validation.required_openstack(users=True) + @scenario.configure(context={"cleanup": ["nova"]}) + def list_flavors(self, detailed=True, **kwargs): + """List all flavors. + + Measure the "nova flavor-list" command performance. + + :param detailed: True if the flavor listing + should contain detailed information + + :param kwargs: Optional additional arguments for flavor listing + """ + self._list_flavors(detailed, **kwargs) diff --git a/rally/plugins/openstack/scenarios/nova/utils.py b/rally/plugins/openstack/scenarios/nova/utils.py index 98b8859043..28eb017d4b 100644 --- a/rally/plugins/openstack/scenarios/nova/utils.py +++ b/rally/plugins/openstack/scenarios/nova/utils.py @@ -892,3 +892,14 @@ class NovaScenario(scenario.OpenStackScenario): :param net_id: The nova-network ID to delete """ return self.admin_clients("nova").networks.delete(net_id) + + @atomic.action_timer("nova.list_flavors") + def _list_flavors(self, detailed=True, **kwargs): + """List all flavors. + + :param kwargs: Optional additional arguments for flavor listing + :param detailed: True if the image listing + should contain detailed information + :returns: flavors list + """ + return self.clients("nova").flavors.list(detailed, **kwargs) diff --git a/samples/tasks/scenarios/nova/list-flavors.json b/samples/tasks/scenarios/nova/list-flavors.json new file mode 100644 index 0000000000..80b91a373b --- /dev/null +++ b/samples/tasks/scenarios/nova/list-flavors.json @@ -0,0 +1,20 @@ +{ + "NovaFlavors.list_flavors": [ + { + "runner": { + "type": "constant", + "concurrency": 2, + "times": 10 + }, + "args": { + "detailed": true + }, + "context": { + "users": { + "tenants": 3, + "users_per_tenant": 2 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/nova/list-flavors.yaml b/samples/tasks/scenarios/nova/list-flavors.yaml new file mode 100644 index 0000000000..0245f4a880 --- /dev/null +++ b/samples/tasks/scenarios/nova/list-flavors.yaml @@ -0,0 +1,13 @@ +--- + NovaFlavors.list_flavors: + - + args: + detailed: True + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 3 + users_per_tenant: 2 diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_flavors.py b/tests/unit/plugins/openstack/scenarios/nova/test_flavors.py new file mode 100644 index 0000000000..aa3284d561 --- /dev/null +++ b/tests/unit/plugins/openstack/scenarios/nova/test_flavors.py @@ -0,0 +1,28 @@ +# Copyright: 2015. +# 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 mock + +from rally.plugins.openstack.scenarios.nova import flavors +from tests.unit import test + + +class NovaFlavorsTestCase(test.TestCase): + + def test_list_flavors(self): + scenario = flavors.NovaFlavors() + scenario._list_flavors = mock.Mock() + scenario.list_flavors(detailed=True, fakearg="fakearg") + scenario._list_flavors.assert_called_once_with(True, fakearg="fakearg") diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py index 5c46a9bb9c..551b2b57f7 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py @@ -865,3 +865,13 @@ class NovaScenarioTestCase(test.ScenarioTestCase): self.assertEqual(return_netlabel, fake_net) self._test_atomic_action_timer(nova_scenario.atomic_actions(), "nova.create_network") + + def test__list_flavors(self): + nova_scenario = utils.NovaScenario() + self.clients("nova").flavors.list.return_value = "flavors_list" + result = nova_scenario._list_flavors(detailed=True, fakearg="fakearg") + self.assertEqual("flavors_list", result) + self.clients("nova").flavors.list.assert_called_once_with( + True, fakearg="fakearg") + self._test_atomic_action_timer(nova_scenario.atomic_actions(), + "nova.list_flavors")