Merge "Add nova.ListAndGetHypervisorUptime"
This commit is contained in:
commit
cd38ba531d
@ -679,6 +679,22 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaHypervisors.list_and_get_uptime_hypervisors:
|
||||
-
|
||||
args:
|
||||
detailed: True
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 5
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaImages.list_images:
|
||||
-
|
||||
args:
|
||||
|
@ -60,3 +60,25 @@ class ListAndGetHypervisors(utils.NovaScenario):
|
||||
with atomic.ActionTimer(self, "nova.get_hypervisor"):
|
||||
for hypervisor in hypervisors:
|
||||
self._get_hypervisor(hypervisor)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True)
|
||||
@scenario.configure(name="NovaHypervisors.list_and_get_uptime_hypervisors")
|
||||
class ListAndGetUptimeHypervisors(utils.NovaScenario):
|
||||
def run(self, detailed=True):
|
||||
"""List hypervisors,then display the uptime of it.
|
||||
|
||||
The scenario first list all hypervisors,then display
|
||||
the uptime of the listed hypervisors in trun.
|
||||
|
||||
Measure the "nova hypervisor-uptime" 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.uptime_hypervisor"):
|
||||
for hypervisor in hypervisors:
|
||||
self._uptime_hypervisor(hypervisor, atomic_action=False)
|
||||
|
@ -883,6 +883,18 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
server.lock()
|
||||
|
||||
@atomic.optional_action_timer("nova.uptime_hypervisor")
|
||||
def _uptime_hypervisor(self, hypervisor, atomic_action=False):
|
||||
"""Display the uptime of the specified 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.uptime(hypervisor)
|
||||
|
||||
@atomic.action_timer("nova.unlock_server")
|
||||
def _unlock_server(self, server):
|
||||
"""Unlock the given server.
|
||||
|
@ -0,0 +1,25 @@
|
||||
{
|
||||
"NovaHypervisors.list_and_get_uptime_hypervisors": [
|
||||
{
|
||||
"args": {
|
||||
"detailed": true
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"concurrency": 2,
|
||||
"times": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
NovaHypervisors.list_and_get_uptime_hypervisors:
|
||||
-
|
||||
args:
|
||||
detailed: True
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 2
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -37,3 +37,15 @@ class NovaHypervisorsTestCase(test.ScenarioTestCase):
|
||||
scenario._get_hypervisor.assert_called_once_with(hypervisor)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"nova.get_hypervisor")
|
||||
|
||||
def test_list_and_get_uptime_hypervisors(self):
|
||||
scenario = hypervisors.ListAndGetUptimeHypervisors(self.context)
|
||||
scenario._list_hypervisors = mock.MagicMock(detailed=False)
|
||||
scenario._uptime_hypervisor = mock.MagicMock()
|
||||
scenario.run(detailed=False)
|
||||
|
||||
scenario._list_hypervisors.assert_called_once_with(False)
|
||||
for hypervisor in scenario._list_hypervisors.return_value:
|
||||
scenario._uptime_hypervisor.assert_called_once_with(hypervisor)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"nova.uptime_hypervisor")
|
||||
|
@ -1119,3 +1119,12 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
"fake_agg", "fake_host")
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.aggregate_remove_host")
|
||||
|
||||
def test__uptime_hypervisor(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._uptime_hypervisor("fake_hostname")
|
||||
|
||||
self.admin_clients("nova").hypervisors.uptime.assert_called_once_with(
|
||||
"fake_hostname")
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.uptime_hypervisor")
|
||||
|
Loading…
Reference in New Issue
Block a user