Add nova.ListAndGetHosts scenario
List all nova hosts,and get detailed information Measure the "nova host-describe" command performance. Change-Id: I10d4b9a4f118f671c6eb91a67b178ecdf08b8a54
This commit is contained in:
parent
07fe83bef1
commit
6fda6dfe2b
@ -1171,6 +1171,21 @@
|
|||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
|
||||||
|
NovaHosts.list_and_get_hosts:
|
||||||
|
-
|
||||||
|
args: {}
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
concurrency: 2
|
||||||
|
times: 5
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 3
|
||||||
|
users_per_tenant: 2
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
|
||||||
NovaServices.list_services:
|
NovaServices.list_services:
|
||||||
-
|
-
|
||||||
runner:
|
runner:
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
@ -37,3 +38,23 @@ class ListHosts(utils.NovaScenario):
|
|||||||
availability-zones
|
availability-zones
|
||||||
"""
|
"""
|
||||||
self._list_hosts(zone)
|
self._list_hosts(zone)
|
||||||
|
|
||||||
|
|
||||||
|
@validation.required_services(consts.Service.NOVA)
|
||||||
|
@validation.required_openstack(admin=True)
|
||||||
|
@scenario.configure(name="NovaHosts.list_and_get_hosts")
|
||||||
|
class ListAndGetHosts(utils.NovaScenario):
|
||||||
|
|
||||||
|
def run(self, zone=None):
|
||||||
|
"""List all nova hosts,and get detailed information fot this hosts.
|
||||||
|
|
||||||
|
Measure the "nova host-describe" command performance.
|
||||||
|
|
||||||
|
:param zone: List nova hosts in an availability-zone.
|
||||||
|
None (default value) means list hosts in all
|
||||||
|
availability-zones
|
||||||
|
"""
|
||||||
|
hosts = self._list_hosts(zone)
|
||||||
|
with atomic.ActionTimer(self, "nova.get_%s_hosts" % len(hosts)):
|
||||||
|
for host in hosts:
|
||||||
|
self._get_host(host.host_name, atomic_action=False)
|
||||||
|
@ -1013,6 +1013,18 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
return self.admin_clients("nova").hosts.list(zone)
|
return self.admin_clients("nova").hosts.list(zone)
|
||||||
|
|
||||||
|
@atomic.optional_action_timer("nova.get_host")
|
||||||
|
def _get_host(self, host_name):
|
||||||
|
"""Describe a specific host.
|
||||||
|
|
||||||
|
:param host_name: host name to get.
|
||||||
|
:param atomic_action: True if this is atomic action. added and
|
||||||
|
handled by the optional_action_timer()
|
||||||
|
decorator.
|
||||||
|
:returns: host object
|
||||||
|
"""
|
||||||
|
return self.admin_clients("nova").hosts.get(host_name)
|
||||||
|
|
||||||
@atomic.action_timer("nova.list_services")
|
@atomic.action_timer("nova.list_services")
|
||||||
def _list_services(self, host=None, binary=None):
|
def _list_services(self, host=None, binary=None):
|
||||||
"""return all nova service details
|
"""return all nova service details
|
||||||
|
23
samples/tasks/scenarios/nova/list-and-get-hosts.json
Normal file
23
samples/tasks/scenarios/nova/list-and-get-hosts.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"NovaHosts.list_and_get_hosts": [
|
||||||
|
{
|
||||||
|
"args": {},
|
||||||
|
"runner": {
|
||||||
|
"type": "constant",
|
||||||
|
"concurrency": 2,
|
||||||
|
"times": 10
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"users": {
|
||||||
|
"tenants": 2,
|
||||||
|
"users_per_tenant": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sla": {
|
||||||
|
"failure_rate": {
|
||||||
|
"max": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
samples/tasks/scenarios/nova/list-and-get-hosts.yaml
Normal file
15
samples/tasks/scenarios/nova/list-and-get-hosts.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
NovaHosts.list_and_get_hosts:
|
||||||
|
-
|
||||||
|
args: {}
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
concurrency: 2
|
||||||
|
times: 10
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 2
|
||||||
|
users_per_tenant: 2
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
@ -26,3 +26,18 @@ class NovaHostsTestCase(test.TestCase):
|
|||||||
scenario._list_hosts = mock.Mock()
|
scenario._list_hosts = mock.Mock()
|
||||||
scenario.run(zone=None)
|
scenario.run(zone=None)
|
||||||
scenario._list_hosts.assert_called_once_with(None)
|
scenario._list_hosts.assert_called_once_with(None)
|
||||||
|
|
||||||
|
def test_list_and_get_hosts(self):
|
||||||
|
fake_hosts = [mock.Mock(host_name="fake_hostname")]
|
||||||
|
scenario = hosts.ListAndGetHosts()
|
||||||
|
scenario._list_hosts = mock.MagicMock(
|
||||||
|
return_value=fake_hosts)
|
||||||
|
scenario._get_host = mock.MagicMock()
|
||||||
|
scenario.run(zone="nova")
|
||||||
|
|
||||||
|
scenario._list_hosts.assert_called_once_with("nova")
|
||||||
|
scenario._get_host.assert_called_once_with(
|
||||||
|
"fake_hostname", atomic_action=False)
|
||||||
|
|
||||||
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
|
"nova.get_1_hosts")
|
||||||
|
@ -889,6 +889,17 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
"nova.search_hypervisors")
|
"nova.search_hypervisors")
|
||||||
|
|
||||||
|
def test__get_host(self):
|
||||||
|
nova_scenario = utils.NovaScenario()
|
||||||
|
result = nova_scenario._get_host("host_name")
|
||||||
|
self.assertEqual(
|
||||||
|
self.admin_clients("nova").hosts.get.return_value,
|
||||||
|
result)
|
||||||
|
self.admin_clients("nova").hosts.get.assert_called_once_with(
|
||||||
|
"host_name")
|
||||||
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
|
"nova.get_host")
|
||||||
|
|
||||||
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")
|
||||||
|
Loading…
Reference in New Issue
Block a user