Fix neutron-dynamic-routing tests when DVR is disabled

OVN doesn't support DVR, so even creating a router with
distributed=False will fail. We want a non-distributed router anyway,
so just retry without that option if we get a BadRequest error.

Change-Id: I004248eb259824614e27b3d8b739d3a72b580df3
This commit is contained in:
Dr. Jens Harbott 2020-07-01 14:54:14 +00:00 committed by Jens Harbott
parent b3aa2a7127
commit 1184bb2d10
2 changed files with 19 additions and 16 deletions

View File

@ -149,6 +149,19 @@ class BgpSpeakerTestJSONBase(base.BaseAdminNetworkTest):
def delete_address_scope(self, id):
return self.admin_client.delete_address_scope(id)
def create_router(self, ext_gw_info):
try:
router = self.admin_client.create_router(
'my-router',
external_gateway_info=ext_gw_info,
distributed=False)
# Retry if not running with DVR enabled
except lib_exc.BadRequest:
router = self.admin_client.create_router(
'my-router',
external_gateway_info=ext_gw_info)
return router['router']
class BgpSpeakerTestJSON(BgpSpeakerTestJSONBase):
@ -253,16 +266,12 @@ class BgpSpeakerTestJSON(BgpSpeakerTestJSONBase):
tenant_net = self.create_network()
tenant_subnet = self.create_subnet(tenant_net)
ext_gw_info = {'network_id': self.ext_net_id}
router = self.admin_client.create_router(
'my-router',
external_gateway_info=ext_gw_info,
admin_state_up=True,
distributed=False)
self.admin_routers.append(router['router'])
router = self.create_router(ext_gw_info)
self.admin_routers.append(router)
self.admin_client.add_router_interface_with_subnet_id(
router['router']['id'],
router['id'],
tenant_subnet['id'])
self.admin_routerports.append({'router_id': router['router']['id'],
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)
@ -302,10 +311,7 @@ class BgpSpeakerTestJSON(BgpSpeakerTestJSONBase):
ip_version=4,
subnetpool_id=tenant_subnetpool['id'])
ext_gw_info = {'network_id': ext_net['id']}
router = self.admin_client.create_router(
'my-router',
external_gateway_info=ext_gw_info,
distributed=False)['router']
router = self.create_router(ext_gw_info)
self.admin_routers.append(router)
self.admin_client.add_router_interface_with_subnet_id(
router['id'],

View File

@ -98,10 +98,7 @@ class BgpSpeakerTestJSONNegative(test_base.BgpSpeakerTestJSONBase):
ip_version=4,
subnetpool_id=tenant_subnetpool2['id'])
ext_gw_info = {'network_id': ext_net['id']}
router = self.admin_client.create_router(
'my-router',
distributed=False,
external_gateway_info=ext_gw_info)['router']
router = self.create_router(ext_gw_info)
self.admin_routers.append(router)
self.admin_client.add_router_interface_with_subnet_id(
router['id'],