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 Following tests are covered to test BGP Multi-VRF:
14 Do a shut and no shut on connecting interface of DUT,
15 to see if all vrf instances clear their respective BGP tables
16 during the interface down and restores when interface brought
18 VRF leaking - next-hop interface is flapping.
20 VRF - VLANs - Routing Table ID - combination testcase
23 Verify that all vrf instances fall back
24 to backup path, if primary link goes down.
26 Restart BGPd daemon on DUT to check if all the
27 routes in respective vrfs are reinstalled..
29 Delete a VRF instance from DUT and check if the routes get
30 deleted from subsequent neighbour routers and appears again once VRF
33 Verify that VRF names are locally significant
34 to a router, and end to end connectivity depends on unique
35 virtual circuits (using VLANs or separate physical interfaces).
37 Restart all FRR services (reboot DUT) to check if all
38 the routes in respective vrfs are reinstalled.
45 from copy
import deepcopy
46 from time
import sleep
49 # Save the Current Working Directory to find configuration files.
50 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
51 sys
.path
.append(os
.path
.join(CWD
, "../"))
52 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
54 # Required to instantiate the topology builder class.
56 # pylint: disable=C0413
57 # Import topogen and topotest helpers
58 from lib
.topogen
import Topogen
, get_topogen
59 from lib
.topotest
import iproute2_is_vrf_capable
60 from lib
.common_config
import (
67 reset_config_on_routers
,
69 shutdown_bringup_interface
,
73 create_interfaces_cfg
,
74 create_interface_in_kernel
,
75 get_frr_ipv6_linklocal
,
78 required_linux_kernel_version
,
85 from lib
.topolog
import logger
86 from lib
.bgp
import clear_bgp
, verify_bgp_rib
, create_router_bgp
, verify_bgp_convergence
87 from lib
.topojson
import build_config_from_json
90 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
94 NETWORK1_1
= {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
95 NETWORK1_2
= {"ipv4": "1.1.1.2/32", "ipv6": "1::2/128"}
96 NETWORK2_1
= {"ipv4": "2.1.1.1/32", "ipv6": "2::1/128"}
97 NETWORK2_2
= {"ipv4": "2.1.1.2/32", "ipv6": "2::2/128"}
98 NETWORK3_1
= {"ipv4": "3.1.1.1/32", "ipv6": "3::1/128"}
99 NETWORK3_2
= {"ipv4": "3.1.1.2/32", "ipv6": "3::2/128"}
100 NETWORK4_1
= {"ipv4": "4.1.1.1/32", "ipv6": "4::1/128"}
101 NETWORK4_2
= {"ipv4": "4.1.1.2/32", "ipv6": "4::2/128"}
102 NETWORK9_1
= {"ipv4": "100.1.0.1/30", "ipv6": "100::1/126"}
103 NETWORK9_2
= {"ipv4": "100.1.0.2/30", "ipv6": "100::2/126"}
105 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
108 "ipv4": "20.20.20.20/32",
109 "ipv6": "20::20:20/128",
115 PREFERRED_NEXT_HOP
= "link_local"
118 def setup_module(mod
):
120 Sets up the pytest environment
124 # Required linux kernel version for this suite to run.
125 result
= required_linux_kernel_version("4.14")
126 if result
is not True:
127 pytest
.skip("Kernel requirements are not met")
129 # iproute2 needs to support VRFs for this suite to run.
130 if not iproute2_is_vrf_capable():
131 pytest
.skip("Installed iproute2 version does not support VRFs")
133 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
134 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
135 logger
.info("=" * 40)
137 logger
.info("Running setup_module to create topology")
139 # This function initiates the topology build with Topogen...
140 json_file
= "{}/bgp_multi_vrf_topo2.json".format(CWD
)
141 tgen
= Topogen(json_file
, mod
.__name
__)
143 topo
= tgen
.json_topo
144 # ... and here it calls Mininet initialization functions.
146 # Starting topology, create tmp files which are loaded to routers
147 # to start daemons and then start routers
150 # Creating configuration from JSON
151 build_config_from_json(tgen
, topo
)
153 global BGP_CONVERGENCE
155 ADDR_TYPES
= check_address_types()
157 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
158 assert BGP_CONVERGENCE
is True, "setup_module : Failed \n Error: {}".format(
162 logger
.info("Running setup_module() done")
165 def teardown_module():
166 """Teardown the pytest environment"""
168 logger
.info("Running teardown_module to delete topology")
172 # Stop toplogy and Remove tmp files
176 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
178 logger
.info("=" * 40)
181 #####################################################
185 #####################################################
188 def test_vrf_with_multiple_links_p1(request
):
191 Verify that all vrf instances fall back
192 to backup path, if primary link goes down.
196 tc_name
= request
.node
.name
197 write_test_header(tc_name
)
199 if tgen
.routers_have_failure():
200 check_router_status(tgen
)
203 "Configure BGP neighborships(IPv4+IPv6) between R1 and R4 "
204 "using exact same link IPs for all 4 VRFs."
207 topo_modify
= deepcopy(topo
)
208 build_config_from_json(tgen
, topo_modify
)
210 interfaces
= ["link1", "link2", "link3", "link4"]
211 for interface
in interfaces
:
212 topo_modify
["routers"]["r1"]["links"]["r4-{}".format(interface
)][
215 topo_modify
["routers"]["r4"]["links"]["r1-{}".format(interface
)][
219 step("Build interface config from json")
220 create_interfaces_cfg(tgen
, topo_modify
["routers"])
222 interfaces
= ["link1", "link2", "link3", "link4"]
223 for interface
in interfaces
:
224 del topo_modify
["routers"]["r1"]["links"]["r4-{}".format(interface
)]["delete"]
225 del topo_modify
["routers"]["r4"]["links"]["r1-{}".format(interface
)]["delete"]
229 for addr_type
in ADDR_TYPES
:
230 interfaces
= ["link1", "link2", "link3", "link4"]
231 for interface
in interfaces
:
232 intf_name_r1
= topo_modify
["routers"]["r1"]["links"][
233 "r4-{}".format(interface
)
235 topo_modify
["routers"]["r1"]["links"]["r4-{}".format(interface
)][
237 ] = NETWORK9_1
[addr_type
]
239 intf_name_r4
= topo_modify
["routers"]["r4"]["links"][
240 "r1-{}".format(interface
)
242 topo_modify
["routers"]["r4"]["links"]["r1-{}".format(interface
)][
244 ] = NETWORK9_2
[addr_type
]
246 r1_config
.append("interface {}".format(intf_name_r1
))
247 r4_config
.append("interface {}".format(intf_name_r4
))
248 if addr_type
== "ipv4":
249 r1_config
.append("no ip address {}".format(NETWORK9_1
[addr_type
]))
250 r4_config
.append("no ip address {}".format(NETWORK9_2
[addr_type
]))
252 r1_config
.append("no ipv6 address {}".format(NETWORK9_1
[addr_type
]))
253 r4_config
.append("no ipv6 address {}".format(NETWORK9_2
[addr_type
]))
255 step("Build interface config from json")
256 create_interfaces_cfg(tgen
, topo_modify
["routers"])
258 step("Create bgp config")
259 result
= create_router_bgp(tgen
, topo_modify
["routers"])
260 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
262 step("Verify BGP convergence")
264 result
= verify_bgp_convergence(tgen
, topo_modify
)
265 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
268 "Advertise below prefixes in BGP using static redistribution"
269 " for both vrfs (RED_A and BLUE_A) on router R2.."
272 for addr_type
in ADDR_TYPES
:
277 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
278 "next_hop": NEXT_HOP_IP
[addr_type
],
282 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
283 "next_hop": NEXT_HOP_IP
[addr_type
],
287 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
288 "next_hop": NEXT_HOP_IP
[addr_type
],
292 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
293 "next_hop": NEXT_HOP_IP
[addr_type
],
299 result
= create_static_routes(tgen
, input_dict_1
)
300 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
304 step("Redistribute static..")
308 temp
= {dut
: {"bgp": []}}
309 input_dict_3
.update(temp
)
311 VRFS
= ["RED_A", "RED_B", "BLUE_A", "BLUE_B"]
312 AS_NUM
= [100, 100, 100, 100]
314 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
315 temp
[dut
]["bgp"].append(
321 "unicast": {"redistribute": [{"redist_type": "static"}]}
324 "unicast": {"redistribute": [{"redist_type": "static"}]}
330 result
= create_router_bgp(tgen
, topo_modify
, input_dict_3
)
331 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
333 step("Verify routes are installed with same nexthop in different" " VRFs")
334 result
= verify_bgp_convergence(tgen
, topo_modify
)
335 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
337 for addr_type
in ADDR_TYPES
:
343 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
344 "next_hop": NEXT_HOP_IP
[addr_type
],
351 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
355 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
356 assert result
is True, "Testcase {} : Failed \n Error {}".format(
364 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
365 "next_hop": NEXT_HOP_IP
[addr_type
],
372 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
376 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
377 assert result
is True, "Testcase {} : Failed \n Error {}".format(
385 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
386 "next_hop": NEXT_HOP_IP
[addr_type
],
393 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
397 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
398 assert result
is True, "Testcase {} : Failed \n Error {}".format(
406 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
407 "next_hop": NEXT_HOP_IP
[addr_type
],
414 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
418 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
419 assert result
is True, "Testcase {} : Failed \n Error {}".format(
424 "Configure a route-map on R3 to prepend as-path and apply"
425 " for neighbour router R2 in both vrfs, in inbound direction."
434 "set": {"path": {"as_num": 123, "as_action": "prepend"}},
440 result
= create_route_maps(tgen
, input_dict_4
)
441 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
443 step("Apply route-map to neighbours")
445 "Configure ECMP on router R3 using 'max-path' command for both"
446 " VRFs RED_A and BLUE_A."
463 {"name": "ASP", "direction": "in"}
478 {"name": "ASP", "direction": "in"}
488 "name": "rmap_global",
511 {"name": "ASP", "direction": "in"}
526 {"name": "ASP", "direction": "in"}
547 {"name": "ASP", "direction": "in"}
562 {"name": "ASP", "direction": "in"}
572 "name": "rmap_global",
595 {"name": "ASP", "direction": "in"}
610 {"name": "ASP", "direction": "in"}
624 result
= create_router_bgp(tgen
, topo_modify
, input_dict_5
)
625 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
627 result
= verify_bgp_convergence(tgen
, topo_modify
)
628 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
630 for addr_type
in ADDR_TYPES
:
637 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
644 intf
= topo_modify
["routers"][peer
]["links"]["r3-link1"]["interface"]
645 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
646 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="RED_A")
648 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link1"][
652 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
653 assert result
is True, "Testcase {} : Failed \n Error {}".format(
661 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
668 intf
= topo
["routers"][peer
]["links"]["r3-link3"]["interface"]
669 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
670 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="BLUE_A")
672 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link3"][
676 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
677 assert result
is True, "Testcase {} : Failed \n Error {}".format(
682 "Configure ECMP on router R3 using max-path command for"
683 " both VRFs RED_A and BLUE_A."
733 result
= create_router_bgp(tgen
, topo_modify
, input_dict_7
)
734 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
736 step("R3 should install prefixes from both next-hops (R2 and R4)")
737 result
= verify_bgp_convergence(tgen
, topo_modify
)
738 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
740 for addr_type
in ADDR_TYPES
:
747 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
754 intf
= topo_modify
["routers"][peer
]["links"]["r3-link1"]["interface"]
755 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
756 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="RED_A")
758 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link1"][
762 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
763 assert result
is True, "Testcase {} : Failed \n Error {}".format(
771 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
778 intf
= topo_modify
["routers"][peer
]["links"]["r3-link3"]["interface"]
779 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
780 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="BLUE_A")
782 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link3"][
786 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
787 assert result
is True, "Testcase {} : Failed \n Error {}".format(
791 step("Shutdown interface between R2 and R3 for vrfs RED_A and " "BLUE_A.")
793 intf1
= topo_modify
["routers"]["r2"]["links"]["r3-link1"]["interface"]
794 intf2
= topo_modify
["routers"]["r2"]["links"]["r3-link3"]["interface"]
796 interfaces
= [intf1
, intf2
]
797 for intf
in interfaces
:
798 shutdown_bringup_interface(tgen
, "r2", intf
, False)
800 for addr_type
in ADDR_TYPES
:
807 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
814 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link1"][addr_type
].split(
818 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
819 assert result
is True, "Testcase {} : Failed \n Error {}".format(
827 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
834 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link3"][addr_type
].split(
838 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
839 assert result
is True, "Testcase {} : Failed \n Error {}".format(
843 step("Unshut the interfaces between R2 and R3 for vrfs RED_A and BLUE_A.")
845 for intf
in interfaces
:
846 shutdown_bringup_interface(tgen
, "r2", intf
, True)
848 for addr_type
in ADDR_TYPES
:
855 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
862 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link1"][addr_type
].split(
866 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
867 assert result
is True, "Testcase {} : Failed \n Error {}".format(
875 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
882 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link3"][addr_type
].split(
886 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
887 assert result
is True, "Testcase {} : Failed \n Error {}".format(
891 step("Remove route-map from R3 for vrfs RED_A and BLUE_A.")
932 "name": "rmap_global",
980 "name": "rmap_global",
996 result
= create_router_bgp(tgen
, topo_modify
, input_dict_6
)
997 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
999 result
= verify_bgp_convergence(tgen
, topo_modify
)
1000 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1002 for addr_type
in ADDR_TYPES
:
1008 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1015 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link1"][addr_type
].split(
1019 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
1020 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1028 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1035 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link3"][addr_type
].split(
1039 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
1040 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1044 step("Shutdown links between between R2 and R3 for vrfs RED_A and" " BLUE_A.")
1046 for intf
in interfaces
:
1047 shutdown_bringup_interface(tgen
, "r2", intf
, False)
1049 for addr_type
in ADDR_TYPES
:
1055 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1062 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link1"][addr_type
].split(
1066 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
1067 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1075 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1082 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link3"][addr_type
].split(
1086 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
1087 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1091 step("Bringup links between between R2 and R3 for vrfs RED_A and" " BLUE_A.")
1093 for intf
in interfaces
:
1094 shutdown_bringup_interface(tgen
, "r2", intf
, True)
1096 step("Deleting manualy assigned ip address from router r1 and r4 interfaces")
1097 raw_config
= {"r1": {"raw_config": r1_config
}, "r4": {"raw_config": r4_config
}}
1098 result
= apply_raw_config(tgen
, raw_config
)
1099 assert result
is True, "Testcase {} : Failed Error: {}".format(tc_name
, result
)
1101 write_test_footer(tc_name
)
1104 def test_shut_noshut_p1(request
):
1107 Do a shut and no shut on connecting interface of DUT,
1108 to see if all vrf instances clear their respective BGP tables
1109 during the interface down and restores when interface brought
1113 tgen
= get_topogen()
1114 tc_name
= request
.node
.name
1115 write_test_header(tc_name
)
1116 reset_config_on_routers(tgen
)
1118 if tgen
.routers_have_failure():
1119 check_router_status(tgen
)
1121 step("Build interface config from json")
1122 create_interfaces_cfg(tgen
, topo
["routers"])
1124 if tgen
.routers_have_failure():
1125 pytest
.skip(tgen
.errors
)
1128 "Advertise unique prefixes in BGP using static redistribution"
1129 " for both vrfs (RED_A and RED_B) on router RED_1."
1132 for addr_type
in ADDR_TYPES
:
1137 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1138 "next_hop": NEXT_HOP_IP
[addr_type
],
1142 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1143 "next_hop": NEXT_HOP_IP
[addr_type
],
1149 result
= create_static_routes(tgen
, input_dict_1
)
1150 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1155 "Advertise unique prefixes in BGP using static redistribution"
1156 " for both vrfs (BLUE_A and BLUE_B) on router BLUE_1."
1159 for addr_type
in ADDR_TYPES
:
1164 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1165 "next_hop": NEXT_HOP_IP
[addr_type
],
1169 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1170 "next_hop": NEXT_HOP_IP
[addr_type
],
1176 result
= create_static_routes(tgen
, input_dict_2
)
1177 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1181 step("Redistribute static..")
1184 for dut
in ["red1", "blue1"]:
1185 temp
= {dut
: {"bgp": []}}
1186 input_dict_3
.update(temp
)
1189 VRFS
= ["RED_A", "RED_B"]
1192 VRFS
= ["BLUE_A", "BLUE_B"]
1195 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
1196 temp
[dut
]["bgp"].append(
1202 "unicast": {"redistribute": [{"redist_type": "static"}]}
1205 "unicast": {"redistribute": [{"redist_type": "static"}]}
1211 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1212 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1214 step("Api call to modify BGP timers")
1229 "keepalivetimer": KEEPALIVETIMER
,
1230 "holddowntimer": HOLDDOWNTIMER
,
1243 "keepalivetimer": KEEPALIVETIMER
,
1244 "holddowntimer": HOLDDOWNTIMER
,
1263 "keepalivetimer": KEEPALIVETIMER
,
1264 "holddowntimer": HOLDDOWNTIMER
,
1277 "keepalivetimer": KEEPALIVETIMER
,
1278 "holddowntimer": HOLDDOWNTIMER
,
1297 "keepalivetimer": KEEPALIVETIMER
,
1298 "holddowntimer": HOLDDOWNTIMER
,
1311 "keepalivetimer": KEEPALIVETIMER
,
1312 "holddowntimer": HOLDDOWNTIMER
,
1331 "keepalivetimer": KEEPALIVETIMER
,
1332 "holddowntimer": HOLDDOWNTIMER
,
1345 "keepalivetimer": KEEPALIVETIMER
,
1346 "holddowntimer": HOLDDOWNTIMER
,
1369 "keepalivetimer": KEEPALIVETIMER
,
1370 "holddowntimer": HOLDDOWNTIMER
,
1383 "keepalivetimer": KEEPALIVETIMER
,
1384 "holddowntimer": HOLDDOWNTIMER
,
1403 "keepalivetimer": KEEPALIVETIMER
,
1404 "holddowntimer": HOLDDOWNTIMER
,
1417 "keepalivetimer": KEEPALIVETIMER
,
1418 "holddowntimer": HOLDDOWNTIMER
,
1437 "keepalivetimer": KEEPALIVETIMER
,
1438 "holddowntimer": HOLDDOWNTIMER
,
1451 "keepalivetimer": KEEPALIVETIMER
,
1452 "holddowntimer": HOLDDOWNTIMER
,
1471 "keepalivetimer": KEEPALIVETIMER
,
1472 "holddowntimer": HOLDDOWNTIMER
,
1485 "keepalivetimer": KEEPALIVETIMER
,
1486 "holddowntimer": HOLDDOWNTIMER
,
1499 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1500 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1502 for addr_type
in ADDR_TYPES
:
1503 clear_bgp(tgen
, addr_type
, "r1", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
1505 clear_bgp(tgen
, addr_type
, "r2", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
1507 step("Shut down connecting interface between R1<<>>R2 on R1.")
1508 step("Repeat step-3 and step-4 10 times.")
1510 for count
in range(1, 2):
1511 step("Iteration {}".format(count
))
1512 step("Shut down connecting interface between R1<<>>R2 on R1.")
1514 intf1
= topo
["routers"]["r1"]["links"]["r2-link1"]["interface"]
1515 intf2
= topo
["routers"]["r1"]["links"]["r2-link2"]["interface"]
1516 intf3
= topo
["routers"]["r1"]["links"]["r2-link3"]["interface"]
1517 intf4
= topo
["routers"]["r1"]["links"]["r2-link4"]["interface"]
1519 interfaces
= [intf1
, intf2
, intf3
, intf4
]
1520 for intf
in interfaces
:
1521 shutdown_bringup_interface(tgen
, "r1", intf
, False)
1524 "On R2, all BGP peering in respective vrf instances go down"
1525 " when the interface is shut"
1528 step("Sleeping for {}+1 sec..".format(HOLDDOWNTIMER
))
1529 sleep(HOLDDOWNTIMER
+ 1)
1531 result
= verify_bgp_convergence(tgen
, topo
, expected
=False)
1534 ), "Testcase {} : Failed \nExpected Behaviour: BGP will not be converged \nError {}".format(
1538 for addr_type
in ADDR_TYPES
:
1544 "network": [NETWORK1_1
[addr_type
]]
1545 + [NETWORK1_2
[addr_type
]],
1546 "next_hop": NEXT_HOP_IP
[addr_type
],
1550 "network": [NETWORK2_1
[addr_type
]]
1551 + [NETWORK2_2
[addr_type
]],
1552 "next_hop": NEXT_HOP_IP
[addr_type
],
1563 "network": [NETWORK1_1
[addr_type
]]
1564 + [NETWORK1_2
[addr_type
]],
1565 "next_hop": NEXT_HOP_IP
[addr_type
],
1569 "network": [NETWORK2_1
[addr_type
]]
1570 + [NETWORK2_2
[addr_type
]],
1571 "next_hop": NEXT_HOP_IP
[addr_type
],
1578 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
1581 ), "Testcase {} : Failed \nExpected Behaviour: Routes are flushed out \nError {}".format(
1585 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
1588 ), "Testcase {} : Failed \nExpected Behaviour: Routes are flushed out \nError {}".format(
1592 step("Bring up connecting interface between R1<<>>R2 on R1.")
1593 for intf
in interfaces
:
1594 shutdown_bringup_interface(tgen
, "r1", intf
, True)
1597 "R2 restores BGP peering and routing tables in all vrf "
1598 "instances when interface brought back up again"
1601 result
= verify_bgp_convergence(tgen
, topo
)
1602 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1606 for addr_type
in ADDR_TYPES
:
1612 "network": [NETWORK1_1
[addr_type
]]
1613 + [NETWORK1_2
[addr_type
]],
1614 "next_hop": NEXT_HOP_IP
[addr_type
],
1618 "network": [NETWORK2_1
[addr_type
]]
1619 + [NETWORK2_2
[addr_type
]],
1620 "next_hop": NEXT_HOP_IP
[addr_type
],
1631 "network": [NETWORK1_1
[addr_type
]]
1632 + [NETWORK1_2
[addr_type
]],
1633 "next_hop": NEXT_HOP_IP
[addr_type
],
1637 "network": [NETWORK2_1
[addr_type
]]
1638 + [NETWORK2_2
[addr_type
]],
1639 "next_hop": NEXT_HOP_IP
[addr_type
],
1646 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
1647 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1651 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
1652 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1656 write_test_footer(tc_name
)
1659 def test_vrf_vlan_routing_table_p1(request
):
1662 VRF - VLANs - Routing Table ID - combination testcase
1666 tgen
= get_topogen()
1667 tc_name
= request
.node
.name
1668 write_test_header(tc_name
)
1669 reset_config_on_routers(tgen
)
1671 if tgen
.routers_have_failure():
1672 check_router_status(tgen
)
1675 "Advertise unique prefixes(IPv4+IPv6) in BGP using"
1676 " network command for vrf RED_A on router R2"
1679 for addr_type
in ADDR_TYPES
:
1684 "network": NETWORK1_1
[addr_type
],
1685 "next_hop": NEXT_HOP_IP
[addr_type
],
1691 result
= create_static_routes(tgen
, input_dict_1
)
1692 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1696 step("Redistribute static..")
1706 "unicast": {"redistribute": [{"redist_type": "static"}]}
1709 "unicast": {"redistribute": [{"redist_type": "static"}]}
1717 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1718 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1721 "Verify that static routes(IPv4+IPv6) is overridden and doesn't"
1722 " have duplicate entries within VRF RED_A on router RED-1"
1725 result
= verify_bgp_convergence(tgen
, topo
)
1726 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1728 for addr_type
in ADDR_TYPES
:
1734 "network": NETWORK1_1
[addr_type
],
1735 "next_hop": NEXT_HOP_IP
[addr_type
],
1742 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
1743 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1747 step("Api call to modify BGP timers")
1762 "keepalivetimer": KEEPALIVETIMER
,
1763 "holddowntimer": HOLDDOWNTIMER
,
1776 "keepalivetimer": KEEPALIVETIMER
,
1777 "holddowntimer": HOLDDOWNTIMER
,
1790 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1791 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1793 for addr_type
in ADDR_TYPES
:
1794 clear_bgp(tgen
, addr_type
, "r3", vrf
=["RED_A"])
1796 step("Repeat for 5 times.")
1798 for count
in range(1, 2):
1799 step("Iteration {}..".format(count
))
1800 step("Delete a specific VRF instance(RED_A) from router R3")
1802 input_dict
= {"r3": {"vrfs": [{"name": "RED_A", "id": "1", "delete": True}]}}
1804 result
= create_vrf_cfg(tgen
, input_dict
)
1805 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1809 step("Sleeping for {}+1 sec..".format(HOLDDOWNTIMER
))
1810 sleep(HOLDDOWNTIMER
+ 1)
1812 for addr_type
in ADDR_TYPES
:
1818 "network": NETWORK1_1
[addr_type
],
1819 "next_hop": NEXT_HOP_IP
[addr_type
],
1826 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
1829 ), "Testcase {} : Failed \n Expected Behaviour: Routes are cleaned \n Error {}".format(
1833 step("Add/reconfigure the same VRF instance again")
1835 result
= create_vrf_cfg(tgen
, {"r3": topo
["routers"]["r3"]})
1836 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1841 "After deleting VRFs ipv6 addresses will be deleted from kernel "
1842 " Adding back ipv6 addresses"
1848 for c_link
, c_data
in topo
["routers"][dut
]["links"].items():
1849 if c_data
["vrf"] != vrf
:
1852 intf_name
= c_data
["interface"]
1853 intf_ipv6
= c_data
["ipv6"]
1855 create_interface_in_kernel(
1856 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
1859 step("Sleeping for {}+1 sec..".format(HOLDDOWNTIMER
))
1860 sleep(HOLDDOWNTIMER
+ 1)
1862 for addr_type
in ADDR_TYPES
:
1868 "network": NETWORK1_1
[addr_type
],
1869 "next_hop": NEXT_HOP_IP
[addr_type
],
1876 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
1877 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1881 write_test_footer(tc_name
)
1884 def test_vrf_route_leaking_next_hop_interface_flapping_p1(request
):
1887 VRF leaking - next-hop interface is flapping.
1890 tgen
= get_topogen()
1891 tc_name
= request
.node
.name
1892 write_test_header(tc_name
)
1893 reset_config_on_routers(tgen
)
1895 if tgen
.routers_have_failure():
1896 check_router_status(tgen
)
1898 step("Create loopback interface")
1900 for addr_type
in ADDR_TYPES
:
1901 create_interface_in_kernel(
1905 LOOPBACK_2
[addr_type
],
1909 intf_red1_r11
= topo
["routers"]["red1"]["links"]["r1-link2"]["interface"]
1910 for addr_type
in ADDR_TYPES
:
1915 "network": LOOPBACK_2
[addr_type
],
1916 "interface": intf_red1_r11
,
1917 "nexthop_vrf": "RED_B",
1923 result
= create_static_routes(tgen
, input_dict_1
)
1924 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1928 step("Redistribute static..")
1938 "unicast": {"redistribute": [{"redist_type": "static"}]}
1941 "unicast": {"redistribute": [{"redist_type": "static"}]}
1949 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1950 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1952 result
= verify_bgp_convergence(tgen
, topo
)
1953 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1955 step("VRF RED_A should install a route for vrf RED_B's " "loopback ip.")
1956 for addr_type
in ADDR_TYPES
:
1962 "network": LOOPBACK_2
[addr_type
],
1963 "interface": intf_red1_r11
,
1964 "nexthop_vrf": "RED_B",
1971 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, protocol
="static")
1972 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1976 step("Repeat step-2 to 4 at least 5 times")
1978 for count
in range(1, 2):
1979 intf1
= topo
["routers"]["red1"]["links"]["r1-link2"]["interface"]
1982 "Iteration {}: Shutdown interface {} on router"
1983 "RED_1.".format(count
, intf1
)
1985 shutdown_bringup_interface(tgen
, "red1", intf1
, False)
1987 step("Verify that RED_A removes static route from routing " "table.")
1989 for addr_type
in ADDR_TYPES
:
1995 "network": LOOPBACK_2
[addr_type
],
1996 "interface": intf_red1_r11
,
1997 "nexthop_vrf": "RED_B",
2004 result
= verify_rib(
2005 tgen
, addr_type
, dut
, input_dict_1
, protocol
="static", expected
=False
2007 assert result
is not True, (
2008 "Testcase {} : Failed \n Expected Behaviour: Routes are"
2009 " not present Error {}".format(tc_name
, result
)
2012 step("Bring up interface {} on router RED_1 again.".format(intf1
))
2013 shutdown_bringup_interface(tgen
, "red1", intf1
, True)
2016 "Verify that RED_A reinstalls static route pointing to "
2017 "RED_B's IP in routing table again"
2020 for addr_type
in ADDR_TYPES
:
2026 "network": LOOPBACK_2
[addr_type
],
2027 "interface": intf_red1_r11
,
2028 "nexthop_vrf": "RED_B",
2035 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, protocol
="static")
2036 assert result
is True, "Testcase {} : Failed \n Error {}".format(
2040 write_test_footer(tc_name
)
2043 def test_restart_bgpd_daemon_p1(request
):
2046 Restart BGPd daemon on DUT to check if all the
2047 routes in respective vrfs are reinstalled..
2050 tgen
= get_topogen()
2051 tc_name
= request
.node
.name
2052 write_test_header(tc_name
)
2054 if tgen
.routers_have_failure():
2055 check_router_status(tgen
)
2057 reset_config_on_routers(tgen
)
2060 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1"
2061 " in vrf instances(RED_A and RED_B)."
2064 for addr_type
in ADDR_TYPES
:
2069 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2070 "next_hop": NEXT_HOP_IP
[addr_type
],
2074 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2075 "next_hop": NEXT_HOP_IP
[addr_type
],
2081 result
= create_static_routes(tgen
, input_dict_1
)
2082 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2087 "Advertise unique BGP prefixes(IPv4+IPv6) from BLUE_1 in"
2088 " vrf instances(BLUE_A and BLUE_B)."
2091 for addr_type
in ADDR_TYPES
:
2096 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2097 "next_hop": NEXT_HOP_IP
[addr_type
],
2101 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2102 "next_hop": NEXT_HOP_IP
[addr_type
],
2108 result
= create_static_routes(tgen
, input_dict_2
)
2109 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2113 step("Redistribute static..")
2116 for dut
in ["red1", "blue1"]:
2117 temp
= {dut
: {"bgp": []}}
2118 input_dict_3
.update(temp
)
2121 VRFS
= ["RED_A", "RED_B"]
2124 VRFS
= ["BLUE_A", "BLUE_B"]
2127 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2128 temp
[dut
]["bgp"].append(
2134 "unicast": {"redistribute": [{"redist_type": "static"}]}
2137 "unicast": {"redistribute": [{"redist_type": "static"}]}
2143 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2144 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2146 result
= verify_bgp_convergence(tgen
, topo
)
2147 assert result
is True, "Testcase {} :Failed\n Error {}".format(tc_name
, result
)
2149 step("Kill BGPd daemon on R1.")
2150 kill_router_daemons(tgen
, "r1", ["bgpd"])
2152 for addr_type
in ADDR_TYPES
:
2158 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2159 "next_hop": NEXT_HOP_IP
[addr_type
],
2163 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2164 "next_hop": NEXT_HOP_IP
[addr_type
],
2175 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2176 "next_hop": NEXT_HOP_IP
[addr_type
],
2180 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2181 "next_hop": NEXT_HOP_IP
[addr_type
],
2188 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
2189 assert result
is not True, (
2190 "Testcase {} : Failed \n "
2191 "Routes are still present in VRF RED_A and RED_B \n Error: {}".format(
2196 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
2197 assert result
is not True, (
2198 "Testcase {} : Failed \n "
2199 "Routes are still present in VRF BLUE_A and BLUE_B \n Error: {}".format(
2204 step("Bring up BGPd daemon on R1.")
2205 start_router_daemons(tgen
, "r1", ["bgpd"])
2207 result
= verify_bgp_convergence(tgen
, topo
)
2208 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2210 for addr_type
in ADDR_TYPES
:
2216 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2217 "next_hop": NEXT_HOP_IP
[addr_type
],
2221 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2222 "next_hop": NEXT_HOP_IP
[addr_type
],
2233 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2234 "next_hop": NEXT_HOP_IP
[addr_type
],
2238 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2239 "next_hop": NEXT_HOP_IP
[addr_type
],
2246 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
2247 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2249 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2250 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2252 write_test_footer(tc_name
)
2255 def test_delete_and_re_add_vrf_p1(request
):
2258 Delete a VRF instance from DUT and check if the routes get
2259 deleted from subsequent neighbour routers and appears again once VRF
2263 tgen
= get_topogen()
2264 tc_name
= request
.node
.name
2265 write_test_header(tc_name
)
2266 reset_config_on_routers(tgen
)
2268 if tgen
.routers_have_failure():
2269 pytest
.skip(tgen
.errors
)
2272 "Advertise unique prefixes in BGP using static redistribution"
2273 "for both vrfs (RED_A and RED_B) on router RED_1"
2276 for addr_type
in ADDR_TYPES
:
2281 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2282 "next_hop": NEXT_HOP_IP
[addr_type
],
2286 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2287 "next_hop": NEXT_HOP_IP
[addr_type
],
2293 result
= create_static_routes(tgen
, input_dict_1
)
2294 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2299 "Advertise unique prefixes in BGP using static redistribution"
2300 " for both vrfs (BLUE_A and BLUE_B) on router BLUE_1."
2303 for addr_type
in ADDR_TYPES
:
2308 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2309 "next_hop": NEXT_HOP_IP
[addr_type
],
2313 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
2314 "next_hop": NEXT_HOP_IP
[addr_type
],
2320 result
= create_static_routes(tgen
, input_dict_2
)
2321 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2325 step("Redistribute static for vrfs RED_A and RED_B and BLUE_A and BLUE_B")
2328 for dut
in ["red1", "blue1"]:
2329 temp
= {dut
: {"bgp": []}}
2330 input_dict_3
.update(temp
)
2333 VRFS
= ["RED_A", "RED_B"]
2336 VRFS
= ["BLUE_A", "BLUE_B"]
2339 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2340 temp
[dut
]["bgp"].append(
2346 "unicast": {"redistribute": [{"redist_type": "static"}]}
2349 "unicast": {"redistribute": [{"redist_type": "static"}]}
2355 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2356 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2358 step("Verifying RIB and FIB before deleting VRFs")
2359 result
= verify_bgp_convergence(tgen
, topo
)
2360 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
2362 for addr_type
in ADDR_TYPES
:
2368 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2369 "next_hop": NEXT_HOP_IP
[addr_type
],
2373 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2374 "next_hop": NEXT_HOP_IP
[addr_type
],
2381 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
2382 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2384 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
2385 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2387 for addr_type
in ADDR_TYPES
:
2393 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2394 "next_hop": NEXT_HOP_IP
[addr_type
],
2398 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
2399 "next_hop": NEXT_HOP_IP
[addr_type
],
2406 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2407 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2409 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2410 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2412 step("Api call to modify BGP timers")
2427 "keepalivetimer": KEEPALIVETIMER
,
2428 "holddowntimer": HOLDDOWNTIMER
,
2441 "keepalivetimer": KEEPALIVETIMER
,
2442 "holddowntimer": HOLDDOWNTIMER
,
2461 "keepalivetimer": KEEPALIVETIMER
,
2462 "holddowntimer": HOLDDOWNTIMER
,
2475 "keepalivetimer": KEEPALIVETIMER
,
2476 "holddowntimer": HOLDDOWNTIMER
,
2495 "keepalivetimer": KEEPALIVETIMER
,
2496 "holddowntimer": HOLDDOWNTIMER
,
2509 "keepalivetimer": KEEPALIVETIMER
,
2510 "holddowntimer": HOLDDOWNTIMER
,
2529 "keepalivetimer": KEEPALIVETIMER
,
2530 "holddowntimer": HOLDDOWNTIMER
,
2543 "keepalivetimer": KEEPALIVETIMER
,
2544 "holddowntimer": HOLDDOWNTIMER
,
2557 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
2558 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2560 for addr_type
in ADDR_TYPES
:
2561 clear_bgp(tgen
, addr_type
, "r1", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
2563 step("Delete vrfs RED_A and BLUE_A from R1.")
2568 {"name": "RED_A", "id": "1", "delete": True},
2569 {"name": "BLUE_A", "id": "3", "delete": True},
2574 result
= create_vrf_cfg(tgen
, input_dict
)
2575 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2578 "R2 must not receive the prefixes(in respective vrfs)"
2579 "originated from RED_1 and BLUE_1."
2582 step("Wait for {}+1 sec..".format(HOLDDOWNTIMER
))
2583 sleep(HOLDDOWNTIMER
+ 1)
2585 for addr_type
in ADDR_TYPES
:
2591 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2592 "next_hop": NEXT_HOP_IP
[addr_type
],
2600 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2601 "next_hop": NEXT_HOP_IP
[addr_type
],
2608 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
2609 assert result
is not True, (
2610 "Testcase {} :Failed \n Expected Behaviour:"
2611 " Routes are not present \n Error {}".format(tc_name
, result
)
2614 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
2615 assert result
is not True, (
2616 "Testcase {} :Failed \n Expected Behaviour:"
2617 " Routes are not present \n Error {}".format(tc_name
, result
)
2620 step("Add vrfs again RED_A and BLUE_A on R1.")
2622 result
= create_vrf_cfg(tgen
, {"r1": topo
["routers"]["r1"]})
2623 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2625 create_interfaces_cfg(tgen
, {"r1": topo
["routers"]["r1"]})
2626 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2629 "After deleting VRFs ipv6 addresses will be deleted from kernel "
2630 " Adding back ipv6 addresses"
2634 vrfs
= ["RED_A", "BLUE_A"]
2637 for c_link
, c_data
in topo
["routers"][dut
]["links"].items():
2638 if c_data
["vrf"] != vrf
:
2641 intf_name
= c_data
["interface"]
2642 intf_ipv6
= c_data
["ipv6"]
2644 create_interface_in_kernel(
2645 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
2649 "R2 should now receive the prefixes(in respective vrfs)"
2650 "again. Check the debugging logs as well. For verification"
2651 " use same commands as mention in step-3."
2654 for addr_type
in ADDR_TYPES
:
2660 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2661 "next_hop": NEXT_HOP_IP
[addr_type
],
2668 result
= verify_bgp_convergence(tgen
, topo
)
2669 assert result
is True, "Testcase {}: Failed\n Error {}".format(tc_name
, result
)
2671 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2672 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2674 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2675 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2677 for addr_type
in ADDR_TYPES
:
2683 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2684 "next_hop": NEXT_HOP_IP
[addr_type
],
2691 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2692 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2694 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2695 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2697 write_test_footer(tc_name
)
2700 def test_vrf_name_significance_p1(request
):
2703 Verify that VRF names are locally significant
2704 to a router, and end to end connectivity depends on unique
2705 virtual circuits (using VLANs or separate physical interfaces).
2708 tgen
= get_topogen()
2709 tc_name
= request
.node
.name
2710 write_test_header(tc_name
)
2711 reset_config_on_routers(tgen
)
2713 if tgen
.routers_have_failure():
2714 check_router_status(tgen
)
2717 "Advertise unique prefixes in BGP using static redistribution"
2718 "for both vrfs (RED_A and RED_B) on router RED_1"
2721 for addr_type
in ADDR_TYPES
:
2726 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2727 "next_hop": NEXT_HOP_IP
[addr_type
],
2731 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2732 "next_hop": NEXT_HOP_IP
[addr_type
],
2738 result
= create_static_routes(tgen
, input_dict_1
)
2739 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2744 "Advertise unique prefixes in BGP using static redistribution"
2745 " for both vrfs (BLUE_A and BLUE_B) on router BLUE_1."
2748 for addr_type
in ADDR_TYPES
:
2753 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2754 "next_hop": NEXT_HOP_IP
[addr_type
],
2758 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
2759 "next_hop": NEXT_HOP_IP
[addr_type
],
2765 result
= create_static_routes(tgen
, input_dict_2
)
2766 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2770 step("Redistribute static for vrfs RED_A and RED_B and BLUE_A and BLUE_B")
2773 for dut
in ["red1", "blue1"]:
2774 temp
= {dut
: {"bgp": []}}
2775 input_dict_3
.update(temp
)
2778 VRFS
= ["RED_A", "RED_B"]
2781 VRFS
= ["BLUE_A", "BLUE_B"]
2784 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2785 temp
[dut
]["bgp"].append(
2791 "unicast": {"redistribute": [{"redist_type": "static"}]}
2794 "unicast": {"redistribute": [{"redist_type": "static"}]}
2800 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2801 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2803 step("Configure allowas-in on red2 and blue2")
2818 "allowas-in": {"number_occurences": 2}
2831 "allowas-in": {"number_occurences": 2}
2850 "allowas-in": {"number_occurences": 2}
2863 "allowas-in": {"number_occurences": 2}
2886 "allowas-in": {"number_occurences": 2}
2899 "allowas-in": {"number_occurences": 2}
2918 "allowas-in": {"number_occurences": 2}
2931 "allowas-in": {"number_occurences": 2}
2944 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
2945 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2947 step("Verifying RIB and FIB before deleting VRFs")
2949 for addr_type
in ADDR_TYPES
:
2955 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2956 "next_hop": NEXT_HOP_IP
[addr_type
],
2966 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2967 "next_hop": NEXT_HOP_IP
[addr_type
],
2974 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
2975 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2977 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2978 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2980 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
2981 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2983 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2984 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2986 for addr_type
in ADDR_TYPES
:
2992 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2993 "next_hop": NEXT_HOP_IP
[addr_type
],
3004 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
3005 "next_hop": NEXT_HOP_IP
[addr_type
],
3012 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_3
)
3013 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3015 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
3016 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3018 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_3
)
3019 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3021 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_4
)
3022 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3024 step("Api call to modify BGP timers")
3039 "keepalivetimer": KEEPALIVETIMER
,
3040 "holddowntimer": HOLDDOWNTIMER
,
3053 "keepalivetimer": KEEPALIVETIMER
,
3054 "holddowntimer": HOLDDOWNTIMER
,
3073 "keepalivetimer": KEEPALIVETIMER
,
3074 "holddowntimer": HOLDDOWNTIMER
,
3087 "keepalivetimer": KEEPALIVETIMER
,
3088 "holddowntimer": HOLDDOWNTIMER
,
3107 "keepalivetimer": KEEPALIVETIMER
,
3108 "holddowntimer": HOLDDOWNTIMER
,
3121 "keepalivetimer": KEEPALIVETIMER
,
3122 "holddowntimer": HOLDDOWNTIMER
,
3141 "keepalivetimer": KEEPALIVETIMER
,
3142 "holddowntimer": HOLDDOWNTIMER
,
3155 "keepalivetimer": KEEPALIVETIMER
,
3156 "holddowntimer": HOLDDOWNTIMER
,
3179 "keepalivetimer": KEEPALIVETIMER
,
3180 "holddowntimer": HOLDDOWNTIMER
,
3193 "keepalivetimer": KEEPALIVETIMER
,
3194 "holddowntimer": HOLDDOWNTIMER
,
3213 "keepalivetimer": KEEPALIVETIMER
,
3214 "holddowntimer": HOLDDOWNTIMER
,
3227 "keepalivetimer": KEEPALIVETIMER
,
3228 "holddowntimer": HOLDDOWNTIMER
,
3251 "keepalivetimer": KEEPALIVETIMER
,
3252 "holddowntimer": HOLDDOWNTIMER
,
3265 "keepalivetimer": KEEPALIVETIMER
,
3266 "holddowntimer": HOLDDOWNTIMER
,
3285 "keepalivetimer": KEEPALIVETIMER
,
3286 "holddowntimer": HOLDDOWNTIMER
,
3299 "keepalivetimer": KEEPALIVETIMER
,
3300 "holddowntimer": HOLDDOWNTIMER
,
3313 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
3314 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3316 for addr_type
in ADDR_TYPES
:
3317 clear_bgp(tgen
, addr_type
, "r3", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
3319 clear_bgp(tgen
, addr_type
, "red2", vrf
=["RED_A", "RED_B"])
3321 clear_bgp(tgen
, addr_type
, "blue2", vrf
=["BLUE_A", "BLUE_B"])
3323 step("Delete vrfs RED_A and BLUE_A from R3")
3328 {"name": "RED_A", "id": "1", "delete": True},
3329 {"name": "BLUE_A", "id": "3", "delete": True},
3334 result
= create_vrf_cfg(tgen
, input_dict
)
3335 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3337 step("Waiting for {}+1..".format(HOLDDOWNTIMER
))
3338 sleep(HOLDDOWNTIMER
+ 1)
3340 step("Verify RIB and FIB after deleting VRFs")
3342 for addr_type
in ADDR_TYPES
:
3348 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3349 "next_hop": NEXT_HOP_IP
[addr_type
],
3356 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
3359 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3363 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
3366 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3370 for addr_type
in ADDR_TYPES
:
3376 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
3377 "next_hop": NEXT_HOP_IP
[addr_type
],
3384 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
3387 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3391 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
3394 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3398 step("Create 2 new VRFs PINK_A and GREY_A IN R3")
3400 topo_modify
= deepcopy(topo
)
3401 topo_modify
["routers"]["r3"]["vrfs"][0]["name"] = "PINK_A"
3402 topo_modify
["routers"]["r3"]["vrfs"][0]["id"] = "1"
3403 topo_modify
["routers"]["r3"]["vrfs"][2]["name"] = "GREY_A"
3404 topo_modify
["routers"]["r3"]["vrfs"][2]["id"] = "3"
3406 topo_modify
["routers"]["r3"]["links"]["red2-link1"]["vrf"] = "PINK_A"
3407 topo_modify
["routers"]["r3"]["links"]["blue2-link1"]["vrf"] = "GREY_A"
3409 topo_modify
["routers"]["r3"]["links"]["r2-link1"]["vrf"] = "PINK_A"
3410 topo_modify
["routers"]["r3"]["links"]["r2-link3"]["vrf"] = "GREY_A"
3412 topo_modify
["routers"]["r3"]["links"]["r4-link1"]["vrf"] = "PINK_A"
3413 topo_modify
["routers"]["r3"]["links"]["r4-link3"]["vrf"] = "GREY_A"
3415 topo_modify
["routers"]["r3"]["bgp"][0]["vrf"] = "PINK_A"
3416 topo_modify
["routers"]["r3"]["bgp"][2]["vrf"] = "GREY_A"
3418 result
= create_vrf_cfg(tgen
, {"r3": topo_modify
["routers"]["r3"]})
3419 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3421 create_interfaces_cfg(tgen
, {"r3": topo_modify
["routers"]["r3"]})
3422 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3424 result
= create_router_bgp(tgen
, topo_modify
["routers"])
3425 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3427 step("Api call to modify BGP timers")
3442 "keepalivetimer": KEEPALIVETIMER
,
3443 "holddowntimer": HOLDDOWNTIMER
,
3456 "keepalivetimer": KEEPALIVETIMER
,
3457 "holddowntimer": HOLDDOWNTIMER
,
3476 "keepalivetimer": KEEPALIVETIMER
,
3477 "holddowntimer": HOLDDOWNTIMER
,
3490 "keepalivetimer": KEEPALIVETIMER
,
3491 "holddowntimer": HOLDDOWNTIMER
,
3510 "keepalivetimer": KEEPALIVETIMER
,
3511 "holddowntimer": HOLDDOWNTIMER
,
3524 "keepalivetimer": KEEPALIVETIMER
,
3525 "holddowntimer": HOLDDOWNTIMER
,
3544 "keepalivetimer": KEEPALIVETIMER
,
3545 "holddowntimer": HOLDDOWNTIMER
,
3558 "keepalivetimer": KEEPALIVETIMER
,
3559 "holddowntimer": HOLDDOWNTIMER
,
3572 result
= create_router_bgp(tgen
, topo_modify
, input_dict_4
)
3573 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3575 for addr_type
in ADDR_TYPES
:
3576 clear_bgp(tgen
, addr_type
, "r3", vrf
=["PINK_A", "RED_B", "GREY_A", "BLUE_B"])
3579 "After deleting VRFs ipv6 addresses will be deleted from kernel "
3580 " Adding back ipv6 addresses"
3584 vrfs
= ["GREY_A", "PINK_A"]
3587 for c_link
, c_data
in topo_modify
["routers"][dut
]["links"].items():
3588 if c_data
["vrf"] != vrf
:
3591 intf_name
= c_data
["interface"]
3592 intf_ipv6
= c_data
["ipv6"]
3594 create_interface_in_kernel(
3595 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
3598 step("Waiting for {}+1 sec..".format(HOLDDOWNTIMER
))
3599 sleep(HOLDDOWNTIMER
+ 1)
3602 "Advertised prefixes should appear again in respective VRF"
3603 " table on routers RED_2 and BLUE_2. Verify fib and rib entries"
3606 for addr_type
in ADDR_TYPES
:
3612 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3613 "next_hop": NEXT_HOP_IP
[addr_type
],
3624 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3625 "next_hop": NEXT_HOP_IP
[addr_type
],
3632 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
3633 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3635 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
3636 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3638 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
3639 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3641 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
3642 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3644 for addr_type
in ADDR_TYPES
:
3650 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
3651 "next_hop": NEXT_HOP_IP
[addr_type
],
3662 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
3663 "next_hop": NEXT_HOP_IP
[addr_type
],
3670 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_3
)
3671 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3673 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
3674 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3676 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_3
)
3677 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3679 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_4
)
3680 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3682 write_test_footer(tc_name
)
3685 def test_restart_frr_services_p1(request
):
3688 Restart all FRR services (reboot DUT) to check if all
3689 the routes in respective vrfs are reinstalled.
3692 tgen
= get_topogen()
3693 tc_name
= request
.node
.name
3694 write_test_header(tc_name
)
3695 reset_config_on_routers(tgen
)
3697 if tgen
.routers_have_failure():
3698 check_router_status(tgen
)
3701 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1"
3702 " in vrf instances(RED_A and RED_B)."
3705 for addr_type
in ADDR_TYPES
:
3710 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3711 "next_hop": NEXT_HOP_IP
[addr_type
],
3715 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3716 "next_hop": NEXT_HOP_IP
[addr_type
],
3722 result
= create_static_routes(tgen
, input_dict_1
)
3723 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3728 "Advertise unique BGP prefixes(IPv4+IPv6) from BLUE_1 in"
3729 " vrf instances(BLUE_A and BLUE_B)."
3732 for addr_type
in ADDR_TYPES
:
3737 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3738 "next_hop": NEXT_HOP_IP
[addr_type
],
3742 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3743 "next_hop": NEXT_HOP_IP
[addr_type
],
3749 result
= create_static_routes(tgen
, input_dict_2
)
3750 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3754 step("Redistribute static..")
3757 for dut
in ["red1", "blue1"]:
3758 temp
= {dut
: {"bgp": []}}
3759 input_dict_3
.update(temp
)
3762 VRFS
= ["RED_A", "RED_B"]
3765 VRFS
= ["BLUE_A", "BLUE_B"]
3768 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
3769 temp
[dut
]["bgp"].append(
3775 "unicast": {"redistribute": [{"redist_type": "static"}]}
3778 "unicast": {"redistribute": [{"redist_type": "static"}]}
3784 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
3785 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3787 step("Restart frr on R1")
3788 stop_router(tgen
, "r1")
3789 start_router(tgen
, "r1")
3791 for addr_type
in ADDR_TYPES
:
3798 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3799 "next_hop": NEXT_HOP_IP
[addr_type
],
3803 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3804 "next_hop": NEXT_HOP_IP
[addr_type
],
3815 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3816 "next_hop": NEXT_HOP_IP
[addr_type
],
3820 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3821 "next_hop": NEXT_HOP_IP
[addr_type
],
3828 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
3829 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3831 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
3832 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3834 write_test_footer(tc_name
)
3837 if __name__
== "__main__":
3838 args
= ["-s"] + sys
.argv
[1:]
3839 sys
.exit(pytest
.main(args
))