Add nova.ListAndGetHypervisors

The scenario fist list all hypervisors,then get detailed information
of the listed hypervisors in trun.

Change-Id: I62d10ba42c7dfdfa75e61a04af7028deb99bbdfb
This commit is contained in:
zhangzhang 2016-09-19 02:47:56 -04:00
parent 5ca1625aa2
commit 343a83d772
7 changed files with 118 additions and 0 deletions

View File

@ -642,6 +642,23 @@
failure_rate: failure_rate:
max: 0 max: 0
NovaHypervisors.list_and_get_hypervisors:
-
args:
detailed: True
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
NovaImages.list_images: NovaImages.list_images:
- -
args: args:

View File

@ -16,6 +16,7 @@
from rally import consts from rally import consts
from rally.plugins.openstack import scenario from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.nova import utils from rally.plugins.openstack.scenarios.nova import utils
from rally.task import atomic
from rally.task import validation from rally.task import validation
@ -34,3 +35,26 @@ class NovaHypervisors(utils.NovaScenario):
detailed information about all of them detailed information about all of them
""" """
self._list_hypervisors(detailed) self._list_hypervisors(detailed)
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure(name="NovaHypervisors.list_and_get_hypervisors")
class ListAndGetHypervisors(utils.NovaScenario):
"""Benchmark scenario for Nova hypervisors."""
def run(self, detailed=True):
"""List and Get hypervisors.
The scenario fist list all hypervisors,then get detailed information
of the listed hypervisors in trun.
Measure the "nova hypervisor-show" command performance.
:param detailed: True if the hypervisor listing should contain
detailed information about all of them
"""
hypervisors = self._list_hypervisors(detailed)
with atomic.ActionTimer(self, "nova.get_hypervisor"):
for hypervisor in hypervisors:
self._get_hypervisor(hypervisor)

View File

@ -863,6 +863,18 @@ class NovaScenario(scenario.OpenStackScenario):
"""List hypervisors.""" """List hypervisors."""
return self.admin_clients("nova").hypervisors.list(detailed) return self.admin_clients("nova").hypervisors.list(detailed)
@atomic.optional_action_timer("nova.get_hypervisor")
def _get_hypervisor(self, hypervisor):
"""Get a specific hypervisor.
:param hypervisor: Hypervisor to get.
:param atomic_action: True if this is atomic action. added and
handled by the optional_action_timer()
decorator.
:returns: Hypervisor object
"""
return self.admin_clients("nova").hypervisors.get(hypervisor)
@atomic.action_timer("nova.lock_server") @atomic.action_timer("nova.lock_server")
def _lock_server(self, server): def _lock_server(self, server):
"""Lock the given server. """Lock the given server.

View File

@ -0,0 +1,25 @@
{
"NovaHypervisors.list_and_get_hypervisors": [
{
"args": {
"detailed": true
},
"runner": {
"type": "constant",
"concurrency": 2,
"times": 2
},
"context": {
"users": {
"tenants": 3,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,16 @@
---
NovaHypervisors.list_and_get_hypervisors:
-
args:
detailed: True
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -29,3 +29,15 @@ class NovaHypervisorsTestCase(test.ScenarioTestCase):
scenario._list_hypervisors = mock.Mock() scenario._list_hypervisors = mock.Mock()
scenario.list_hypervisors(detailed=False) scenario.list_hypervisors(detailed=False)
scenario._list_hypervisors.assert_called_once_with(False) scenario._list_hypervisors.assert_called_once_with(False)
def test_list_and_get_hypervisors(self):
scenario = hypervisors.ListAndGetHypervisors(self.context)
scenario._list_hypervisors = mock.MagicMock(detailed=False)
scenario._get_hypervisor = mock.MagicMock()
scenario.run(detailed=False)
scenario._list_hypervisors.assert_called_once_with(False)
for hypervisor in scenario._list_hypervisors.return_value:
scenario._get_hypervisor.assert_called_once_with(hypervisor)
self._test_atomic_action_timer(scenario.atomic_actions(),
"nova.get_hypervisor")

View File

@ -841,6 +841,18 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(nova_scenario.atomic_actions(), self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_hypervisors") "nova.list_hypervisors")
def test__get_hypervisor(self):
hypervisor = mock.Mock()
nova_scenario = utils.NovaScenario()
result = nova_scenario._get_hypervisor(hypervisor)
self.assertEqual(
self.admin_clients("nova").hypervisors.get.return_value,
result)
self.admin_clients("nova").hypervisors.get.assert_called_once_with(
hypervisor)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.get_hypervisor")
def test__list_images(self): def test__list_images(self):
nova_scenario = utils.NovaScenario() nova_scenario = utils.NovaScenario()
result = nova_scenario._list_images(detailed=False, fakearg="fakearg") result = nova_scenario._list_images(detailed=False, fakearg="fakearg")