Skip to content

Commit

Permalink
[route] Fix of static route redistribution in test_static_route (#3785)
Browse files Browse the repository at this point in the history
Summary:
Fix of static route redistribution in test_static_route

Approach
What is the motivation for this PR?
PR-3633 add check if static routes get redistributed in test_static_route
But BGP does not redistribute static route by default.

How did you do it?
Added function that enable/disable redistribution of static routes.

How did you verify/test it?
Run route/test_static_route.py

route/test_static_route.py::test_static_route PASSED
route/test_static_route.py::test_static_route_ecmp PASSED
route/test_static_route.py::test_static_route_ipv6 PASSED
route/test_static_route.py::test_static_route_ecmp_ipv6 PASSED

Signed-off-by: Vladyslav Morokhovych<[email protected]>
  • Loading branch information
vmorokhx authored Aug 2, 2021
1 parent f549cfc commit d3510a7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/route/test_static_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ def check_route_redistribution(duthost, prefix, ipv6, removed=False):
assert prefix in adv_routes


def route_redistribution_static(duthost, ipv6, removed=False):
mg_facts = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"]
if ipv6:
duthost.shell("vtysh -c 'configure terminal' -c 'router bgp {}' -c 'address-family ipv6' -c '{}redistribute static'".format(mg_facts["minigraph_bgp_asn"],
"no " if removed else ''))
else:
duthost.shell("vtysh -c 'configure terminal' -c 'router bgp {}' -c '{}redistribute static'".format(mg_facts["minigraph_bgp_asn"],
"no " if removed else ''))


def run_static_route_test(duthost, ptfadapter, ptfhost, tbinfo, prefix, nexthop_addrs, prefix_len, nexthop_devs, ipv6=False, config_reload_test=False):
# Clean up arp or ndp
clear_arp_ndp(duthost, ipv6=ipv6)
Expand All @@ -148,6 +158,8 @@ def run_static_route_test(duthost, ptfadapter, ptfhost, tbinfo, prefix, nexthop_
add_ipaddr(ptfadapter, ptfhost, nexthop_addrs, prefix_len, nexthop_devs, ipv6=ipv6)

try:
# Enable redistribution of static routes
route_redistribution_static(duthost, ipv6)
# Add static route
duthost.shell("sonic-db-cli CONFIG_DB hmset 'STATIC_ROUTE|{}' nexthop {}".format(prefix, ",".join(nexthop_addrs)))
time.sleep(5)
Expand All @@ -163,6 +175,7 @@ def run_static_route_test(duthost, ptfadapter, ptfhost, tbinfo, prefix, nexthop_
if config_reload_test:
duthost.shell('config save -y')
config_reload(duthost, wait=350)
route_redistribution_static(duthost, ipv6)
generate_and_verify_traffic(duthost, ptfadapter, tbinfo, ip_dst, nexthop_devs, ipv6=ipv6)
check_route_redistribution(duthost, prefix, ipv6)

Expand All @@ -176,7 +189,8 @@ def run_static_route_test(duthost, ptfadapter, ptfhost, tbinfo, prefix, nexthop_
# Check the advertised route get removed
time.sleep(5)
check_route_redistribution(duthost, prefix, ipv6, removed=True)

# Disable redistribution of static routes
route_redistribution_static(duthost, ipv6, removed=True)
# Config save if the saved config_db was updated
if config_reload_test:
duthost.shell('config save -y')
Expand Down

0 comments on commit d3510a7

Please sign in to comment.