2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2020 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation,
7 # Inc. ("NetDEF") in this file.
11 -Verify static route ECMP functionality with 2 next hop.
13 -Verify static route functionality with 2 next hop and different AD
16 -Verify RIB status when same route advertise via BGP and static route.
25 # Save the Current Working Directory to find configuration files.
26 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
27 sys
.path
.append(os
.path
.join(CWD
, "../"))
28 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
30 # pylint: disable=C0413
31 # Import topogen and topotest helpers
32 from lib
.topogen
import Topogen
, get_topogen
33 from lib
.topotest
import version_cmp
35 # Import topoJson from lib, to create topology and initial configuration
36 from lib
.common_config
import (
40 reset_config_on_routers
,
45 shutdown_bringup_interface
,
49 from lib
.topolog
import logger
50 from lib
.bgp
import verify_bgp_convergence
, create_router_bgp
, verify_bgp_rib
51 from lib
.topojson
import build_config_from_json
53 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
56 ADDR_TYPES
= check_address_types()
57 NETWORK
= {"ipv4": ["11.0.20.1/32", "11.0.20.2/32"], "ipv6": ["2::1/128", "2::2/128"]}
58 NETWORK2
= {"ipv4": "11.0.20.1/32", "ipv6": "2::1/128"}
60 PREFIX1
= {"ipv4": "110.0.20.1/32", "ipv6": "20::1/128"}
63 def setup_module(mod
):
65 Sets up the pytest environment.
70 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
71 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
74 logger
.info("Running setup_module to create topology")
76 # This function initiates the topology build with Topogen...
77 json_file
= "{}/static_routes_topo1_ebgp.json".format(CWD
)
78 tgen
= Topogen(json_file
, mod
.__name
__)
81 # ... and here it calls Mininet initialization functions.
83 # Starting topology, create tmp files which are loaded to routers
84 # to start daemons and then start routers
87 # Creating configuration from JSON
88 build_config_from_json(tgen
, topo
)
90 if version_cmp(platform
.release(), "4.19") < 0:
92 'These tests will not run. (have kernel "{}", '
93 "requires kernel >= 4.19)".format(platform
.release())
95 pytest
.skip(error_msg
)
97 # Checking BGP convergence
99 # Don't run this test if we have any failure.
100 if tgen
.routers_have_failure():
101 pytest
.skip(tgen
.errors
)
103 # Api call verify whether BGP is converged
104 converged
= verify_bgp_convergence(tgen
, topo
)
105 assert converged
is True, "setup_module :Failed \n Error: {}".format(converged
)
107 logger
.info("Running setup_module() done")
110 def teardown_module(mod
):
112 Teardown the pytest environment.
117 logger
.info("Running teardown_module to delete topology: %s", mod
)
121 # Stop toplogy and Remove tmp files
125 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
127 logger
.info("=" * 40)
137 "ipv4": topo
["routers"]["r1"]["links"]["r2-link0"]["ipv4"].split("/")[0],
138 "ipv6": topo
["routers"]["r1"]["links"]["r2-link0"]["ipv6"].split("/")[0],
141 "ipv4": topo
["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split("/")[0],
142 "ipv6": topo
["routers"]["r1"]["links"]["r2-link1"]["ipv6"].split("/")[0],
148 #####################################################
152 #####################################################
155 def test_static_route_2nh_p0_tc_1_ebgp(request
):
157 Verify static route ECMP functionality with 2 next hop.
160 tc_name
= request
.node
.name
161 write_test_header(tc_name
)
163 # Don't run this test if we have any failure.
164 if tgen
.routers_have_failure():
165 pytest
.skip(tgen
.errors
)
167 reset_config_on_routers(tgen
)
168 next_hop_ip
= populate_nh()
171 "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1"
172 "(28.1.1.2 ) and N2 (29.1.1.2) , Static route next-hop present on"
175 step("ex :- ip route 10.1.1.1/24 28.1.1.2 & ip route 10.1.1.1/24 29.1.1.1")
176 for addr_type
in ADDR_TYPES
:
181 "network": NETWORK
[addr_type
],
182 "next_hop": next_hop_ip
["nh1"][addr_type
],
185 "network": NETWORK
[addr_type
],
186 "next_hop": next_hop_ip
["nh2"][addr_type
],
192 logger
.info("Configure static routes")
193 result
= create_static_routes(tgen
, input_dict_4
)
194 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
199 "On R2, static route installed in RIB using show ip route"
200 " with 2 ECMP next hop "
202 nh
= [next_hop_ip
["nh1"][addr_type
], next_hop_ip
["nh2"][addr_type
]]
206 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
210 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
212 step("Configure IBGP IPv4 peering between R2 and R3 router.")
213 step("Configure redistribute static in BGP on R2 router")
220 "unicast": {"redistribute": [{"redist_type": "static"}]}
226 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
227 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
231 step("Remove the static route configured with nexthop N1 from running config")
236 "network": NETWORK
[addr_type
],
237 "next_hop": next_hop_ip
["nh1"][addr_type
],
243 logger
.info("Configure static routes")
244 result
= create_static_routes(tgen
, input_dict_4
)
245 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
250 "On R2, after removing the static route with N1 , "
251 "route become active with nexthop N2 and vice versa."
253 nh
= next_hop_ip
["nh1"][addr_type
]
265 ), "Testcase {} : Failed" "Error: Routes is still present in RIB".format(
269 nh
= [next_hop_ip
["nh2"][addr_type
]]
271 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
275 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
277 step("Configure the static route with nexthop N1")
283 "network": NETWORK
[addr_type
],
284 "next_hop": next_hop_ip
["nh1"][addr_type
],
290 logger
.info("Configure static routes")
291 result
= create_static_routes(tgen
, input_dict_4
)
292 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
296 step("Remove the static route configured with nexthop N2 from" "running config")
302 "network": NETWORK
[addr_type
],
303 "next_hop": next_hop_ip
["nh2"][addr_type
],
310 logger
.info("Configure static routes")
311 result
= create_static_routes(tgen
, input_dict_4
)
312 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
317 "On R2, after removing the static route with N2 , "
318 "route become active with nexthop N1 and vice versa."
320 nh
= next_hop_ip
["nh2"][addr_type
]
332 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
336 nh
= [next_hop_ip
["nh1"][addr_type
]]
338 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
342 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
344 step("Configure the static route with nexthop N2")
349 "network": NETWORK
[addr_type
],
350 "next_hop": next_hop_ip
["nh2"][addr_type
],
356 logger
.info("Configure static routes")
357 result
= create_static_routes(tgen
, input_dict_4
)
358 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
362 step("Shut nexthop interface N1")
363 intf
= topo
["routers"]["r2"]["links"]["r1-link0"]["interface"]
365 shutdown_bringup_interface(tgen
, dut
, intf
, False)
367 step("Only one the nexthops should be active in RIB.")
369 nh
= next_hop_ip
["nh2"][addr_type
]
371 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
375 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
377 nh
= next_hop_ip
["nh1"][addr_type
]
389 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
394 result
= verify_bgp_rib(
395 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, expected
=False
399 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
414 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
419 nh
= [next_hop_ip
["nh2"][addr_type
]]
421 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
425 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
428 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
431 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
434 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
438 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
443 step("No shut the nexthop interface N1")
444 shutdown_bringup_interface(tgen
, dut
, intf
, True)
447 "after shut of nexthop N1 , route become active "
448 "with nexthop N2 and vice versa."
450 nh
= [next_hop_ip
["nh1"][addr_type
], next_hop_ip
["nh2"][addr_type
]]
453 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
457 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
459 step("Shut nexthop interface N2")
460 intf
= topo
["routers"]["r2"]["links"]["r1-link1"]["interface"]
462 shutdown_bringup_interface(tgen
, dut
, intf
, False)
465 " after shut of nexthop N1 , route become active with "
466 "nexthop N2 and vice versa."
468 nh
= next_hop_ip
["nh2"][addr_type
]
481 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
485 nh
= [next_hop_ip
["nh1"][addr_type
]]
489 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
493 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
496 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
499 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
502 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
506 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
510 step("No shut nexthop interface N2")
512 shutdown_bringup_interface(tgen
, dut
, intf
, True)
515 "after shut of nexthop N1 , route become active "
516 "with nexthop N2 and vice versa."
518 nh
= [next_hop_ip
["nh1"][addr_type
], next_hop_ip
["nh2"][addr_type
]]
521 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
525 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
528 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
531 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
534 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
538 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
542 step("Reload the FRR router")
543 # stop/start -> restart FRR router and verify
544 stop_router(tgen
, "r2")
546 start_router(tgen
, "r2")
550 "After reload of FRR router , static route installed"
551 " in RIB and FIB properly ."
554 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
558 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
561 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
564 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
569 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
573 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
577 write_test_footer(tc_name
)
580 def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request
):
582 Verify static route functionality with 2 next hop & different AD value.
585 tc_name
= request
.node
.name
586 write_test_header(tc_name
)
588 # Don't run this test if we have any failure.
589 if tgen
.routers_have_failure():
590 pytest
.skip(tgen
.errors
)
592 reset_config_on_routers(tgen
)
595 "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1"
596 "(28.1.1.2 ) AD 10 and N2 (29.1.1.2) AD 20 , Static route next-hop"
597 "present on R1 \n ex :- ip route 10.1.1.1/24 28.1.1.2 10 & "
598 "ip route 10.1.1.1/24 29.1.1.2 20"
601 reset_config_on_routers(tgen
)
602 next_hop_ip
= populate_nh()
603 for addr_type
in ADDR_TYPES
:
608 "network": NETWORK2
[addr_type
],
609 "next_hop": next_hop_ip
["nh1"][addr_type
],
610 "admin_distance": 10,
613 "network": NETWORK2
[addr_type
],
614 "next_hop": next_hop_ip
["nh2"][addr_type
],
615 "admin_distance": 20,
620 logger
.info("Configure static routes")
621 result
= create_static_routes(tgen
, input_dict_4
)
622 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
627 "On R2, static route installed in RIB using "
628 "show ip route with 2 next hop , lowest AD nexthop is active "
634 "network": NETWORK2
[addr_type
],
635 "next_hop": next_hop_ip
["nh1"][addr_type
],
636 "admin_distance": 10,
641 nh
= [next_hop_ip
["nh1"][addr_type
]]
645 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
649 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
655 "network": NETWORK2
[addr_type
],
656 "next_hop": next_hop_ip
["nh2"][addr_type
],
657 "admin_distance": 20,
662 nh
= [next_hop_ip
["nh2"][addr_type
]]
677 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
679 step("Configure IBGP IPv4 peering between R2 and R3 router.")
680 step("Explicit route is added in R3 for R2 nexthop rechability")
685 "network": next_hop_ip
["nh1"][addr_type
] + "/32",
686 "next_hop": topo
["routers"]["r2"]["links"]["r3"][addr_type
],
689 "network": next_hop_ip
["nh2"][addr_type
] + "/32",
690 "next_hop": topo
["routers"]["r2"]["links"]["r3"][addr_type
],
695 logger
.info("Configure static routes")
696 result
= create_static_routes(tgen
, rt3_rtes
)
697 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
700 step("Configure redistribute static in BGP on R2 router")
707 "unicast": {"redistribute": [{"redist_type": "static"}]}
713 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
714 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
718 step("Remove the static route configured with nexthop N1 from" "running config")
723 "network": NETWORK
[addr_type
],
724 "next_hop": next_hop_ip
["nh1"][addr_type
],
725 "admin_distance": 10,
732 logger
.info("Configure static routes")
733 result
= create_static_routes(tgen
, rt1_nh1
)
734 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
739 "On R2, after removing the static route with N1 , "
740 "route become active with nexthop N2 and vice versa."
746 "network": NETWORK2
[addr_type
],
747 "next_hop": next_hop_ip
["nh1"][addr_type
],
748 "admin_distance": 10,
753 nh
= [next_hop_ip
["nh1"][addr_type
]]
768 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
774 "network": NETWORK2
[addr_type
],
775 "next_hop": next_hop_ip
["nh2"][addr_type
],
776 "admin_distance": 20,
781 nh
= [next_hop_ip
["nh2"][addr_type
]]
783 tgen
, addr_type
, dut
, rte2_nh2
, next_hop
=nh
, protocol
=protocol
, fib
=True
787 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
789 step("Configure the static route with nexthop N1")
794 "network": NETWORK
[addr_type
],
795 "next_hop": next_hop_ip
["nh1"][addr_type
],
796 "admin_distance": 10,
801 logger
.info("Configure static routes")
802 result
= create_static_routes(tgen
, rte1_nh1
)
803 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
807 step("Remove the static route configured with nexthop N2 from" "running config")
812 "network": NETWORK
[addr_type
],
813 "next_hop": next_hop_ip
["nh2"][addr_type
],
814 "admin_distance": 20,
820 logger
.info("Configure static routes")
821 result
= create_static_routes(tgen
, rte2_nh2
)
822 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
827 "On R2, after removing the static route with N2 , "
828 "route become active with nexthop N1 and vice versa."
830 nh
= next_hop_ip
["nh2"][addr_type
]
842 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
846 nh
= [next_hop_ip
["nh1"][addr_type
]]
848 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
852 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
854 step("Configure the static route with nexthop N2")
859 "network": NETWORK
[addr_type
],
860 "next_hop": next_hop_ip
["nh2"][addr_type
],
861 "admin_distance": 20,
867 logger
.info("Configure static routes")
868 result
= create_static_routes(tgen
, rte2_nh2
)
869 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
873 step("Shut nexthop interface N1")
874 intf
= topo
["routers"]["r2"]["links"]["r1-link0"]["interface"]
876 shutdown_bringup_interface(tgen
, dut
, intf
, False)
878 step("after shut of nexthop N1 , route become active with nexthop N2")
880 nh
= next_hop_ip
["nh1"][addr_type
]
892 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
896 nh
= [next_hop_ip
["nh2"][addr_type
]]
898 tgen
, addr_type
, dut
, rte2_nh2
, next_hop
=nh
, protocol
=protocol
, fib
=True
902 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
904 step("No shut the nexthop interface N1")
905 shutdown_bringup_interface(tgen
, dut
, intf
, True)
908 "after shut of nexthop N1 , route become active "
909 "with nexthop N2 and vice versa."
911 nh
= [next_hop_ip
["nh1"][addr_type
]]
914 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
918 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
920 step("Shut nexthop interface N2")
921 intf
= topo
["routers"]["r2"]["links"]["r1-link1"]["interface"]
923 shutdown_bringup_interface(tgen
, dut
, intf
, False)
926 " after shut of nexthop N1 , route become active with "
927 "nexthop N2 and vice versa."
929 nh
= next_hop_ip
["nh2"][addr_type
]
942 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
946 nh
= [next_hop_ip
["nh1"][addr_type
]]
948 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
952 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
954 step("No shut nexthop interface N2")
955 shutdown_bringup_interface(tgen
, dut
, intf
, True)
958 "after shut of nexthop N1 , route become active "
959 "with nexthop N2 and vice versa."
965 "network": NETWORK2
[addr_type
],
966 "next_hop": next_hop_ip
["nh1"][addr_type
],
967 "admin_distance": 10,
972 nh
= [next_hop_ip
["nh1"][addr_type
]]
976 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
980 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
986 "network": NETWORK2
[addr_type
],
987 "next_hop": next_hop_ip
["nh2"][addr_type
],
988 "admin_distance": 20,
993 nh
= [next_hop_ip
["nh2"][addr_type
]]
1008 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1013 result
= verify_rib(
1025 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1028 step("Reload the FRR router")
1029 # stop/start -> restart FRR router and verify
1030 stop_router(tgen
, "r2")
1032 start_router(tgen
, "r2")
1035 "After reload of FRR router , static route installed"
1036 " in RIB and FIB properly ."
1042 "network": NETWORK2
[addr_type
],
1043 "next_hop": next_hop_ip
["nh1"][addr_type
],
1044 "admin_distance": 10,
1049 nh
= [next_hop_ip
["nh1"][addr_type
]]
1052 result
= verify_rib(
1053 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
1057 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
1061 result
= verify_bgp_rib(tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
)
1064 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
1070 "network": NETWORK2
[addr_type
],
1071 "next_hop": next_hop_ip
["nh2"][addr_type
],
1072 "admin_distance": 20,
1077 nh
= [next_hop_ip
["nh2"][addr_type
]]
1080 result
= verify_rib(
1092 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1096 result
= verify_bgp_rib(tgen
, addr_type
, dut
, rte2_nh2
, next_hop
=nh
)
1099 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1101 result
= verify_rib(
1113 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1115 write_test_footer(tc_name
)
1118 def test_same_rte_from_bgp_static_p0_tc5_ebgp(request
):
1120 Verify RIB status when same route advertise via BGP and static
1124 tc_name
= request
.node
.name
1125 write_test_header(tc_name
)
1126 tgen
= get_topogen()
1127 # Don't run this test if we have any failure.
1128 if tgen
.routers_have_failure():
1129 pytest
.skip(tgen
.errors
)
1131 reset_config_on_routers(tgen
)
1133 NEXT_HOP_IP
= populate_nh()
1134 step("Configure EBGP IPv4 peering between R2 and R3 router.")
1137 "Configure IPv4 static route (10.1.1.1/24) in R2 with next hop"
1138 "N1 (28.1.1.2 ) and N2 (29.1.1.2) , Static route next-hop present"
1142 for addr_type
in ADDR_TYPES
:
1147 "network": NETWORK
[addr_type
],
1148 "next_hop": NEXT_HOP_IP
["nh1"][addr_type
],
1151 "network": NETWORK
[addr_type
],
1152 "next_hop": NEXT_HOP_IP
["nh2"][addr_type
],
1157 logger
.info("Configure static routes")
1158 result
= create_static_routes(tgen
, input_dict_4
)
1159 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1163 step("Configure redistribute static in BGP.")
1164 for addr_type
in ADDR_TYPES
:
1170 "unicast": {"redistribute": [{"redist_type": "static"}]}
1176 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1177 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1180 step("Verify on R3 , route receive on R3 BGP table ")
1182 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
1185 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
1189 step("Verify route installed in the RIB and FIB of R3")
1191 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
)
1194 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
1199 "Configure 2 links/interfaces between R1 and R3 , keep one"
1200 "interface in shut (active) state and other interface in no shut"
1204 intf
= topo
["routers"]["r3"]["links"]["r1-link0"]["interface"]
1205 shutdown_bringup_interface(tgen
, dut
, intf
, False)
1208 "Configure same static route (10.1.1.1/24) in R3 with inactive"
1213 "Configure same static route 10.1.1.1/24) again in R3 with"
1214 "active nexthop interface"
1216 for addr_type
in ADDR_TYPES
:
1221 "network": NETWORK
[addr_type
],
1222 "next_hop": topo
["routers"]["r1"]["links"]["r3-link0"][
1227 "network": NETWORK
[addr_type
],
1228 "next_hop": topo
["routers"]["r1"]["links"]["r3-link1"][
1235 logger
.info("Configure static routes")
1236 result
= create_static_routes(tgen
, input_dict_4
)
1237 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1242 "Verify when static route configure with inactive nexthop , "
1243 "verify BGP received route is active in the RIB and FIB"
1246 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
1249 ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format(
1254 result
= verify_rib(
1255 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, fib
=True
1259 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
1261 step("Remove the static route on R3 configured with active" "interface")
1262 for addr_type
in ADDR_TYPES
:
1267 "network": NETWORK
[addr_type
],
1268 "next_hop": topo
["routers"]["r1"]["links"]["r3-link0"][
1274 "network": NETWORK
[addr_type
],
1275 "next_hop": topo
["routers"]["r1"]["links"]["r3-link1"][
1283 logger
.info("Configure static routes")
1284 result
= create_static_routes(tgen
, input_dict_4
)
1285 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1289 "After removing the static route with active nexthop verify "
1290 "BGP received route is became active in RIB and FIB"
1293 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
1296 ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format(
1301 result
= verify_rib(
1302 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, fib
=True
1306 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
1308 write_test_footer(tc_name
)
1311 if __name__
== "__main__":
1312 args
= ["-s"] + sys
.argv
[1:]
1313 sys
.exit(pytest
.main(args
))