Fix exclude_hosts mechanism in _create_server method
Patch [1] broke the way tests specify that a VM has to be spawned on a host different from a provided list of exclude_hosts because the list of hosts includes shortnames instead of FQDN after [1] was merged. This patch fixes this problem. Besides that, the method `get_shortname_for_server` is renamed to `get_host_shortname_for_server` because what it really returns is the hypervisor/host name. [1] https://review.opendev.org/c/932348 Change-Id: I584565b42bfb691c224330ab96664ac9fec150c1
This commit is contained in:
parent
15692a9fa8
commit
3feaab6c99
@ -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]
|
||||
|
@ -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 = [
|
||||
|
Loading…
Reference in New Issue
Block a user