Merge "Add nova.ListAndGetHypervisors"
This commit is contained in:
commit
a04dffe2b3
@ -662,6 +662,23 @@
|
||||
failure_rate:
|
||||
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:
|
||||
-
|
||||
args:
|
||||
|
@ -16,6 +16,7 @@
|
||||
from rally import consts
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.scenarios.nova import utils
|
||||
from rally.task import atomic
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
@ -36,3 +37,26 @@ class ListHypervisors(utils.NovaScenario):
|
||||
detailed information about all of them
|
||||
"""
|
||||
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)
|
||||
|
@ -863,6 +863,18 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
"""List hypervisors."""
|
||||
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")
|
||||
def _lock_server(self, server):
|
||||
"""Lock the given server.
|
||||
|
25
samples/tasks/scenarios/nova/list-and-get-hypervisors.json
Normal file
25
samples/tasks/scenarios/nova/list-and-get-hypervisors.json
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
16
samples/tasks/scenarios/nova/list-and-get-hypervisors.yaml
Normal file
16
samples/tasks/scenarios/nova/list-and-get-hypervisors.yaml
Normal 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
|
@ -25,3 +25,15 @@ class NovaHypervisorsTestCase(test.ScenarioTestCase):
|
||||
scenario._list_hypervisors = mock.Mock()
|
||||
scenario.run(detailed=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")
|
||||
|
@ -841,6 +841,18 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"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):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
result = nova_scenario._list_images(detailed=False, fakearg="fakearg")
|
||||
|
Loading…
Reference in New Issue
Block a user