diff --git a/whitebox_tempest_plugin/api/compute/base.py b/whitebox_tempest_plugin/api/compute/base.py index d7487941..06299bc8 100644 --- a/whitebox_tempest_plugin/api/compute/base.py +++ b/whitebox_tempest_plugin/api/compute/base.py @@ -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'] diff --git a/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py b/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py index e7549914..58acd1a5 100644 --- a/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py +++ b/whitebox_tempest_plugin/api/compute/test_cpu_pinning.py @@ -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) diff --git a/whitebox_tempest_plugin/api/compute/test_volume_negative.py b/whitebox_tempest_plugin/api/compute/test_volume_negative.py index d3c869c2..1bd8431b 100644 --- a/whitebox_tempest_plugin/api/compute/test_volume_negative.py +++ b/whitebox_tempest_plugin/api/compute/test_volume_negative.py @@ -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() diff --git a/whitebox_tempest_plugin/config.py b/whitebox_tempest_plugin/config.py index 0f5034df..a2e3483a 100644 --- a/whitebox_tempest_plugin/config.py +++ b/whitebox_tempest_plugin/config.py @@ -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 " diff --git a/whitebox_tempest_plugin/exceptions.py b/whitebox_tempest_plugin/exceptions.py index 0e95b281..c54d6b2a 100644 --- a/whitebox_tempest_plugin/exceptions.py +++ b/whitebox_tempest_plugin/exceptions.py @@ -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): diff --git a/whitebox_tempest_plugin/tests/test_base.py b/whitebox_tempest_plugin/tests/test_base.py index 09d6859f..2620ceee 100644 --- a/whitebox_tempest_plugin/tests/test_base.py +++ b/whitebox_tempest_plugin/tests/test_base.py @@ -44,17 +44,18 @@ class UtilsTestCase(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'],