Make test_z99_reboot_controller_galera_main_vip more stable
This test was sometimes failing during the verification of the number of ports obtained after the controller reboot. Two issues have been identified and corrected: - The information obtained from nova/heat for some VMs showed no ports and in some cases a port had been created for those VMs. The test is modified to try to obtain the port from neutron in those cases. - The final list of ports after the reboot was obtained before the loop checking VM ports ends. It has been moved to obtain the list after that loop, which looks more stable. Change-Id: If57c2fc9451a89813f63d6c84e5ad86b991cfd3f
This commit is contained in:
parent
0962d8e266
commit
e0202499ac
@ -342,16 +342,26 @@ def get_vms_detailed_info(multi_ip_test_fixture):
|
||||
|
||||
def check_no_duplicate_ips(vms_detailed_info, ports_before_stack_creation):
|
||||
test_case = tobiko.get_test_case()
|
||||
ports_after_reboot = neutron.list_ports(device_owner="compute:nova")
|
||||
# check VM IP addresses are different
|
||||
ip4_list = []
|
||||
ip6_list = []
|
||||
for vm in vms_detailed_info:
|
||||
addresses = vm.get('addresses', {}) if vm is not None else {}
|
||||
# try to obtain the port associated to a VM from neutron if the VM
|
||||
# exists but vms_detailed_info does not show the port
|
||||
if not addresses and vm is not None:
|
||||
ports = neutron.list_ports(device_id=vm['id'])
|
||||
test_case.assertLess(len(ports), 2)
|
||||
for port in ports:
|
||||
addresses[port['network_id']] = port['fixed_ips']
|
||||
|
||||
for addresses_per_network in addresses.values():
|
||||
test_case.assertEqual(len(addresses_per_network), 2)
|
||||
for subnet_addr in addresses_per_network:
|
||||
subnet_ip = subnet_addr['addr']
|
||||
# the subnet_addr dict is different depending on how it was
|
||||
# obtained: from vms_detailed_info or from neutron.list_ports
|
||||
subnet_ip = (subnet_addr.get('addr') or
|
||||
subnet_addr.get('ip_address'))
|
||||
if netaddr.valid_ipv4(subnet_ip):
|
||||
ip4_list.append(subnet_ip)
|
||||
elif netaddr.valid_ipv6(subnet_ip):
|
||||
@ -368,6 +378,8 @@ def check_no_duplicate_ips(vms_detailed_info, ports_before_stack_creation):
|
||||
LOG.debug("list of IPv4 and list of IPv6 addresses "
|
||||
"should have the same length")
|
||||
test_case.assertEqual(len(ip6_list), len(ip4_list))
|
||||
|
||||
ports_after_reboot = neutron.list_ports(device_owner="compute:nova")
|
||||
test_case.assertEqual(len(ip6_list), len(ports_after_reboot) - len(
|
||||
ports_before_stack_creation))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user