Fix list_and_get_host scenario bug
The scenario measure the "nova host-describe <hostname>" command performance, the code will describe all hosts which are listed by "nova host-list" command performance. but the hostname seems to must be compute host's name, so we only can describe compute hosts. Change-Id: I037264580570e68b8cd587280f50660d89566051 Closes-Bug: #1675254
This commit is contained in:
parent
4afdc9550c
commit
0132987d91
@ -1146,7 +1146,6 @@
|
||||
|
||||
NovaHosts.list_and_get_hosts:
|
||||
-
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
concurrency: 2
|
||||
|
@ -16,7 +16,6 @@
|
||||
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
|
||||
|
||||
|
||||
@ -46,7 +45,7 @@ class ListHosts(utils.NovaScenario):
|
||||
class ListAndGetHosts(utils.NovaScenario):
|
||||
|
||||
def run(self, zone=None):
|
||||
"""List all nova hosts,and get detailed information fot this hosts.
|
||||
"""List all nova hosts, and get detailed information for compute hosts.
|
||||
|
||||
Measure the "nova host-describe" command performance.
|
||||
|
||||
@ -54,7 +53,7 @@ class ListAndGetHosts(utils.NovaScenario):
|
||||
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)):
|
||||
hosts = self._list_hosts(zone, service="compute")
|
||||
|
||||
for host in hosts:
|
||||
self._get_host(host.host_name, atomic_action=False)
|
||||
self._get_host(host.host_name)
|
||||
|
@ -1046,7 +1046,7 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
"""Returns list of all os-aggregates."""
|
||||
return self.admin_clients("nova").aggregates.list()
|
||||
|
||||
@atomic.action_timer("nova.list_availbility_zones")
|
||||
@atomic.action_timer("nova.list_availability_zones")
|
||||
def _list_availability_zones(self, detailed=True):
|
||||
"""List availability-zones.
|
||||
|
||||
@ -1057,22 +1057,23 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
return self.admin_clients("nova").availability_zones.list(detailed)
|
||||
|
||||
@atomic.action_timer("nova.list_hosts")
|
||||
def _list_hosts(self, zone=None):
|
||||
def _list_hosts(self, zone=None, service=None):
|
||||
"""List nova hosts.
|
||||
|
||||
:param zone: List all hosts in the given nova availability-zone ID
|
||||
:param service: Name of service type to filter
|
||||
:returns: Nova host list
|
||||
"""
|
||||
return self.admin_clients("nova").hosts.list(zone)
|
||||
hosts = self.admin_clients("nova").hosts.list(zone)
|
||||
if service:
|
||||
hosts = [host for host in hosts if host.service == service]
|
||||
return hosts
|
||||
|
||||
@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)
|
||||
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
"NovaHosts.list_and_get_hosts": [
|
||||
{
|
||||
"args": {},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"concurrency": 2,
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
NovaHosts.list_and_get_hosts:
|
||||
-
|
||||
args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
concurrency: 2
|
||||
|
@ -30,14 +30,12 @@ class NovaHostsTestCase(test.TestCase):
|
||||
def test_list_and_get_hosts(self):
|
||||
fake_hosts = [mock.Mock(host_name="fake_hostname")]
|
||||
scenario = hosts.ListAndGetHosts()
|
||||
scenario._list_hosts = mock.MagicMock(
|
||||
scenario._list_hosts = mock.create_autospec(scenario._list_hosts,
|
||||
return_value=fake_hosts)
|
||||
scenario._get_host = mock.MagicMock()
|
||||
scenario._get_host = mock.create_autospec(scenario._get_host,
|
||||
"fake_hostname")
|
||||
scenario.run(zone="nova")
|
||||
|
||||
scenario._list_hosts.assert_called_once_with("nova")
|
||||
scenario._list_hosts.assert_called_once_with("nova", service="compute")
|
||||
scenario._get_host.assert_called_once_with(
|
||||
"fake_hostname", atomic_action=False)
|
||||
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"nova.get_1_hosts")
|
||||
"fake_hostname")
|
||||
|
@ -1069,16 +1069,24 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
||||
avail_zones_client = self.admin_clients("nova").availability_zones
|
||||
avail_zones_client.list.assert_called_once_with(True)
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.list_availbility_zones")
|
||||
"nova.list_availability_zones")
|
||||
|
||||
@ddt.data({},
|
||||
{"zone": "foo_zone"})
|
||||
{"zone": "foo_zone"},
|
||||
{"zone": "foo_zone", "service": "some"})
|
||||
@ddt.unpack
|
||||
def test__list_hosts(self, zone=None):
|
||||
def test__list_hosts(self, zone=None, service=None):
|
||||
|
||||
hosts = [mock.Mock(service="foo"), mock.Mock(service="some")]
|
||||
|
||||
self.admin_clients("nova").hosts.list.return_value = hosts
|
||||
nova_scenario = utils.NovaScenario()
|
||||
result = nova_scenario._list_hosts(zone)
|
||||
self.assertEqual(self.admin_clients("nova").hosts.list.return_value,
|
||||
result)
|
||||
|
||||
result = nova_scenario._list_hosts(zone, service=service)
|
||||
|
||||
if service:
|
||||
hosts = [h for h in hosts if h.service == service]
|
||||
self.assertEqual(hosts, result)
|
||||
self.admin_clients("nova").hosts.list.assert_called_once_with(zone)
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.list_hosts")
|
||||
|
Loading…
Reference in New Issue
Block a user