Adding test for static route on distributed router

Change-Id: I55949c84fb6a0e12fddf6bc9330b9319a4cd4b8a
This commit is contained in:
dkumbhar 2020-04-14 13:40:40 +00:00
parent 5735e66c2f
commit f12452f303
2 changed files with 45 additions and 0 deletions

View File

@ -389,3 +389,15 @@ class VSMClient(object):
else:
LOG.debug('spoofguard policy of nw is %s NOT found!' % network_id)
return False
def verify_static_route(self, name, cidr, nexthop):
edge_id = self.get_edge_name_substring(name)['id']
self.__set_api_version('4.0')
self.__set_endpoint('/edges/%s/routing/config/static' % edge_id)
response = self.get()
routes = response.json()['staticRoutes']['staticRoutes']
route = [(r['network'], r['nextHop']) for r in routes]
if (cidr, nexthop) in route:
return True
else:
return False

View File

@ -1790,3 +1790,36 @@ class TestNewCase(feature_manager.FeatureManager):
routerIP = router_ext['external_fixed_ips'][0]['ip_address']
self.assertTrue(self.vsm.verify_default_snat_rule(name, routerIP,
cidr_value))
@decorators.attr(type='nsxv')
@decorators.idempotent_id('2226016a-91cc-8905-b217-12344cab24a1')
def test_update_router_with_static_route_via_any_CIDR(self):
"""
Check it should not allow to add static route on router with
10.0.0.0/24 next hop.
"""
kwargs = {"distributed": "true",
"admin_state_up": "True"}
rtr_name = 'tempest-router-dist'
network_name = data_utils.rand_name(name='tempest-net')
subnet_name = data_utils.rand_name(name='tempest-subnet')
router_state = self.create_topology_router(rtr_name,
set_gateway=False,
**kwargs)
network_state = self.create_topology_network(network_name)
subnet_state = self.create_topology_subnet(
subnet_name, network_state, router_id=router_state["id"])
next_hop = subnet_state['allocation_pools'][0]['end']
routes = [{
"destination": "100.0.0.0/24",
"nexthop": next_hop
}]
router_id = router_state['id']
self.routers_client.update_router(router_id, routes=routes)
self.assertTrue(self.vsm.verify_static_route(router_state['name'],
'100.0.0.0/24', next_hop))
routes = []
self.routers_client.update_router(router_id, routes=routes)
self.assertFalse(self.vsm.verify_static_route(router_state['name'],
'100.0.0.0/24',
next_hop))