Merge "Follow up for I4660043fcccec6721e197c4d77390744e356c59e"

This commit is contained in:
Zuul 2020-03-31 21:19:25 +00:00 committed by Gerrit Code Review
commit 09d56749ea
6 changed files with 26 additions and 32 deletions

View File

@ -37,7 +37,6 @@ class BaseWhiteboxComputeTest(base.BaseV2ComputeAdminTest):
cls.servers_client = cls.os_admin.servers_client
cls.flavors_client = cls.os_admin.flavors_client
cls.service_client = cls.os_admin.services_client
cls.hypervisor_client = cls.os_admin.hypervisor_client
cls.image_client = cls.os_admin.image_client_v2
cls.admin_migration_client = cls.os_admin.migrations_client
@ -100,24 +99,25 @@ class BaseWhiteboxComputeTest(base.BaseV2ComputeAdminTest):
return new_image['id']
def get_ctrlplane_address(self, compute_hostname):
def get_ctlplane_address(self, compute_hostname):
"""Return the appropriate host address depending on a deployment.
In TripleO deployments the Undercloud does not have DNS entries for
the compute hosts. This method checks if there are 'DNS' mappings of
the provided hostname to it's control plane IP address and returns it.
the provided hostname to its control plane IP address and returns it.
For Devstack deployments, no such parameters will exist and the method
will just return compute_hostname
:param compute_hostname: str the compute hostname
:return str simply pass the provided compute_hostname back or
return the associated control plane IP address
:return: The address to be used to access the compute host. For
devstack deployments, this is compute_host itself. For
TripleO, it needs to be looked up in the configuration.
"""
if not CONF.whitebox.ctrlplane_addresses:
if not CONF.whitebox.ctlplane_addresses:
return compute_hostname
if compute_hostname in CONF.whitebox.ctrlplane_addresses:
return CONF.whitebox.ctrlplane_addresses[compute_hostname]
if compute_hostname in CONF.whitebox.ctlplane_addresses:
return CONF.whitebox.ctlplane_addresses[compute_hostname]
raise exceptions.CtrlplaneAddressResolutionError(host=compute_hostname)
@ -133,7 +133,7 @@ class BaseWhiteboxComputeTest(base.BaseV2ComputeAdminTest):
def get_server_xml(self, server_id):
server = self.servers_client.show_server(server_id)
host = server['server']['OS-EXT-SRV-ATTR:host']
cntrlplane_addr = self.get_ctrlplane_address(host)
cntrlplane_addr = self.get_ctlplane_address(host)
server_instance_name = self.servers_client.show_server(
server_id)['server']['OS-EXT-SRV-ATTR:instance_name']

View File

