4 # Copyright (c) 2020 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation,
6 # Inc. ("NetDEF") in this file.
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 -Verify static route ECMP functionality with 2 next hop.
26 -Verify static route functionality with 2 next hop and different AD
29 -Verify RIB status when same route advertise via BGP and static route.
38 # Save the Current Working Directory to find configuration files.
39 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
40 sys
.path
.append(os
.path
.join(CWD
, "../"))
41 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
43 # pylint: disable=C0413
44 # Import topogen and topotest helpers
45 from lib
.topogen
import Topogen
, get_topogen
46 from lib
.topotest
import version_cmp
48 # Import topoJson from lib, to create topology and initial configuration
49 from lib
.common_config
import (
53 reset_config_on_routers
,
58 shutdown_bringup_interface
,
62 from lib
.topolog
import logger
63 from lib
.bgp
import verify_bgp_convergence
, create_router_bgp
, verify_bgp_rib
64 from lib
.topojson
import build_config_from_json
66 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
69 ADDR_TYPES
= check_address_types()
70 NETWORK
= {"ipv4": ["11.0.20.1/32", "11.0.20.2/32"], "ipv6": ["2::1/128", "2::2/128"]}
71 NETWORK2
= {"ipv4": "11.0.20.1/32", "ipv6": "2::1/128"}
73 PREFIX1
= {"ipv4": "110.0.20.1/32", "ipv6": "20::1/128"}
76 def setup_module(mod
):
78 Sets up the pytest environment.
83 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
84 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
87 logger
.info("Running setup_module to create topology")
89 # This function initiates the topology build with Topogen...
90 json_file
= "{}/static_routes_topo1_ebgp.json".format(CWD
)
91 tgen
= Topogen(json_file
, mod
.__name
__)
94 # ... and here it calls Mininet initialization functions.
96 # Starting topology, create tmp files which are loaded to routers
97 # to start daemons and then start routers
100 # Creating configuration from JSON
101 build_config_from_json(tgen
, topo
)
103 if version_cmp(platform
.release(), "4.19") < 0:
105 'These tests will not run. (have kernel "{}", '
106 "requires kernel >= 4.19)".format(platform
.release())
108 pytest
.skip(error_msg
)
110 # Checking BGP convergence
112 # Don't run this test if we have any failure.
113 if tgen
.routers_have_failure():
114 pytest
.skip(tgen
.errors
)
116 # Api call verify whether BGP is converged
117 converged
= verify_bgp_convergence(tgen
, topo
)
118 assert converged
is True, "setup_module :Failed \n Error: {}".format(converged
)
120 logger
.info("Running setup_module() done")
123 def teardown_module(mod
):
125 Teardown the pytest environment.
130 logger
.info("Running teardown_module to delete topology: %s", mod
)
134 # Stop toplogy and Remove tmp files
138 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
140 logger
.info("=" * 40)
150 "ipv4": topo
["routers"]["r1"]["links"]["r2-link0"]["ipv4"].split("/")[0],
151 "ipv6": topo
["routers"]["r1"]["links"]["r2-link0"]["ipv6"].split("/")[0],
154 "ipv4": topo
["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split("/")[0],
155 "ipv6": topo
["routers"]["r1"]["links"]["r2-link1"]["ipv6"].split("/")[0],
161 #####################################################
165 #####################################################
168 def test_static_route_2nh_p0_tc_1_ebgp(request
):
170 Verify static route ECMP functionality with 2 next hop.
173 tc_name
= request
.node
.name
174 write_test_header(tc_name
)
176 # Don't run this test if we have any failure.
177 if tgen
.routers_have_failure():
178 pytest
.skip(tgen
.errors
)
180 reset_config_on_routers(tgen
)
181 next_hop_ip
= populate_nh()
184 "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1"
185 "(28.1.1.2 ) and N2 (29.1.1.2) , Static route next-hop present on"
188 step("ex :- ip route 10.1.1.1/24 28.1.1.2 & ip route 10.1.1.1/24 29.1.1.1")
189 for addr_type
in ADDR_TYPES
:
194 "network": NETWORK
[addr_type
],
195 "next_hop": next_hop_ip
["nh1"][addr_type
],
198 "network": NETWORK
[addr_type
],
199 "next_hop": next_hop_ip
["nh2"][addr_type
],
205 logger
.info("Configure static routes")
206 result
= create_static_routes(tgen
, input_dict_4
)
207 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
212 "On R2, static route installed in RIB using show ip route"
213 " with 2 ECMP next hop "
215 nh
= [next_hop_ip
["nh1"][addr_type
], next_hop_ip
["nh2"][addr_type
]]
219 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
223 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
225 step("Configure IBGP IPv4 peering between R2 and R3 router.")
226 step("Configure redistribute static in BGP on R2 router")
233 "unicast": {"redistribute": [{"redist_type": "static"}]}
239 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
240 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
244 step("Remove the static route configured with nexthop N1 from running config")
249 "network": NETWORK
[addr_type
],
250 "next_hop": next_hop_ip
["nh1"][addr_type
],
256 logger
.info("Configure static routes")
257 result
= create_static_routes(tgen
, input_dict_4
)
258 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
263 "On R2, after removing the static route with N1 , "
264 "route become active with nexthop N2 and vice versa."
266 nh
= next_hop_ip
["nh1"][addr_type
]
278 ), "Testcase {} : Failed" "Error: Routes is still present in RIB".format(
282 nh
= [next_hop_ip
["nh2"][addr_type
]]
284 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
288 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
290 step("Configure the static route with nexthop N1")
296 "network": NETWORK
[addr_type
],
297 "next_hop": next_hop_ip
["nh1"][addr_type
],
303 logger
.info("Configure static routes")
304 result
= create_static_routes(tgen
, input_dict_4
)
305 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
309 step("Remove the static route configured with nexthop N2 from" "running config")
315 "network": NETWORK
[addr_type
],
316 "next_hop": next_hop_ip
["nh2"][addr_type
],
323 logger
.info("Configure static routes")
324 result
= create_static_routes(tgen
, input_dict_4
)
325 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
330 "On R2, after removing the static route with N2 , "
331 "route become active with nexthop N1 and vice versa."
333 nh
= next_hop_ip
["nh2"][addr_type
]
345 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
349 nh
= [next_hop_ip
["nh1"][addr_type
]]
351 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
355 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
357 step("Configure the static route with nexthop N2")
362 "network": NETWORK
[addr_type
],
363 "next_hop": next_hop_ip
["nh2"][addr_type
],
369 logger
.info("Configure static routes")
370 result
= create_static_routes(tgen
, input_dict_4
)
371 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
375 step("Shut nexthop interface N1")
376 intf
= topo
["routers"]["r2"]["links"]["r1-link0"]["interface"]
378 shutdown_bringup_interface(tgen
, dut
, intf
, False)
380 step("Only one the nexthops should be active in RIB.")
382 nh
= next_hop_ip
["nh2"][addr_type
]
384 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
388 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
390 nh
= next_hop_ip
["nh1"][addr_type
]
402 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
407 result
= verify_bgp_rib(
408 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, expected
=False
412 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
427 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
432 nh
= [next_hop_ip
["nh2"][addr_type
]]
434 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
438 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
441 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
444 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
447 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
451 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
456 step("No shut the nexthop interface N1")
457 shutdown_bringup_interface(tgen
, dut
, intf
, True)
460 "after shut of nexthop N1 , route become active "
461 "with nexthop N2 and vice versa."
463 nh
= [next_hop_ip
["nh1"][addr_type
], next_hop_ip
["nh2"][addr_type
]]
466 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
470 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
472 step("Shut nexthop interface N2")
473 intf
= topo
["routers"]["r2"]["links"]["r1-link1"]["interface"]
475 shutdown_bringup_interface(tgen
, dut
, intf
, False)
478 " after shut of nexthop N1 , route become active with "
479 "nexthop N2 and vice versa."
481 nh
= next_hop_ip
["nh2"][addr_type
]
494 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
498 nh
= [next_hop_ip
["nh1"][addr_type
]]
502 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
506 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
509 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
512 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
515 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
519 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
523 step("No shut nexthop interface N2")
525 shutdown_bringup_interface(tgen
, dut
, intf
, True)
528 "after shut of nexthop N1 , route become active "
529 "with nexthop N2 and vice versa."
531 nh
= [next_hop_ip
["nh1"][addr_type
], next_hop_ip
["nh2"][addr_type
]]
534 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
538 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
541 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
544 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
547 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
551 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
555 step("Reload the FRR router")
556 # stop/start -> restart FRR router and verify
557 stop_router(tgen
, "r2")
559 start_router(tgen
, "r2")
563 "After reload of FRR router , static route installed"
564 " in RIB and FIB properly ."
567 tgen
, addr_type
, dut
, input_dict_4
, next_hop
=nh
, protocol
=protocol
571 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
574 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
577 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
582 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, expected
=False
586 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
590 write_test_footer(tc_name
)
593 def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request
):
595 Verify static route functionality with 2 next hop & different AD value.
598 tc_name
= request
.node
.name
599 write_test_header(tc_name
)
601 # Don't run this test if we have any failure.
602 if tgen
.routers_have_failure():
603 pytest
.skip(tgen
.errors
)
605 reset_config_on_routers(tgen
)
608 "Configure IPv4 static route (10.1.1.1) in R2 with next hop N1"
609 "(28.1.1.2 ) AD 10 and N2 (29.1.1.2) AD 20 , Static route next-hop"
610 "present on R1 \n ex :- ip route 10.1.1.1/24 28.1.1.2 10 & "
611 "ip route 10.1.1.1/24 29.1.1.2 20"
614 reset_config_on_routers(tgen
)
615 next_hop_ip
= populate_nh()
616 for addr_type
in ADDR_TYPES
:
621 "network": NETWORK2
[addr_type
],
622 "next_hop": next_hop_ip
["nh1"][addr_type
],
623 "admin_distance": 10,
626 "network": NETWORK2
[addr_type
],
627 "next_hop": next_hop_ip
["nh2"][addr_type
],
628 "admin_distance": 20,
633 logger
.info("Configure static routes")
634 result
= create_static_routes(tgen
, input_dict_4
)
635 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
640 "On R2, static route installed in RIB using "
641 "show ip route with 2 next hop , lowest AD nexthop is active "
647 "network": NETWORK2
[addr_type
],
648 "next_hop": next_hop_ip
["nh1"][addr_type
],
649 "admin_distance": 10,
654 nh
= [next_hop_ip
["nh1"][addr_type
]]
658 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
662 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
668 "network": NETWORK2
[addr_type
],
669 "next_hop": next_hop_ip
["nh2"][addr_type
],
670 "admin_distance": 20,
675 nh
= [next_hop_ip
["nh2"][addr_type
]]
690 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
692 step("Configure IBGP IPv4 peering between R2 and R3 router.")
693 step("Explicit route is added in R3 for R2 nexthop rechability")
698 "network": next_hop_ip
["nh1"][addr_type
] + "/32",
699 "next_hop": topo
["routers"]["r2"]["links"]["r3"][addr_type
],
702 "network": next_hop_ip
["nh2"][addr_type
] + "/32",
703 "next_hop": topo
["routers"]["r2"]["links"]["r3"][addr_type
],
708 logger
.info("Configure static routes")
709 result
= create_static_routes(tgen
, rt3_rtes
)
710 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
713 step("Configure redistribute static in BGP on R2 router")
720 "unicast": {"redistribute": [{"redist_type": "static"}]}
726 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
727 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
731 step("Remove the static route configured with nexthop N1 from" "running config")
736 "network": NETWORK
[addr_type
],
737 "next_hop": next_hop_ip
["nh1"][addr_type
],
738 "admin_distance": 10,
745 logger
.info("Configure static routes")
746 result
= create_static_routes(tgen
, rt1_nh1
)
747 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
752 "On R2, after removing the static route with N1 , "
753 "route become active with nexthop N2 and vice versa."
759 "network": NETWORK2
[addr_type
],
760 "next_hop": next_hop_ip
["nh1"][addr_type
],
761 "admin_distance": 10,
766 nh
= [next_hop_ip
["nh1"][addr_type
]]
781 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
787 "network": NETWORK2
[addr_type
],
788 "next_hop": next_hop_ip
["nh2"][addr_type
],
789 "admin_distance": 20,
794 nh
= [next_hop_ip
["nh2"][addr_type
]]
796 tgen
, addr_type
, dut
, rte2_nh2
, next_hop
=nh
, protocol
=protocol
, fib
=True
800 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
802 step("Configure the static route with nexthop N1")
807 "network": NETWORK
[addr_type
],
808 "next_hop": next_hop_ip
["nh1"][addr_type
],
809 "admin_distance": 10,
814 logger
.info("Configure static routes")
815 result
= create_static_routes(tgen
, rte1_nh1
)
816 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
820 step("Remove the static route configured with nexthop N2 from" "running config")
825 "network": NETWORK
[addr_type
],
826 "next_hop": next_hop_ip
["nh2"][addr_type
],
827 "admin_distance": 20,
833 logger
.info("Configure static routes")
834 result
= create_static_routes(tgen
, rte2_nh2
)
835 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
840 "On R2, after removing the static route with N2 , "
841 "route become active with nexthop N1 and vice versa."
843 nh
= next_hop_ip
["nh2"][addr_type
]
855 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
859 nh
= [next_hop_ip
["nh1"][addr_type
]]
861 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
865 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
867 step("Configure the static route with nexthop N2")
872 "network": NETWORK
[addr_type
],
873 "next_hop": next_hop_ip
["nh2"][addr_type
],
874 "admin_distance": 20,
880 logger
.info("Configure static routes")
881 result
= create_static_routes(tgen
, rte2_nh2
)
882 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
886 step("Shut nexthop interface N1")
887 intf
= topo
["routers"]["r2"]["links"]["r1-link0"]["interface"]
889 shutdown_bringup_interface(tgen
, dut
, intf
, False)
891 step("after shut of nexthop N1 , route become active with nexthop N2")
893 nh
= next_hop_ip
["nh1"][addr_type
]
905 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
909 nh
= [next_hop_ip
["nh2"][addr_type
]]
911 tgen
, addr_type
, dut
, rte2_nh2
, next_hop
=nh
, protocol
=protocol
, fib
=True
915 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
917 step("No shut the nexthop interface N1")
918 shutdown_bringup_interface(tgen
, dut
, intf
, True)
921 "after shut of nexthop N1 , route become active "
922 "with nexthop N2 and vice versa."
924 nh
= [next_hop_ip
["nh1"][addr_type
]]
927 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
931 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
933 step("Shut nexthop interface N2")
934 intf
= topo
["routers"]["r2"]["links"]["r1-link1"]["interface"]
936 shutdown_bringup_interface(tgen
, dut
, intf
, False)
939 " after shut of nexthop N1 , route become active with "
940 "nexthop N2 and vice versa."
942 nh
= next_hop_ip
["nh2"][addr_type
]
955 ), "Testcase {} : Failed \nError: Routes is" " still present in RIB".format(
959 nh
= [next_hop_ip
["nh1"][addr_type
]]
961 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
965 ), "Testcase {} : Failed \nError: Routes is" " missing in RIB".format(tc_name
)
967 step("No shut nexthop interface N2")
968 shutdown_bringup_interface(tgen
, dut
, intf
, True)
971 "after shut of nexthop N1 , route become active "
972 "with nexthop N2 and vice versa."
978 "network": NETWORK2
[addr_type
],
979 "next_hop": next_hop_ip
["nh1"][addr_type
],
980 "admin_distance": 10,
985 nh
= [next_hop_ip
["nh1"][addr_type
]]
989 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
993 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
999 "network": NETWORK2
[addr_type
],
1000 "next_hop": next_hop_ip
["nh2"][addr_type
],
1001 "admin_distance": 20,
1006 nh
= [next_hop_ip
["nh2"][addr_type
]]
1009 result
= verify_rib(
1021 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1026 result
= verify_rib(
1038 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1041 step("Reload the FRR router")
1042 # stop/start -> restart FRR router and verify
1043 stop_router(tgen
, "r2")
1045 start_router(tgen
, "r2")
1048 "After reload of FRR router , static route installed"
1049 " in RIB and FIB properly ."
1055 "network": NETWORK2
[addr_type
],
1056 "next_hop": next_hop_ip
["nh1"][addr_type
],
1057 "admin_distance": 10,
1062 nh
= [next_hop_ip
["nh1"][addr_type
]]
1065 result
= verify_rib(
1066 tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
, protocol
=protocol
, fib
=True
1070 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
1074 result
= verify_bgp_rib(tgen
, addr_type
, dut
, rte1_nh1
, next_hop
=nh
)
1077 ), "Testcase {} : Failed \nError: Routes is" "missing in RIB".format(tc_name
)
1083 "network": NETWORK2
[addr_type
],
1084 "next_hop": next_hop_ip
["nh2"][addr_type
],
1085 "admin_distance": 20,
1090 nh
= [next_hop_ip
["nh2"][addr_type
]]
1093 result
= verify_rib(
1105 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1109 result
= verify_bgp_rib(tgen
, addr_type
, dut
, rte2_nh2
, next_hop
=nh
)
1112 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1114 result
= verify_rib(
1126 ), "Testcase {} : Failed \nError: Routes is" "not active in RIB".format(tc_name
)
1128 write_test_footer(tc_name
)
1131 def test_same_rte_from_bgp_static_p0_tc5_ebgp(request
):
1133 Verify RIB status when same route advertise via BGP and static
1137 tc_name
= request
.node
.name
1138 write_test_header(tc_name
)
1139 tgen
= get_topogen()
1140 # Don't run this test if we have any failure.
1141 if tgen
.routers_have_failure():
1142 pytest
.skip(tgen
.errors
)
1144 reset_config_on_routers(tgen
)
1146 NEXT_HOP_IP
= populate_nh()
1147 step("Configure EBGP IPv4 peering between R2 and R3 router.")
1150 "Configure IPv4 static route (10.1.1.1/24) in R2 with next hop"
1151 "N1 (28.1.1.2 ) and N2 (29.1.1.2) , Static route next-hop present"
1155 for addr_type
in ADDR_TYPES
:
1160 "network": NETWORK
[addr_type
],
1161 "next_hop": NEXT_HOP_IP
["nh1"][addr_type
],
1164 "network": NETWORK
[addr_type
],
1165 "next_hop": NEXT_HOP_IP
["nh2"][addr_type
],
1170 logger
.info("Configure static routes")
1171 result
= create_static_routes(tgen
, input_dict_4
)
1172 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1176 step("Configure redistribute static in BGP.")
1177 for addr_type
in ADDR_TYPES
:
1183 "unicast": {"redistribute": [{"redist_type": "static"}]}
1189 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1190 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1193 step("Verify on R3 , route receive on R3 BGP table ")
1195 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
1198 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
1202 step("Verify route installed in the RIB and FIB of R3")
1204 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
)
1207 ), "Testcase {} : Failed \nError: Route is" " still present in RIB".format(
1212 "Configure 2 links/interfaces between R1 and R3 , keep one"
1213 "interface in shut (active) state and other interface in no shut"
1217 intf
= topo
["routers"]["r3"]["links"]["r1-link0"]["interface"]
1218 shutdown_bringup_interface(tgen
, dut
, intf
, False)
1221 "Configure same static route (10.1.1.1/24) in R3 with inactive"
1226 "Configure same static route 10.1.1.1/24) again in R3 with"
1227 "active nexthop interface"
1229 for addr_type
in ADDR_TYPES
:
1234 "network": NETWORK
[addr_type
],
1235 "next_hop": topo
["routers"]["r1"]["links"]["r3-link0"][
1240 "network": NETWORK
[addr_type
],
1241 "next_hop": topo
["routers"]["r1"]["links"]["r3-link1"][
1248 logger
.info("Configure static routes")
1249 result
= create_static_routes(tgen
, input_dict_4
)
1250 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1255 "Verify when static route configure with inactive nexthop , "
1256 "verify BGP received route is active in the RIB and FIB"
1259 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
1262 ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format(
1267 result
= verify_rib(
1268 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, fib
=True
1272 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
1274 step("Remove the static route on R3 configured with active" "interface")
1275 for addr_type
in ADDR_TYPES
:
1280 "network": NETWORK
[addr_type
],
1281 "next_hop": topo
["routers"]["r1"]["links"]["r3-link0"][
1287 "network": NETWORK
[addr_type
],
1288 "next_hop": topo
["routers"]["r1"]["links"]["r3-link1"][
1296 logger
.info("Configure static routes")
1297 result
= create_static_routes(tgen
, input_dict_4
)
1298 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1302 "After removing the static route with active nexthop verify "
1303 "BGP received route is became active in RIB and FIB"
1306 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
1309 ), "Testcase {} : Failed \nError: Route is" " missing in BGP RIB".format(
1314 result
= verify_rib(
1315 tgen
, addr_type
, dut
, input_dict_4
, protocol
=protocol
, fib
=True
1319 ), "Testcase {} : Failed \nError: Route is" " missing in RIB".format(tc_name
)
1321 write_test_footer(tc_name
)
1324 if __name__
== "__main__":
1325 args
= ["-s"] + sys
.argv
[1:]
1326 sys
.exit(pytest
.main(args
))