Add support for nova service-list

blueprint extend-api-benchmark-in-nova-scenarios

Change-Id: Iebe321d395c5eca8621b53cb3bb7659f0aae28e6
This commit is contained in:
Piyush Raman Srivastava 2016-02-18 11:43:57 -08:00
parent b225764180
commit 52aab67865
7 changed files with 122 additions and 0 deletions

View File

@ -946,3 +946,13 @@
sla:
failure_rate:
max: 0
NovaServices.list_services:
-
runner:
type: "constant"
times: 5
concurrency: 2
sla:
failure_rate:
max: 0

View File

@ -0,0 +1,40 @@
# Copyright 2016 IBM Corp.
# 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.common import logging
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils
from rally.task import validation
LOG = logging.getLogger(__name__)
class NovaServices(utils.NovaScenario):
"""Benchmark scenarios for Nova agents."""
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure()
def list_services(self, host=None, binary=None):
"""List all nova services.
Measure the "nova service-list" command performance.
:param host: List nova services on host
:param binary: List nova services matching given binary
"""
self._list_services(host, binary)

View File

@ -937,3 +937,12 @@ class NovaScenario(scenario.OpenStackScenario):
:returns: Nova host list
"""
return self.admin_clients("nova").hosts.list(zone)
@atomic.action_timer("nova.list_services")
def _list_services(self, host=None, binary=None):
"""return all nova service details
:param host: List all nova services on host
:param binary: List all nova services matching given binary
"""
return self.admin_clients("nova").services.list(host, binary)

View File

@ -0,0 +1,11 @@
{
"NovaServices.list_services": [
{
"runner": {
"type": "constant",
"concurrency": 2,
"times": 10
}
}
]
}

View File

@ -0,0 +1,7 @@
---
NovaServices.list_services:
-
runner:
type: "constant"
times: 10
concurrency: 2

View File

@ -0,0 +1,29 @@
# Copyright 2016 IBM Corp.
# 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 services
from tests.unit import test
class NovaServicesTestCase(test.TestCase):
def test_list_services(self):
scenario = services.NovaServices()
scenario._list_services = mock.Mock()
scenario.list_services(host="foo_host", binary="foo_hypervisor")
scenario._list_services.assert_called_once_with("foo_host",
"foo_hypervisor")

View File

@ -922,3 +922,19 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
self.admin_clients("nova").hosts.list.assert_called_once_with(zone)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_hosts")
@ddt.data({},
{"host": "foo_host"},
{"binary": "foo_binary"},
{"host": "foo_host", "binary": "foo_binary"})
@ddt.unpack
def test__list_services(self, host=None, binary=None):
nova_scenario = utils.NovaScenario()
self.admin_clients("nova").services.list.return_value = (
"services_list")
result = nova_scenario._list_services(host=host, binary=binary)
self.assertEqual("services_list", result)
self.admin_clients("nova").services.list.assert_called_once_with(
host, binary)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_services")