diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/base.py b/whitebox_neutron_tempest_plugin/tests/scenario/base.py index cdc6881..809dcb1 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/base.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/base.py @@ -159,7 +159,9 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): def find_node_client(self, node_name): for node in self.nodes: - if node['name'] == node_name: + # we want to make sure we are comparing short names + # in this case either short or long node_name will work + if node['name'].split('.')[0] == node_name.split('.')[0]: return node['client'] def find_different_compute_host(self, exclude_hosts): @@ -172,15 +174,12 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): "Not able to find a different compute than: {}".format( exclude_hosts)) - @classmethod - def get_full_name(cls, hostname): - compute_hosts = [ - host['hypervisor_hostname'] for host - in cls.os_admin.hv_client.list_hypervisors()['hypervisors']] - for host_name in compute_hosts: - if hostname in host_name: - return host_name - return hostname + def get_node_full_name(self, node_name): + for node in self.nodes: + # we want to make sure we are comparing short names + # in this case either short or long node_name will work + if node['name'].split('.')[0] == node_name.split('.')[0]: + return node['client'].exec_command('hostname -f').strip() def get_network_type(self, network_id): network_details = self.os_admin.network_client.show_network( @@ -331,12 +330,9 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): for host in cls.nodes_data: if not local_utils.host_responds_to_ping(host['ip']): continue - host['name'] = cls.get_full_name( - host['client'].exec_command('hostname').strip()) - host['full_name'] = cls.get_full_name( - host['client'].exec_command('hostname -f').strip()) - host['is_compute'] = (host['full_name'] in compute_hosts) - host['is_networker'] = (host['full_name'] in l3_agent_hosts) + host['name'] = host['client'].exec_command('hostname -f').strip() + host['is_compute'] = (host['name'] in compute_hosts) + host['is_networker'] = (host['name'] in l3_agent_hosts) if WB_CONF.openstack_type == 'devstack': # Here we are checking if there are controller-specific # processes running on the node @@ -1059,7 +1055,10 @@ class TrafficFlowTest(BaseTempestWhiteboxTestCase): cmd).strip().splitlines() for line in output: for node in cls.nodes: - if node['name'] == line.split()[0]: + # split('.')[0] ensures that we always compare short names. + # This will work even if for some reason one value is short + # (can happen in get pods output) and another is long(fqdn). + if line.split()[0].split('.')[0] == node['name'].split('.')[0]: node['ovs_pod'] = line.split()[1] def _start_captures(self, filters, scenario='north_south', interface=None): @@ -1295,7 +1294,7 @@ class BaseTempestTestCaseOvn(BaseTempestWhiteboxTestCase): cmd = "{} get chassis {} hostname".format(self.sbctl, self.chassis_id) LOG.debug("Running '{}' on the master node".format(cmd)) res = self.run_on_master_controller(cmd) - return res.replace('"', '').split('.')[0] + return self.get_node_full_name(res.replace('"', '')) def get_router_gateway_chassis_list(self, router_port_id): cmd = (self.nbctl + " lrp-get-gateway-chassis lrp-" + router_port_id) @@ -1305,7 +1304,7 @@ class BaseTempestTestCaseOvn(BaseTempestWhiteboxTestCase): def get_router_gateway_chassis_by_id(self, chassis_id): res = self.run_on_master_controller( self.sbctl + " get chassis " + chassis_id + " hostname").rstrip() - return res.replace('"', '').split('.')[0] + return self.get_node_full_name(res.replace('"', '')) def get_router_port_gateway_mtu(self, router_port_id): cmd = (self.nbctl + " get logical_router_port lrp-" + router_port_id + diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py index 9f29d08..f119ebd 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py @@ -898,7 +898,7 @@ class OvnDvrAdvancedTest(base.BaseTempestTestCaseAdvanced, for vm in [vm1, vm2]: nic = local_utils.get_default_interface(vm['ssh_client']) self.expected_routing_nodes.append( - self.get_host_for_server(vm['id']).split('.')[0]) + self.get_host_for_server(vm['id'])) vip_ssh_client = ssh.Client( vip_fip['floating_ip_address'], self.username, @@ -1012,7 +1012,7 @@ class OvnDvrAdvancedTest(base.BaseTempestTestCaseAdvanced, for vm in [vm1, vm2]: nic = local_utils.get_default_interface(vm['ssh_client']) self.expected_routing_nodes.append( - self.get_host_for_server(vm['id']).split('.')[0]) + self.get_host_for_server(vm['id'])) # checking whether an external IPv6 subnet exists or not ip_versions = [