Add retries to find created ports at test_ovsdb_transation
This test may be unstable because the ports are created and immediately they are obtained from the nova API. When a port creation request succeeds, it doesn't mean it has already been created, but the POST request is being processed (response 201). It may take a while to really create the port Change-Id: Iea69f2252dc766ffcc0513331535ceebe9f80ddc
This commit is contained in:
parent
fb96fe49bb
commit
da0d344f5f
@ -641,18 +641,31 @@ def cleanup_ports_network(port_count):
|
|||||||
neutron.delete_network(network=network)
|
neutron.delete_network(network=network)
|
||||||
|
|
||||||
|
|
||||||
|
def find_port_retries(port_name, timeout=30., interval=3.):
|
||||||
|
for attempt in tobiko.retry(timeout=timeout, interval=interval):
|
||||||
|
try:
|
||||||
|
port = neutron.find_port(name=port_name)
|
||||||
|
except (neutron.NoSuchPort, tobiko.ObjectNotFound):
|
||||||
|
if attempt.is_last:
|
||||||
|
LOG.debug(
|
||||||
|
"Port %s not found after %f seconds", port_name, timeout)
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
return port
|
||||||
|
|
||||||
|
|
||||||
def check_port_created(port_count):
|
def check_port_created(port_count):
|
||||||
# This function checks the number of ports created
|
# This function checks the number of ports created
|
||||||
test_case = tobiko.get_test_case()
|
test_case = tobiko.get_test_case()
|
||||||
port_count_created = 0
|
port_count_created = 0
|
||||||
for _ in range(port_count):
|
for _ in range(port_count):
|
||||||
port_name = f'tobiko_ovn_leader_test_port-{_}'
|
port_name = f'tobiko_ovn_leader_test_port-{_}'
|
||||||
try:
|
port = find_port_retries(port_name)
|
||||||
port = neutron.find_port(name=port_name)
|
if port is not None:
|
||||||
if port:
|
port_count_created += 1
|
||||||
port_count_created += 1
|
LOG.debug("Port found: %s", port_name)
|
||||||
LOG.debug("Port found: %s", port_name)
|
else:
|
||||||
except (neutron.NoSuchPort, tobiko.ObjectNotFound):
|
|
||||||
LOG.debug("No Such port found: %s", port_name)
|
LOG.debug("No Such port found: %s", port_name)
|
||||||
test_case.assertEqual(port_count_created, port_count)
|
test_case.assertEqual(port_count_created, port_count)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user