@ -334,15 +334,8 @@ class CPUThreadPolicyTest(BasePinningTest):
"""
siblings = {}
if CONF.whitebox.hypervisors:
try:
host_address = CONF.whitebox.hypervisors[host]
except KeyError:
raise exceptions.CtrlplaneAddressResolutionError(host=host)
else:
host_address = host
virshxml = clients.VirshXMLClient(host_address)
host = self.get_ctlplane_address(host)
virshxml = clients.VirshXMLClient(host)
capxml = virshxml.capabilities()
root = ET.fromstring(capxml)
cpu_cells = root.findall('./host/topology/cells/cell/cpus')
@ -489,7 +482,7 @@ class NUMALiveMigrationTest(BasePinningTest):
return set([len(cpu_list) for cpu_list in chain(*args)])
def test_cpu_pinning(self):
host1, host2 = [self.get_ctrlplane_address(host) for host in
host1, host2 = [self.get_ctlplane_address(host) for host in
self.list_compute_hosts()]
numaclient_1 = clients.NUMAClient(host1)
@ -555,7 +548,7 @@ class NUMALiveMigrationTest(BasePinningTest):
# Live migrate server_b to server_a's compute, adding the second
# NUMA node's CPUs to vcpu_pin_set
host_a = self.get_host_other_than(server_b['id'])
host_a_addr = self.get_ctrlplane_address(host_a)
host_a_addr = self.get_ctlplane_address(host_a)
host_a_sm = clients.ServiceManager(host_a_addr, 'nova-compute')
numaclient_a = clients.NUMAClient(host_a_addr)
topo_a = numaclient_a.get_host_topology()
@ -594,7 +587,7 @@ class NUMALiveMigrationTest(BasePinningTest):
def test_emulator_threads(self):
# Need 4 CPUs on each host
host1, host2 = [self.get_ctrlplane_address(host) for host in
host1, host2 = [self.get_ctlplane_address(host) for host in
self.list_compute_hosts()]
for host in [host1, host2]:
@ -656,7 +649,7 @@ class NUMALiveMigrationTest(BasePinningTest):
self.delete_server(server_b['id'])
def test_hugepages(self):
host_a, host_b = [self.get_ctrlplane_address(host) for host in
host_a, host_b = [self.get_ctlplane_address(host) for host in
self.list_compute_hosts()]
numaclient_a = clients.NUMAClient(host_a)

View File

@ -70,7 +70,7 @@ class VolumesAdminNegativeTest(base.BaseWhiteboxComputeTest,
self.assertGreater(
len(disks_after_attach),
len(disks_before_attach))
host = self.get_ctrlplane_address(server['OS-EXT-SRV-ATTR:host'])
host = self.get_ctlplane_address(server['OS-EXT-SRV-ATTR:host'])
# stop the nova_libvirt service
clients.ServiceManager(host, 'nova-libvirt').stop()

View File

@ -40,13 +40,13 @@ general_opts = [
default=False,
help='Deployment is containerized.'),
cfg.DictOpt(
'ctrlplane_addresses',
'ctlplane_addresses',
help="Dictionary of control plane addresses. The keys are the "
"compute hostnames as they appear in the OS-EXT-SRV-ATTR:host "
"field of Nova's show server details API. The values are the "
"control plane addresses. For example:"
""
" ctrlplane_addresses = compute-0.localdomain:172.16.42.11,"
" ctlplane_addresses = compute-0.localdomain:172.16.42.11,"
" compute-1.localdomain:172.16.42.10"
""
"While this looks like a poor man's DNS, this is needed "

View File

@ -17,7 +17,7 @@ from tempest.lib import exceptions
class CtrlplaneAddressResolutionError(exceptions.TempestException):
message = "Unable to find IP in conf. for host: %(host)s."
message = "Unable to find address in conf. Host: %(host)s."
class MissingServiceSectionException(exceptions.TempestException):

View File

@ -44,17 +44,18 @@ class ComputeBaseTestCase(base.WhiteboxPluginTestCase):
self.test_class.service_client = mock.Mock()
self.test_class.servers_client.show_server = fake_show_server
self.test_class.service_client.list_services = fake_list_services
self.flags(hypervisors={'fake-host': 'fake-ip',
'fake-host2': 'fake-ip2'}, group='whitebox')
self.flags(ctlplane_addresses={'fake-host': 'fake-ip',
'fake-host2': 'fake-ip2'},
group='whitebox')
def test_get_ctrlplane_address(self):
def test_get_ctlplane_address(self):
self.assertEqual('fake-ip',
self.test_class.get_ctrlplane_address('fake-host'))
self.test_class.get_ctlplane_address('fake-host'))
@mock.patch.object(compute_base.LOG, 'error')
def test_get_ctrlplane_address_keyerror(self, mock_log):
def test_get_ctlplane_address_keyerror(self, mock_log):
self.assertRaises(exceptions.CtrlplaneAddressResolutionError,
self.test_class.get_ctrlplane_address, 'missing-id')
self.test_class.get_ctlplane_address, 'missing-id')
def test_list_compute_hosts(self):
self.assertItemsEqual(['fake-host', 'fake-host2'],