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
This commit is contained in:
Sirisha Areti 2015-09-08 13:37:12 -07:00
parent 7e00a81f06
commit bb9ecad478
7 changed files with 134 additions and 0 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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
}
}
}
]
}

View File

@ -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

View File

@ -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")

View File

@ -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)