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:
|
NovaHosts.list_and_get_hosts:
|
||||||
-
|
-
|
||||||
args: {}
|
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
concurrency: 2
|
concurrency: 2
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
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
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ class ListHosts(utils.NovaScenario):
|
|||||||
class ListAndGetHosts(utils.NovaScenario):
|
class ListAndGetHosts(utils.NovaScenario):
|
||||||
|
|
||||||
def run(self, zone=None):
|
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.
|
Measure the "nova host-describe" command performance.
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ class ListAndGetHosts(utils.NovaScenario):
|
|||||||
None (default value) means list hosts in all
|
None (default value) means list hosts in all
|
||||||
availability-zones
|
availability-zones
|
||||||
"""
|
"""
|
||||||
hosts = self._list_hosts(zone)
|
hosts = self._list_hosts(zone, service="compute")
|
||||||
with atomic.ActionTimer(self, "nova.get_%s_hosts" % len(hosts)):
|
|
||||||
for host in hosts:
|
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."""
|
"""Returns list of all os-aggregates."""
|
||||||
return self.admin_clients("nova").aggregates.list()
|
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):
|
def _list_availability_zones(self, detailed=True):
|
||||||
"""List availability-zones.
|
"""List availability-zones.
|
||||||
|
|
||||||
@ -1057,22 +1057,23 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
return self.admin_clients("nova").availability_zones.list(detailed)
|
return self.admin_clients("nova").availability_zones.list(detailed)
|
||||||
|
|
||||||
@atomic.action_timer("nova.list_hosts")
|
@atomic.action_timer("nova.list_hosts")
|
||||||
def _list_hosts(self, zone=None):
|
def _list_hosts(self, zone=None, service=None):
|
||||||
"""List nova hosts.
|
"""List nova hosts.
|
||||||
|
|
||||||
:param zone: List all hosts in the given nova availability-zone ID
|
:param zone: List all hosts in the given nova availability-zone ID
|
||||||
|
:param service: Name of service type to filter
|
||||||
:returns: Nova host list
|
: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")
|
@atomic.optional_action_timer("nova.get_host")
|
||||||
def _get_host(self, host_name):
|
def _get_host(self, host_name):
|
||||||
"""Describe a specific host.
|
"""Describe a specific host.
|
||||||
|
|
||||||
:param host_name: host name to get.
|
: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
|
:returns: host object
|
||||||
"""
|
"""
|
||||||
return self.admin_clients("nova").hosts.get(host_name)
|
return self.admin_clients("nova").hosts.get(host_name)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"NovaHosts.list_and_get_hosts": [
|
"NovaHosts.list_and_get_hosts": [
|
||||||
{
|
{
|
||||||
"args": {},
|
|
||||||
"runner": {
|
"runner": {
|
||||||
"type": "constant",
|
"type": "constant",
|
||||||
"concurrency": 2,
|
"concurrency": 2,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
---
|
---
|
||||||
NovaHosts.list_and_get_hosts:
|
NovaHosts.list_and_get_hosts:
|
||||||
-
|
-
|
||||||
args: {}
|
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
concurrency: 2
|
concurrency: 2
|
||||||
|
@ -30,14 +30,12 @@ class NovaHostsTestCase(test.TestCase):
|
|||||||
def test_list_and_get_hosts(self):
|
def test_list_and_get_hosts(self):
|
||||||
fake_hosts = [mock.Mock(host_name="fake_hostname")]
|
fake_hosts = [mock.Mock(host_name="fake_hostname")]
|
||||||
scenario = hosts.ListAndGetHosts()
|
scenario = hosts.ListAndGetHosts()
|
||||||
scenario._list_hosts = mock.MagicMock(
|
scenario._list_hosts = mock.create_autospec(scenario._list_hosts,
|
||||||
return_value=fake_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.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(
|
scenario._get_host.assert_called_once_with(
|
||||||
"fake_hostname", atomic_action=False)
|
"fake_hostname")
|
||||||
|
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
|
||||||
"nova.get_1_hosts")
|
|
||||||
|
@ -1069,16 +1069,24 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
avail_zones_client = self.admin_clients("nova").availability_zones
|
avail_zones_client = self.admin_clients("nova").availability_zones
|
||||||
avail_zones_client.list.assert_called_once_with(True)
|
avail_zones_client.list.assert_called_once_with(True)
|
||||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
"nova.list_availbility_zones")
|
"nova.list_availability_zones")
|
||||||
|
|
||||||
@ddt.data({},
|
@ddt.data({},
|
||||||
{"zone": "foo_zone"})
|
{"zone": "foo_zone"},
|
||||||
|
{"zone": "foo_zone", "service": "some"})
|
||||||
@ddt.unpack
|
@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()
|
nova_scenario = utils.NovaScenario()
|
||||||
result = nova_scenario._list_hosts(zone)
|
|
||||||
self.assertEqual(self.admin_clients("nova").hosts.list.return_value,
|
result = nova_scenario._list_hosts(zone, service=service)
|
||||||
result)
|
|
||||||
|
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.admin_clients("nova").hosts.list.assert_called_once_with(zone)
|
||||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
"nova.list_hosts")
|
"nova.list_hosts")
|
||||||
|
Loading…
Reference in New Issue
Block a user