From 7ac89c977b02fce4d85bd200943a6b179935ae5c Mon Sep 17 00:00:00 2001 From: Paras Babbar Date: Sun, 15 Mar 2020 19:59:45 -0400 Subject: [PATCH] Add explicit external network for test_create_router_set_gateway_with_fixed_ip This avoid neutron error that IP address x.x.x.x already allocated in subnet as the public network from tempest.conf is shared amongs multiple test cases which may ask for ip address in parallel to this test case execution and might end up in race condition. Note:Interop/Any other user doesn't use this test location so we should be good to move the location Change-Id: Ibf5ad52062b3719899a123a799f5f4f8e961f609 Closes-bug: #1676207 Logs: https://bugs.launchpad.net/tempest/+bug/1676207/comments/13 --- tempest/api/network/admin/test_routers.py | 36 +++++++++++++++++++++++ tempest/api/network/test_routers.py | 33 --------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/tempest/api/network/admin/test_routers.py b/tempest/api/network/admin/test_routers.py index a4a057c895..41f97d863b 100644 --- a/tempest/api/network/admin/test_routers.py +++ b/tempest/api/network/admin/test_routers.py @@ -212,6 +212,42 @@ class RoutersAdminTest(base.BaseAdminNetworkTest): 'enable_snat': False}) self._verify_gateway_port(router['id']) + @decorators.idempotent_id('cbe42f84-04c2-11e7-8adb-fa163e4fa634') + @utils.requires_ext(extension='ext-gw-mode', service='network') + def test_create_router_set_gateway_with_fixed_ip(self): + # At first create an external network and then use that + # to create address and delete + network_name = data_utils.rand_name(self.__class__.__name__) + network_1 = self.admin_networks_client.create_network( + name=network_name, **{'router:external': True})['network'] + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.admin_networks_client.delete_network, + network_1['id']) + subnet = self.create_subnet( + network_1, client=self.admin_subnets_client, enable_dhcp=False) + self.addCleanup(test_utils.call_and_ignore_notfound_exc, + self.admin_subnets_client.delete_subnet, subnet['id']) + port = self.admin_ports_client.create_port( + name=data_utils.rand_name(self.__class__.__name__), + network_id=network_1['id'])['port'] + self.admin_ports_client.delete_port(port_id=port['id']) + fixed_ip = { + 'subnet_id': port['fixed_ips'][0]['subnet_id'], + 'ip_address': port['fixed_ips'][0]['ip_address'] + } + external_gateway_info = { + 'network_id': network_1['id'], + 'external_fixed_ips': [fixed_ip] + } + # Create a router and set gateway to fixed_ip + router = self.admin_routers_client.create_router( + external_gateway_info=external_gateway_info)['router'] + self.admin_routers_client.delete_router(router['id']) + # Examine router's gateway is equal to fixed_ip + self.assertEqual(router['external_gateway_info'][ + 'external_fixed_ips'][0]['ip_address'], + fixed_ip['ip_address']) + class RoutersIpV6AdminTest(RoutersAdminTest): _ip_version = 6 diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py index ad316d1958..30423e3cd9 100644 --- a/tempest/api/network/test_routers.py +++ b/tempest/api/network/test_routers.py @@ -142,39 +142,6 @@ class RoutersTest(base.BaseNetworkTest): self.routers_client.remove_router_interface( router['id'], port_id=port_body['port']['id']) - @decorators.idempotent_id('cbe42f84-04c2-11e7-8adb-fa163e4fa634') - @utils.requires_ext(extension='ext-gw-mode', service='network') - @testtools.skipUnless(CONF.network.public_network_id, - 'The public_network_id option must be specified.') - @decorators.skip_because(bug='1676207') - def test_create_router_set_gateway_with_fixed_ip(self): - # Don't know public_network_address, so at first create address - # from public_network and delete - port = self.admin_ports_client.create_port( - name=data_utils.rand_name(self.__class__.__name__), - network_id=CONF.network.public_network_id)['port'] - self.admin_ports_client.delete_port(port_id=port['id']) - - fixed_ip = { - 'subnet_id': port['fixed_ips'][0]['subnet_id'], - 'ip_address': port['fixed_ips'][0]['ip_address'] - } - external_gateway_info = { - 'network_id': CONF.network.public_network_id, - 'external_fixed_ips': [fixed_ip] - } - - # Create a router and set gateway to fixed_ip - router = self.admin_routers_client.create_router( - external_gateway_info=external_gateway_info)['router'] - self.addCleanup(test_utils.call_and_ignore_notfound_exc, - self.admin_routers_client.delete_router, - router_id=router['id']) - # Examine router's gateway is equal to fixed_ip - self.assertEqual(router['external_gateway_info'][ - 'external_fixed_ips'][0]['ip_address'], - fixed_ip['ip_address']) - @decorators.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c') @utils.requires_ext(extension='extraroute', service='network') def test_update_delete_extra_route(self):