diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/base.py b/whitebox_neutron_tempest_plugin/tests/scenario/base.py index df76f40..8ccafc8 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/base.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/base.py @@ -123,7 +123,7 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): server_details = self.os_admin.servers_client.show_server(server_id) return server_details['server']['OS-EXT-SRV-ATTR:host'] - def get_shortname_for_server(self, server_id): + def get_host_shortname_for_server(self, server_id): return self.get_host_for_server(server_id).split('.')[0] @classmethod @@ -176,7 +176,7 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): for node in self.nodes: if not node['is_compute']: continue - if node['is_compute'] and not node['name'] in exclude_hosts: + if node['is_compute'] and not node['short_name'] in exclude_hosts: return node['name'] raise self.skipException( "Not able to find a different compute than: {}".format( @@ -624,7 +624,8 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): kwargs.pop("scheduler_hints", None) if exclude_hosts: exclude_hosts_ignored = False - if kwargs.get('host') and (kwargs['host'] in exclude_hosts): + if kwargs.get('host') and ( + kwargs['host'].split('.')[0] in exclude_hosts): exclude_hosts_ignored = True LOG.debug("'exclude_hosts' parameter contains same value as " "'host' so it will be ignored, i.e. 'host' will be " @@ -647,12 +648,14 @@ class BaseTempestWhiteboxTestCase(base.BaseTempestTestCase): self.addCleanup(test_utils.call_and_ignore_notfound_exc, servers_client.delete_server, server['id']) + # wait for VM ACTIVE to get its host; otherwise host may be None + self.wait_for_server_active(server, client=servers_client) if exclude_hosts and not exclude_hosts_ignored: - if self.get_host_for_server(server['id']) in exclude_hosts: + if (self.get_host_shortname_for_server(server['id']) + in exclude_hosts): self.fail("Failed to spawn a server on a host other than in " "this list: '{}'. Can not proceed.".format( ' '.join(exclude_hosts))) - self.wait_for_server_active(server, client=servers_client) port = network_client.list_ports( network_id=network['id'], device_id=server['id'])['ports'][0] 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 acc9d3a..ecbaad2 100644 --- a/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_dvr_ovn.py @@ -142,7 +142,7 @@ class OvnDvrBase(base.TrafficFlowTest, base.BaseTempestTestCaseOvn): self.server = self._create_server( exclude_hosts=self.exclude_hosts) - self.compute = self.get_shortname_for_server( + self.compute = self.get_host_shortname_for_server( self.server['server']['id']) self.exclude_hosts.append(self.compute) @@ -252,7 +252,7 @@ class OvnDvrTest(OvnDvrBase): ext_vm['port']['fixed_ips'][0]['ip_address'], self.username, pkey=self.keypair['private_key']) ssh_client = self.ext_vm_ssh_client - ext_vm_host = self.get_shortname_for_server( + ext_vm_host = self.get_host_shortname_for_server( ext_vm['server']['id']) # expected_routing_nodes should not have duplicates expected_routing_nodes = list(set([self.compute, ext_vm_host])) @@ -324,7 +324,7 @@ class OvnDvrTest(OvnDvrBase): """ self._setup() server2 = self._create_server(exclude_hosts=self.exclude_hosts) - compute2 = self.get_shortname_for_server( + compute2 = self.get_host_shortname_for_server( server2['server']['id']) LOG.debug("compute = {}, compute2 = {}".format(self.compute, compute2)) if self.compute == compute2: @@ -399,7 +399,7 @@ class OvnDvrTest(OvnDvrBase): CONF.validation.image_ssh_user, pkey=self.keypair['private_key'], proxy_client=self.server_ssh_client) - server2_host = self.get_shortname_for_server( + server2_host = self.get_host_shortname_for_server( server2['server']['id']) # verify N/S connection with self.server @@ -437,13 +437,13 @@ class OvnDvrTest(OvnDvrBase): block_migration=block_migration) self.wait_for_server_active( self.server['server'], client=self.os_admin.servers_client) - new_host = self.get_shortname_for_server( + new_host = self.get_host_shortname_for_server( self.server['server']['id']) self.assertNotEqual(self.compute, new_host, 'Server1 did not migrate') # migrate server2 compute_names = [ node['name'] for node in self.nodes - if node['is_compute'] and node['name'] not in ( + if node['is_compute'] and node['short_name'] not in ( new_host, server2_host)] host = random.choice(compute_names) self.os_admin.servers_client.live_migrate_server( @@ -452,7 +452,7 @@ class OvnDvrTest(OvnDvrBase): self.wait_for_server_active( server2['server'], client=self.os_admin.servers_client) - new_server2_host = self.get_shortname_for_server( + new_server2_host = self.get_host_shortname_for_server( server2['server']['id']) self.assertNotEqual(server2_host, new_server2_host, 'Server2 did not migrate') @@ -524,7 +524,7 @@ class OvnDvrTest(OvnDvrBase): else {}) servers.append(self._create_server( network=networks[i], scheduler_hints=scheduler_hints)) - servers_host.append(self.get_shortname_for_server( + servers_host.append(self.get_host_shortname_for_server( servers[i]['server']['id'])) servers_fip_mac.append(self.get_fip_port_details( servers[i]['fip'])['mac_address']) @@ -548,7 +548,7 @@ class OvnDvrTest(OvnDvrBase): def get_mac_mapping_for_vm(vm): return self.get_mac_mappings( self.find_node_client( - self.get_shortname_for_server(vm['server']['id'])), + self.get_host_shortname_for_server(vm['server']['id'])), 'datacentre') def get_expected_macs_for_vlan_tenant(): @@ -591,14 +591,14 @@ class OvnDvrTest(OvnDvrBase): else: compute_names = [ node['name'] for node in self.nodes - if node['is_compute'] and node['name'] not in ( + if node['is_compute'] and node['short_name'] not in ( new_servers_host[0], servers_host[1])] host = random.choice(compute_names) self.os_admin.servers_client.live_migrate_server( server['server']['id'], host=host, block_migration=block_migration) self.wait_for_server_active(server['server']) - new_servers_host.append(self.get_shortname_for_server( + new_servers_host.append(self.get_host_shortname_for_server( server['server']['id'])) self.assertNotEqual(servers_host[i], new_servers_host[i], 'Server%d did not migrate' % i) @@ -698,7 +698,7 @@ class OvnDvrTest(OvnDvrBase): port_id=test_server['port']['id'], floating_network_id=CONF.network.public_network_id)['floatingip'] fip_port_mac = self.get_fip_port_details(fip)['mac_address'] - test_server_compute = self.get_shortname_for_server( + test_server_compute = self.get_host_shortname_for_server( test_server['server']['id']) self.check_north_south_icmp_flow( dst_ip=self.gateway_external_ip, @@ -880,7 +880,7 @@ class OvnDvrAdvancedTest(base.BaseTempestTestCaseAdvanced, ip, self.username, pkey=self.keypair['private_key'], proxy_client=ext_vm_ssh_client) - ext_vm_host = self.get_shortname_for_server( + ext_vm_host = self.get_host_shortname_for_server( ext_vm['server']['id']) if ext_vm_host not in self.expected_routing_nodes: self.expected_routing_nodes.append(ext_vm_host) @@ -935,7 +935,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_shortname_for_server(vm['id'])) + self.get_host_shortname_for_server(vm['id'])) vip_ssh_client = ssh.Client( vip_fip['floating_ip_address'], self.username, @@ -1035,7 +1035,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_shortname_for_server(vm['id'])) + self.get_host_shortname_for_server(vm['id'])) # checking whether an external IPv6 subnet exists or not ip_versions = [