From bb9ecad478acf7ddf494e6add9717344896db48e Mon Sep 17 00:00:00 2001 From: Sirisha Areti Date: Tue, 8 Sep 2015 13:37:12 -0700 Subject: [PATCH] Adds nova image list plugin One of the functionalities Nova provides is listing images. This allows users to be able to consume the functionality, without having to go through Glance. (There are users who do not consume Glance). Currently, there isn't a benchmark provided by rally that does the above. This commit adds a plugin that calls nova client list method for Images, which will therefore be available for benchmarking. Includes functional and unit tests. Change-Id: If11d623bd5c9bf7f8c723908cf9e1e332de0639d --- rally-jobs/nova.yaml | 16 ++++++++ .../openstack/scenarios/nova/images.py | 37 +++++++++++++++++++ .../plugins/openstack/scenarios/nova/utils.py | 12 ++++++ samples/tasks/scenarios/nova/list-images.json | 20 ++++++++++ samples/tasks/scenarios/nova/list-images.yaml | 13 +++++++ .../openstack/scenarios/nova/test_images.py | 28 ++++++++++++++ .../openstack/scenarios/nova/test_utils.py | 8 ++++ 7 files changed, 134 insertions(+) create mode 100644 rally/plugins/openstack/scenarios/nova/images.py create mode 100644 samples/tasks/scenarios/nova/list-images.json create mode 100644 samples/tasks/scenarios/nova/list-images.yaml create mode 100644 tests/unit/plugins/openstack/scenarios/nova/test_images.py diff --git a/rally-jobs/nova.yaml b/rally-jobs/nova.yaml index 63b79adb..d18e00d9 100644 --- a/rally-jobs/nova.yaml +++ b/rally-jobs/nova.yaml @@ -465,6 +465,22 @@ failure_rate: max: 0 + NovaImages.list_images: + - + args: + detailed: True + runner: + type: "constant" + times: 5 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + NovaSecGroup.create_and_delete_secgroups: - args: diff --git a/rally/plugins/openstack/scenarios/nova/images.py b/rally/plugins/openstack/scenarios/nova/images.py new file mode 100644 index 00000000..0cc24a6d --- /dev/null +++ b/rally/plugins/openstack/scenarios/nova/images.py @@ -0,0 +1,37 @@ +# Copyright 2015: Workday, 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 NovaImages(utils.NovaScenario): + """Benchmark scenarios for Nova images.""" + + @validation.required_services(consts.Service.NOVA) + @validation.required_openstack(users=True) + @scenario.configure(context={"cleanup": ["nova"]}) + def list_images(self, detailed=True, **kwargs): + """List all images. + + Measure the "nova image-list" command performance. + + :param detailed: True if the image listing + should contain detailed information + :param kwargs: Optional additional arguments for image listing + """ + self._list_images(detailed, **kwargs) diff --git a/rally/plugins/openstack/scenarios/nova/utils.py b/rally/plugins/openstack/scenarios/nova/utils.py index 783a53eb..5d22bee9 100644 --- a/rally/plugins/openstack/scenarios/nova/utils.py +++ b/rally/plugins/openstack/scenarios/nova/utils.py @@ -461,6 +461,18 @@ class NovaScenario(scenario.OpenStackScenario): ) return image + @atomic.action_timer("nova.list_images") + def _list_images(self, detailed=False, **kwargs): + """List all images. + + :param detailed: True if the image listing + should contain detailed information + :param kwargs: Optional additional arguments for image listing + + :returns: Image list + """ + return self.clients("nova").images.list(detailed, **kwargs) + @atomic.action_timer("nova.create_keypair") def _create_keypair(self, **kwargs): """Create a keypair diff --git a/samples/tasks/scenarios/nova/list-images.json b/samples/tasks/scenarios/nova/list-images.json new file mode 100644 index 00000000..8620b5c6 --- /dev/null +++ b/samples/tasks/scenarios/nova/list-images.json @@ -0,0 +1,20 @@ +{ + "NovaImages.list_images": [ + { + "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-images.yaml b/samples/tasks/scenarios/nova/list-images.yaml new file mode 100644 index 00000000..94dd3b11 --- /dev/null +++ b/samples/tasks/scenarios/nova/list-images.yaml @@ -0,0 +1,13 @@ +--- + NovaImages.list_images: + - + 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_images.py b/tests/unit/plugins/openstack/scenarios/nova/test_images.py new file mode 100644 index 00000000..bfdf9026 --- /dev/null +++ b/tests/unit/plugins/openstack/scenarios/nova/test_images.py @@ -0,0 +1,28 @@ +# Copyright: 2015 Workday, 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 mock + +from rally.plugins.openstack.scenarios.nova import images +from tests.unit import test + + +class NovaImagesTestCase(test.TestCase): + + def test_list_images(self): + scenario = images.NovaImages() + scenario._list_images = mock.Mock() + scenario.list_images(detailed=False, fakearg="fakearg") + scenario._list_images.assert_called_once_with(False, 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 cd666333..a871e36e 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py @@ -778,6 +778,14 @@ class NovaScenarioTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(nova_scenario.atomic_actions(), "nova.list_hypervisors") + def test__list_images(self): + nova_scenario = utils.NovaScenario() + nova_scenario._list_images(detailed=False, fakearg="fakearg") + self.clients("nova").images.list.assert_called_once_with( + False, fakearg="fakearg") + self._test_atomic_action_timer(nova_scenario.atomic_actions(), + "nova.list_images") + def test__lock_server(self): server = mock.Mock() nova_scenario = utils.NovaScenario(context=self.context)