Add nova.getHypervisorStatistics

Get hypervisor statistics over all compute nodes.

Measure the "nova hypervisor-stats" command performance.

Change-Id: Id7b2ff3e9f85c9f99c3f701637b8be32f9e23fe4
This commit is contained in:
zhangzhang 2016-10-14 08:00:08 -04:00
parent cd38ba531d
commit c698e96df9
7 changed files with 90 additions and 0 deletions

View File

@ -662,6 +662,20 @@
failure_rate:
max: 0
NovaHypervisors.statistics_hypervisors:
-
args: {}
runner:
type: "constant"
times: 5
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
NovaHypervisors.list_and_get_hypervisors:
-

View File

@ -62,6 +62,19 @@ class ListAndGetHypervisors(utils.NovaScenario):
self._get_hypervisor(hypervisor)
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure(name="NovaHypervisors.statistics_hypervisors")
class StatisticsHypervisors(utils.NovaScenario):
def run(self):
"""Get hypervisor statistics over all compute nodes.
Measure the "nova hypervisor-stats" command performance.
"""
self._statistics_hypervisors()
@validation.required_services(consts.Service.NOVA)
@validation.required_openstack(admin=True)
@scenario.configure(name="NovaHypervisors.list_and_get_uptime_hypervisors")

View File

@ -863,6 +863,14 @@ class NovaScenario(scenario.OpenStackScenario):
"""List hypervisors."""
return self.admin_clients("nova").hypervisors.list(detailed)
@atomic.action_timer("nova.statistics_hypervisors")
def _statistics_hypervisors(self):
"""Get hypervisor statistics over all compute nodes.
:returns: Hypervisor statistics
"""
return self.admin_clients("nova").hypervisors.statistics()
@atomic.optional_action_timer("nova.get_hypervisor")
def _get_hypervisor(self, hypervisor):
"""Get a specific hypervisor.

View File

@ -0,0 +1,23 @@
{
"NovaHypervisors.statistics_hypervisors": [
{
"args": {},
"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,15 @@
---
NovaHypervisors.statistics_hypervisors:
-
args: {}
runner:
type: "constant"
times: 2
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -38,6 +38,12 @@ class NovaHypervisorsTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(scenario.atomic_actions(),
"nova.get_hypervisor")
def test_statistics_hypervisors(self):
scenario = hypervisors.StatisticsHypervisors(self.context)
scenario._statistics_hypervisors = mock.Mock()
scenario.run()
scenario._statistics_hypervisors.assert_called_once_with()
def test_list_and_get_uptime_hypervisors(self):
scenario = hypervisors.ListAndGetUptimeHypervisors(self.context)
scenario._list_hypervisors = mock.MagicMock(detailed=False)

View File

@ -841,6 +841,17 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.list_hypervisors")
def test__statistics_hypervisors(self):
nova_scenario = utils.NovaScenario()
result = nova_scenario._statistics_hypervisors()
self.assertEqual(
self.admin_clients("nova").hypervisors.statistics.return_value,
result)
(self.admin_clients("nova").hypervisors.statistics.
assert_called_once_with())
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.statistics_hypervisors")
def test__get_hypervisor(self):
hypervisor = mock.Mock()
nova_scenario = utils.NovaScenario()