Create external network for advertised routes tests
Due to the fact that public network is configured as shared external
network and shared among all the tests it leads to the situation if
during advertised routes tests any of test will add floatingip this
floating IP will appear in advertised routes. To avoid this each test
creates it's own public network used in the test therefore only
routes created by these tests will appear in this network.
Related-PRODX: PRODX-30128
Change-Id: Icf85f84c8d0ba43e5b1c0578360817f0fd809039
diff --git a/neutron_tempest_plugin/neutron_dynamic_routing/api/test_bgp_speaker_extensions.py b/neutron_tempest_plugin/neutron_dynamic_routing/api/test_bgp_speaker_extensions.py
index 5cdd524..83b283e 100644
--- a/neutron_tempest_plugin/neutron_dynamic_routing/api/test_bgp_speaker_extensions.py
+++ b/neutron_tempest_plugin/neutron_dynamic_routing/api/test_bgp_speaker_extensions.py
@@ -229,22 +229,56 @@
def test_get_advertised_routes_null_address_scope(self):
self.useFixture(fixtures.LockFixture('gateway_network_binding'))
bgp_speaker = self.create_bgp_speaker(**self.default_bgp_speaker_args)
+
+ addr_scope1 = self.create_address_scope(
+ 'get-advertised-routes-null-address-scope',
+ ip_version=4)
+ ext_net = self.create_shared_network(**{'router:external': True})
+ ext_subnetpool = self.create_subnetpool(
+ 'get-advertised-routes-null-address-pool-ext',
+ is_admin=True,
+ default_prefixlen=24,
+ address_scope_id=addr_scope1['id'],
+ prefixes=['8.0.0.0/8'])
+ self.create_subnet({'id': ext_net['id']},
+ cidr=netaddr.IPNetwork('8.0.0.0/24'),
+ ip_version=4,
+ client=self.admin_client,
+ subnetpool_id=ext_subnetpool['id'])
+ ext_gw_info = {'network_id': ext_net['id']}
+ router = self.create_router(ext_gw_info)
+ self.admin_routers.append(router)
bgp_speaker_id = bgp_speaker['id']
self.bgp_adm_client.add_bgp_gateway_network(bgp_speaker_id,
- self.ext_net_id)
+ ext_net['id'])
routes = self.bgp_adm_client.get_bgp_advertised_routes(bgp_speaker_id)
self.assertEqual(0, len(routes['advertised_routes']))
@decorators.idempotent_id('cae9cdb1-ad65-423c-9604-d4cd0073616e')
def test_get_advertised_routes_floating_ips(self):
self.useFixture(fixtures.LockFixture('gateway_network_binding'))
+ addr_scope1 = self.create_address_scope(
+ 'get-advertised-routes-floating-ip-scope',
+ ip_version=4)
+ ext_net = self.create_shared_network(**{'router:external': True})
+ ext_subnetpool = self.create_subnetpool(
+ 'get-advertised-routes-floating-ip-ext',
+ is_admin=True,
+ default_prefixlen=24,
+ address_scope_id=addr_scope1['id'],
+ prefixes=['8.0.0.0/8'])
+ self.create_subnet({'id': ext_net['id']},
+ cidr=netaddr.IPNetwork('8.0.0.0/24'),
+ ip_version=4,
+ client=self.admin_client,
+ subnetpool_id=ext_subnetpool['id'])
bgp_speaker = self.create_bgp_speaker(**self.default_bgp_speaker_args)
bgp_speaker_id = bgp_speaker['id']
self.bgp_adm_client.add_bgp_gateway_network(bgp_speaker_id,
- self.ext_net_id)
+ ext_net['id'])
tenant_net = self.create_network()
tenant_subnet = self.create_subnet(tenant_net)
- ext_gw_info = {'network_id': self.ext_net_id}
+ ext_gw_info = {'network_id': ext_net['id']}
router = self.create_router(ext_gw_info)
self.admin_routers.append(router)
self.admin_client.add_router_interface_with_subnet_id(
@@ -253,7 +287,7 @@
self.admin_routerports.append({'router_id': router['id'],
'subnet_id': tenant_subnet['id']})
tenant_port = self.create_port(tenant_net)
- floatingip = self.create_floatingip(self.ext_net_id)
+ floatingip = self.create_floatingip(ext_net['id'])
self.admin_floatingips.append(floatingip)
self.client.update_floatingip(floatingip['id'],
port_id=tenant_port['id'])