Skip multi GW router update if IP in use
Skip the test ``test_create_router_update_external_gateways`` execution
if the router gateway update returns a ``IpAddressAlreadyAllocated``
exception. That could happen if the removed gateway port IP, between
the removal and the re-assignation to the same router, is allocated by
other test, as reported in the bug. The probabilities of this error are
low but not zero.
Closes-Bug: #2117383
Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>
Change-Id: I8038c5775cf5f1c20a4349ddc472415b65945219
diff --git a/neutron_tempest_plugin/api/test_routers.py b/neutron_tempest_plugin/api/test_routers.py
index 1470a7b..0012ffe 100644
--- a/neutron_tempest_plugin/api/test_routers.py
+++ b/neutron_tempest_plugin/api/test_routers.py
@@ -506,9 +506,17 @@
remove_gateways[0])
external_gateways[1] = remove_gateways[0]
- res_update_gws = self.admin_client.router_update_external_gateways(
- router['id'],
- external_gateways)
+ try:
+ res_update_gws = self.admin_client.router_update_external_gateways(
+ router['id'],
+ external_gateways)
+ except lib_exc.Conflict as exc:
+ if 'IpAddressAlreadyAllocated' in str(exc):
+ self.skipTest(
+ 'The IP address of the removed gateway port is already '
+ 'used by other test, thus this exception is dismissed and '
+ 'the rest of the test skipped')
+ raise exc
self.assertEqual(len(res_update_gws['router']['external_gateways']), 2)
for n in range(0, 2):