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 Following tests are covered to test BGP Multi-VRF:
27 Do a shut and no shut on connecting interface of DUT,
28 to see if all vrf instances clear their respective BGP tables
29 during the interface down and restores when interface brought
31 VRF leaking - next-hop interface is flapping.
33 VRF - VLANs - Routing Table ID - combination testcase
36 Verify that all vrf instances fall back
37 to backup path, if primary link goes down.
39 Restart BGPd daemon on DUT to check if all the
40 routes in respective vrfs are reinstalled..
42 Delete a VRF instance from DUT and check if the routes get
43 deleted from subsequent neighbour routers and appears again once VRF
46 Verify that VRF names are locally significant
47 to a router, and end to end connectivity depends on unique
48 virtual circuits (using VLANs or separate physical interfaces).
50 Restart all FRR services (reboot DUT) to check if all
51 the routes in respective vrfs are reinstalled.
58 from copy
import deepcopy
59 from time
import sleep
62 # Save the Current Working Directory to find configuration files.
63 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
64 sys
.path
.append(os
.path
.join(CWD
, "../"))
65 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
67 # Required to instantiate the topology builder class.
69 # pylint: disable=C0413
70 # Import topogen and topotest helpers
71 from lib
.topogen
import Topogen
, get_topogen
72 from lib
.topotest
import iproute2_is_vrf_capable
73 from lib
.common_config
import (
80 reset_config_on_routers
,
82 shutdown_bringup_interface
,
86 create_interfaces_cfg
,
87 create_interface_in_kernel
,
88 get_frr_ipv6_linklocal
,
91 required_linux_kernel_version
,
98 from lib
.topolog
import logger
99 from lib
.bgp
import clear_bgp
, verify_bgp_rib
, create_router_bgp
, verify_bgp_convergence
100 from lib
.topojson
import build_config_from_json
103 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
107 NETWORK1_1
= {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
108 NETWORK1_2
= {"ipv4": "1.1.1.2/32", "ipv6": "1::2/128"}
109 NETWORK2_1
= {"ipv4": "2.1.1.1/32", "ipv6": "2::1/128"}
110 NETWORK2_2
= {"ipv4": "2.1.1.2/32", "ipv6": "2::2/128"}
111 NETWORK3_1
= {"ipv4": "3.1.1.1/32", "ipv6": "3::1/128"}
112 NETWORK3_2
= {"ipv4": "3.1.1.2/32", "ipv6": "3::2/128"}
113 NETWORK4_1
= {"ipv4": "4.1.1.1/32", "ipv6": "4::1/128"}
114 NETWORK4_2
= {"ipv4": "4.1.1.2/32", "ipv6": "4::2/128"}
115 NETWORK9_1
= {"ipv4": "100.1.0.1/30", "ipv6": "100::1/126"}
116 NETWORK9_2
= {"ipv4": "100.1.0.2/30", "ipv6": "100::2/126"}
118 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
121 "ipv4": "20.20.20.20/32",
122 "ipv6": "20::20:20/128",
128 PREFERRED_NEXT_HOP
= "link_local"
131 def setup_module(mod
):
133 Sets up the pytest environment
137 # Required linux kernel version for this suite to run.
138 result
= required_linux_kernel_version("4.14")
139 if result
is not True:
140 pytest
.skip("Kernel requirements are not met")
142 # iproute2 needs to support VRFs for this suite to run.
143 if not iproute2_is_vrf_capable():
144 pytest
.skip("Installed iproute2 version does not support VRFs")
146 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
147 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
148 logger
.info("=" * 40)
150 logger
.info("Running setup_module to create topology")
152 # This function initiates the topology build with Topogen...
153 json_file
= "{}/bgp_multi_vrf_topo2.json".format(CWD
)
154 tgen
= Topogen(json_file
, mod
.__name
__)
156 topo
= tgen
.json_topo
157 # ... and here it calls Mininet initialization functions.
159 # Starting topology, create tmp files which are loaded to routers
160 # to start daemons and then start routers
163 # Creating configuration from JSON
164 build_config_from_json(tgen
, topo
)
166 global BGP_CONVERGENCE
168 ADDR_TYPES
= check_address_types()
170 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
171 assert BGP_CONVERGENCE
is True, "setup_module : Failed \n Error: {}".format(
175 logger
.info("Running setup_module() done")
178 def teardown_module():
179 """Teardown the pytest environment"""
181 logger
.info("Running teardown_module to delete topology")
185 # Stop toplogy and Remove tmp files
189 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
191 logger
.info("=" * 40)
194 #####################################################
198 #####################################################
201 def test_vrf_with_multiple_links_p1(request
):
204 Verify that all vrf instances fall back
205 to backup path, if primary link goes down.
209 tc_name
= request
.node
.name
210 write_test_header(tc_name
)
212 if tgen
.routers_have_failure():
213 check_router_status(tgen
)
216 "Configure BGP neighborships(IPv4+IPv6) between R1 and R4 "
217 "using exact same link IPs for all 4 VRFs."
220 topo_modify
= deepcopy(topo
)
221 build_config_from_json(tgen
, topo_modify
)
223 interfaces
= ["link1", "link2", "link3", "link4"]
224 for interface
in interfaces
:
225 topo_modify
["routers"]["r1"]["links"]["r4-{}".format(interface
)][
228 topo_modify
["routers"]["r4"]["links"]["r1-{}".format(interface
)][
232 step("Build interface config from json")
233 create_interfaces_cfg(tgen
, topo_modify
["routers"])
235 interfaces
= ["link1", "link2", "link3", "link4"]
236 for interface
in interfaces
:
237 del topo_modify
["routers"]["r1"]["links"]["r4-{}".format(interface
)]["delete"]
238 del topo_modify
["routers"]["r4"]["links"]["r1-{}".format(interface
)]["delete"]
242 for addr_type
in ADDR_TYPES
:
243 interfaces
= ["link1", "link2", "link3", "link4"]
244 for interface
in interfaces
:
245 intf_name_r1
= topo_modify
["routers"]["r1"]["links"][
246 "r4-{}".format(interface
)
248 topo_modify
["routers"]["r1"]["links"]["r4-{}".format(interface
)][
250 ] = NETWORK9_1
[addr_type
]
252 intf_name_r4
= topo_modify
["routers"]["r4"]["links"][
253 "r1-{}".format(interface
)
255 topo_modify
["routers"]["r4"]["links"]["r1-{}".format(interface
)][
257 ] = NETWORK9_2
[addr_type
]
259 r1_config
.append("interface {}".format(intf_name_r1
))
260 r4_config
.append("interface {}".format(intf_name_r4
))
261 if addr_type
== "ipv4":
262 r1_config
.append("no ip address {}".format(NETWORK9_1
[addr_type
]))
263 r4_config
.append("no ip address {}".format(NETWORK9_2
[addr_type
]))
265 r1_config
.append("no ipv6 address {}".format(NETWORK9_1
[addr_type
]))
266 r4_config
.append("no ipv6 address {}".format(NETWORK9_2
[addr_type
]))
268 step("Build interface config from json")
269 create_interfaces_cfg(tgen
, topo_modify
["routers"])
271 step("Create bgp config")
272 result
= create_router_bgp(tgen
, topo_modify
["routers"])
273 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
275 step("Verify BGP convergence")
277 result
= verify_bgp_convergence(tgen
, topo_modify
)
278 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
281 "Advertise below prefixes in BGP using static redistribution"
282 " for both vrfs (RED_A and BLUE_A) on router R2.."
285 for addr_type
in ADDR_TYPES
:
290 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
291 "next_hop": NEXT_HOP_IP
[addr_type
],
295 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
296 "next_hop": NEXT_HOP_IP
[addr_type
],
300 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
301 "next_hop": NEXT_HOP_IP
[addr_type
],
305 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
306 "next_hop": NEXT_HOP_IP
[addr_type
],
312 result
= create_static_routes(tgen
, input_dict_1
)
313 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
317 step("Redistribute static..")
321 temp
= {dut
: {"bgp": []}}
322 input_dict_3
.update(temp
)
324 VRFS
= ["RED_A", "RED_B", "BLUE_A", "BLUE_B"]
325 AS_NUM
= [100, 100, 100, 100]
327 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
328 temp
[dut
]["bgp"].append(
334 "unicast": {"redistribute": [{"redist_type": "static"}]}
337 "unicast": {"redistribute": [{"redist_type": "static"}]}
343 result
= create_router_bgp(tgen
, topo_modify
, input_dict_3
)
344 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
346 step("Verify routes are installed with same nexthop in different" " VRFs")
347 result
= verify_bgp_convergence(tgen
, topo_modify
)
348 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
350 for addr_type
in ADDR_TYPES
:
356 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
357 "next_hop": NEXT_HOP_IP
[addr_type
],
364 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
368 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
369 assert result
is True, "Testcase {} : Failed \n Error {}".format(
377 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
378 "next_hop": NEXT_HOP_IP
[addr_type
],
385 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
389 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
390 assert result
is True, "Testcase {} : Failed \n Error {}".format(
398 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
399 "next_hop": NEXT_HOP_IP
[addr_type
],
406 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
410 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
411 assert result
is True, "Testcase {} : Failed \n Error {}".format(
419 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
420 "next_hop": NEXT_HOP_IP
[addr_type
],
427 R1_NEXTHOP
= topo_modify
["routers"]["r1"]["links"]["r4-link1"][addr_type
].split(
431 result
= verify_rib(tgen
, addr_type
, dut
, _input_dict
, next_hop
=R1_NEXTHOP
)
432 assert result
is True, "Testcase {} : Failed \n Error {}".format(
437 "Configure a route-map on R3 to prepend as-path and apply"
438 " for neighbour router R2 in both vrfs, in inbound direction."
447 "set": {"path": {"as_num": 123, "as_action": "prepend"}},
453 result
= create_route_maps(tgen
, input_dict_4
)
454 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
456 step("Apply route-map to neighbours")
458 "Configure ECMP on router R3 using 'max-path' command for both"
459 " VRFs RED_A and BLUE_A."
476 {"name": "ASP", "direction": "in"}
491 {"name": "ASP", "direction": "in"}
501 "name": "rmap_global",
524 {"name": "ASP", "direction": "in"}
539 {"name": "ASP", "direction": "in"}
560 {"name": "ASP", "direction": "in"}
575 {"name": "ASP", "direction": "in"}
585 "name": "rmap_global",
608 {"name": "ASP", "direction": "in"}
623 {"name": "ASP", "direction": "in"}
637 result
= create_router_bgp(tgen
, topo_modify
, input_dict_5
)
638 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
640 result
= verify_bgp_convergence(tgen
, topo_modify
)
641 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
643 for addr_type
in ADDR_TYPES
:
650 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
657 intf
= topo_modify
["routers"][peer
]["links"]["r3-link1"]["interface"]
658 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
659 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="RED_A")
661 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link1"][
665 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
666 assert result
is True, "Testcase {} : Failed \n Error {}".format(
674 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
681 intf
= topo
["routers"][peer
]["links"]["r3-link3"]["interface"]
682 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
683 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="BLUE_A")
685 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link3"][
689 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
690 assert result
is True, "Testcase {} : Failed \n Error {}".format(
695 "Configure ECMP on router R3 using max-path command for"
696 " both VRFs RED_A and BLUE_A."
746 result
= create_router_bgp(tgen
, topo_modify
, input_dict_7
)
747 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
749 step("R3 should install prefixes from both next-hops (R2 and R4)")
750 result
= verify_bgp_convergence(tgen
, topo_modify
)
751 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
753 for addr_type
in ADDR_TYPES
:
760 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
767 intf
= topo_modify
["routers"][peer
]["links"]["r3-link1"]["interface"]
768 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
769 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="RED_A")
771 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link1"][
775 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
776 assert result
is True, "Testcase {} : Failed \n Error {}".format(
784 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
791 intf
= topo_modify
["routers"][peer
]["links"]["r3-link3"]["interface"]
792 if addr_type
== "ipv6" and "link_local" in PREFERRED_NEXT_HOP
:
793 R2_NEXTHOP
= get_frr_ipv6_linklocal(tgen
, peer
, intf
=intf
, vrf
="BLUE_A")
795 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link3"][
799 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
800 assert result
is True, "Testcase {} : Failed \n Error {}".format(
804 step("Shutdown interface between R2 and R3 for vrfs RED_A and " "BLUE_A.")
806 intf1
= topo_modify
["routers"]["r2"]["links"]["r3-link1"]["interface"]
807 intf2
= topo_modify
["routers"]["r2"]["links"]["r3-link3"]["interface"]
809 interfaces
= [intf1
, intf2
]
810 for intf
in interfaces
:
811 shutdown_bringup_interface(tgen
, "r2", intf
, False)
813 for addr_type
in ADDR_TYPES
:
820 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
827 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link1"][addr_type
].split(
831 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
832 assert result
is True, "Testcase {} : Failed \n Error {}".format(
840 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
847 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link3"][addr_type
].split(
851 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
852 assert result
is True, "Testcase {} : Failed \n Error {}".format(
856 step("Unshut the interfaces between R2 and R3 for vrfs RED_A and BLUE_A.")
858 for intf
in interfaces
:
859 shutdown_bringup_interface(tgen
, "r2", intf
, True)
861 for addr_type
in ADDR_TYPES
:
868 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
875 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link1"][addr_type
].split(
879 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
880 assert result
is True, "Testcase {} : Failed \n Error {}".format(
888 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
895 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link3"][addr_type
].split(
899 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
900 assert result
is True, "Testcase {} : Failed \n Error {}".format(
904 step("Remove route-map from R3 for vrfs RED_A and BLUE_A.")
945 "name": "rmap_global",
993 "name": "rmap_global",
1009 result
= create_router_bgp(tgen
, topo_modify
, input_dict_6
)
1010 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1012 result
= verify_bgp_convergence(tgen
, topo_modify
)
1013 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1015 for addr_type
in ADDR_TYPES
:
1021 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1028 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link1"][addr_type
].split(
1032 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
1033 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1041 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1048 R2_NEXTHOP
= topo_modify
["routers"]["r2"]["links"]["r3-link3"][addr_type
].split(
1052 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R2_NEXTHOP
)
1053 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1057 step("Shutdown links between between R2 and R3 for vrfs RED_A and" " BLUE_A.")
1059 for intf
in interfaces
:
1060 shutdown_bringup_interface(tgen
, "r2", intf
, False)
1062 for addr_type
in ADDR_TYPES
:
1068 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1075 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link1"][addr_type
].split(
1079 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
1080 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1088 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1095 R4_NEXTHOP
= topo_modify
["routers"]["r4"]["links"]["r3-link3"][addr_type
].split(
1099 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
, next_hop
=R4_NEXTHOP
)
1100 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1104 step("Bringup links between between R2 and R3 for vrfs RED_A and" " BLUE_A.")
1106 for intf
in interfaces
:
1107 shutdown_bringup_interface(tgen
, "r2", intf
, True)
1109 step("Deleting manualy assigned ip address from router r1 and r4 interfaces")
1110 raw_config
= {"r1": {"raw_config": r1_config
}, "r4": {"raw_config": r4_config
}}
1111 result
= apply_raw_config(tgen
, raw_config
)
1112 assert result
is True, "Testcase {} : Failed Error: {}".format(tc_name
, result
)
1114 write_test_footer(tc_name
)
1117 def test_shut_noshut_p1(request
):
1120 Do a shut and no shut on connecting interface of DUT,
1121 to see if all vrf instances clear their respective BGP tables
1122 during the interface down and restores when interface brought
1126 tgen
= get_topogen()
1127 tc_name
= request
.node
.name
1128 write_test_header(tc_name
)
1129 reset_config_on_routers(tgen
)
1131 if tgen
.routers_have_failure():
1132 check_router_status(tgen
)
1134 step("Build interface config from json")
1135 create_interfaces_cfg(tgen
, topo
["routers"])
1137 if tgen
.routers_have_failure():
1138 pytest
.skip(tgen
.errors
)
1141 "Advertise unique prefixes in BGP using static redistribution"
1142 " for both vrfs (RED_A and RED_B) on router RED_1."
1145 for addr_type
in ADDR_TYPES
:
1150 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1151 "next_hop": NEXT_HOP_IP
[addr_type
],
1155 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1156 "next_hop": NEXT_HOP_IP
[addr_type
],
1162 result
= create_static_routes(tgen
, input_dict_1
)
1163 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1168 "Advertise unique prefixes in BGP using static redistribution"
1169 " for both vrfs (BLUE_A and BLUE_B) on router BLUE_1."
1172 for addr_type
in ADDR_TYPES
:
1177 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1178 "next_hop": NEXT_HOP_IP
[addr_type
],
1182 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1183 "next_hop": NEXT_HOP_IP
[addr_type
],
1189 result
= create_static_routes(tgen
, input_dict_2
)
1190 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1194 step("Redistribute static..")
1197 for dut
in ["red1", "blue1"]:
1198 temp
= {dut
: {"bgp": []}}
1199 input_dict_3
.update(temp
)
1202 VRFS
= ["RED_A", "RED_B"]
1205 VRFS
= ["BLUE_A", "BLUE_B"]
1208 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
1209 temp
[dut
]["bgp"].append(
1215 "unicast": {"redistribute": [{"redist_type": "static"}]}
1218 "unicast": {"redistribute": [{"redist_type": "static"}]}
1224 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1225 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1227 step("Api call to modify BGP timers")
1242 "keepalivetimer": KEEPALIVETIMER
,
1243 "holddowntimer": HOLDDOWNTIMER
,
1256 "keepalivetimer": KEEPALIVETIMER
,
1257 "holddowntimer": HOLDDOWNTIMER
,
1276 "keepalivetimer": KEEPALIVETIMER
,
1277 "holddowntimer": HOLDDOWNTIMER
,
1290 "keepalivetimer": KEEPALIVETIMER
,
1291 "holddowntimer": HOLDDOWNTIMER
,
1310 "keepalivetimer": KEEPALIVETIMER
,
1311 "holddowntimer": HOLDDOWNTIMER
,
1324 "keepalivetimer": KEEPALIVETIMER
,
1325 "holddowntimer": HOLDDOWNTIMER
,
1344 "keepalivetimer": KEEPALIVETIMER
,
1345 "holddowntimer": HOLDDOWNTIMER
,
1358 "keepalivetimer": KEEPALIVETIMER
,
1359 "holddowntimer": HOLDDOWNTIMER
,
1382 "keepalivetimer": KEEPALIVETIMER
,
1383 "holddowntimer": HOLDDOWNTIMER
,
1396 "keepalivetimer": KEEPALIVETIMER
,
1397 "holddowntimer": HOLDDOWNTIMER
,
1416 "keepalivetimer": KEEPALIVETIMER
,
1417 "holddowntimer": HOLDDOWNTIMER
,
1430 "keepalivetimer": KEEPALIVETIMER
,
1431 "holddowntimer": HOLDDOWNTIMER
,
1450 "keepalivetimer": KEEPALIVETIMER
,
1451 "holddowntimer": HOLDDOWNTIMER
,
1464 "keepalivetimer": KEEPALIVETIMER
,
1465 "holddowntimer": HOLDDOWNTIMER
,
1484 "keepalivetimer": KEEPALIVETIMER
,
1485 "holddowntimer": HOLDDOWNTIMER
,
1498 "keepalivetimer": KEEPALIVETIMER
,
1499 "holddowntimer": HOLDDOWNTIMER
,
1512 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1513 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1515 for addr_type
in ADDR_TYPES
:
1516 clear_bgp(tgen
, addr_type
, "r1", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
1518 clear_bgp(tgen
, addr_type
, "r2", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
1520 step("Shut down connecting interface between R1<<>>R2 on R1.")
1521 step("Repeat step-3 and step-4 10 times.")
1523 for count
in range(1, 2):
1524 step("Iteration {}".format(count
))
1525 step("Shut down connecting interface between R1<<>>R2 on R1.")
1527 intf1
= topo
["routers"]["r1"]["links"]["r2-link1"]["interface"]
1528 intf2
= topo
["routers"]["r1"]["links"]["r2-link2"]["interface"]
1529 intf3
= topo
["routers"]["r1"]["links"]["r2-link3"]["interface"]
1530 intf4
= topo
["routers"]["r1"]["links"]["r2-link4"]["interface"]
1532 interfaces
= [intf1
, intf2
, intf3
, intf4
]
1533 for intf
in interfaces
:
1534 shutdown_bringup_interface(tgen
, "r1", intf
, False)
1537 "On R2, all BGP peering in respective vrf instances go down"
1538 " when the interface is shut"
1541 step("Sleeping for {}+1 sec..".format(HOLDDOWNTIMER
))
1542 sleep(HOLDDOWNTIMER
+ 1)
1544 result
= verify_bgp_convergence(tgen
, topo
, expected
=False)
1547 ), "Testcase {} : Failed \nExpected Behaviour: BGP will not be converged \nError {}".format(
1551 for addr_type
in ADDR_TYPES
:
1557 "network": [NETWORK1_1
[addr_type
]]
1558 + [NETWORK1_2
[addr_type
]],
1559 "next_hop": NEXT_HOP_IP
[addr_type
],
1563 "network": [NETWORK2_1
[addr_type
]]
1564 + [NETWORK2_2
[addr_type
]],
1565 "next_hop": NEXT_HOP_IP
[addr_type
],
1576 "network": [NETWORK1_1
[addr_type
]]
1577 + [NETWORK1_2
[addr_type
]],
1578 "next_hop": NEXT_HOP_IP
[addr_type
],
1582 "network": [NETWORK2_1
[addr_type
]]
1583 + [NETWORK2_2
[addr_type
]],
1584 "next_hop": NEXT_HOP_IP
[addr_type
],
1591 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
1594 ), "Testcase {} : Failed \nExpected Behaviour: Routes are flushed out \nError {}".format(
1598 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
1601 ), "Testcase {} : Failed \nExpected Behaviour: Routes are flushed out \nError {}".format(
1605 step("Bring up connecting interface between R1<<>>R2 on R1.")
1606 for intf
in interfaces
:
1607 shutdown_bringup_interface(tgen
, "r1", intf
, True)
1610 "R2 restores BGP peering and routing tables in all vrf "
1611 "instances when interface brought back up again"
1614 result
= verify_bgp_convergence(tgen
, topo
)
1615 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1619 for addr_type
in ADDR_TYPES
:
1625 "network": [NETWORK1_1
[addr_type
]]
1626 + [NETWORK1_2
[addr_type
]],
1627 "next_hop": NEXT_HOP_IP
[addr_type
],
1631 "network": [NETWORK2_1
[addr_type
]]
1632 + [NETWORK2_2
[addr_type
]],
1633 "next_hop": NEXT_HOP_IP
[addr_type
],
1644 "network": [NETWORK1_1
[addr_type
]]
1645 + [NETWORK1_2
[addr_type
]],
1646 "next_hop": NEXT_HOP_IP
[addr_type
],
1650 "network": [NETWORK2_1
[addr_type
]]
1651 + [NETWORK2_2
[addr_type
]],
1652 "next_hop": NEXT_HOP_IP
[addr_type
],
1659 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
1660 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1664 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
1665 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1669 write_test_footer(tc_name
)
1672 def test_vrf_vlan_routing_table_p1(request
):
1675 VRF - VLANs - Routing Table ID - combination testcase
1679 tgen
= get_topogen()
1680 tc_name
= request
.node
.name
1681 write_test_header(tc_name
)
1682 reset_config_on_routers(tgen
)
1684 if tgen
.routers_have_failure():
1685 check_router_status(tgen
)
1688 "Advertise unique prefixes(IPv4+IPv6) in BGP using"
1689 " network command for vrf RED_A on router R2"
1692 for addr_type
in ADDR_TYPES
:
1697 "network": NETWORK1_1
[addr_type
],
1698 "next_hop": NEXT_HOP_IP
[addr_type
],
1704 result
= create_static_routes(tgen
, input_dict_1
)
1705 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1709 step("Redistribute static..")
1719 "unicast": {"redistribute": [{"redist_type": "static"}]}
1722 "unicast": {"redistribute": [{"redist_type": "static"}]}
1730 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1731 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1734 "Verify that static routes(IPv4+IPv6) is overridden and doesn't"
1735 " have duplicate entries within VRF RED_A on router RED-1"
1738 result
= verify_bgp_convergence(tgen
, topo
)
1739 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1741 for addr_type
in ADDR_TYPES
:
1747 "network": NETWORK1_1
[addr_type
],
1748 "next_hop": NEXT_HOP_IP
[addr_type
],
1755 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
1756 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1760 step("Api call to modify BGP timers")
1775 "keepalivetimer": KEEPALIVETIMER
,
1776 "holddowntimer": HOLDDOWNTIMER
,
1789 "keepalivetimer": KEEPALIVETIMER
,
1790 "holddowntimer": HOLDDOWNTIMER
,
1803 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1804 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1806 for addr_type
in ADDR_TYPES
:
1807 clear_bgp(tgen
, addr_type
, "r3", vrf
=["RED_A"])
1809 step("Repeat for 5 times.")
1811 for count
in range(1, 2):
1812 step("Iteration {}..".format(count
))
1813 step("Delete a specific VRF instance(RED_A) from router R3")
1815 input_dict
= {"r3": {"vrfs": [{"name": "RED_A", "id": "1", "delete": True}]}}
1817 result
= create_vrf_cfg(tgen
, input_dict
)
1818 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1822 step("Sleeping for {}+1 sec..".format(HOLDDOWNTIMER
))
1823 sleep(HOLDDOWNTIMER
+ 1)
1825 for addr_type
in ADDR_TYPES
:
1831 "network": NETWORK1_1
[addr_type
],
1832 "next_hop": NEXT_HOP_IP
[addr_type
],
1839 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
1842 ), "Testcase {} : Failed \n Expected Behaviour: Routes are cleaned \n Error {}".format(
1846 step("Add/reconfigure the same VRF instance again")
1848 result
= create_vrf_cfg(tgen
, {"r3": topo
["routers"]["r3"]})
1849 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1854 "After deleting VRFs ipv6 addresses will be deleted from kernel "
1855 " Adding back ipv6 addresses"
1861 for c_link
, c_data
in topo
["routers"][dut
]["links"].items():
1862 if c_data
["vrf"] != vrf
:
1865 intf_name
= c_data
["interface"]
1866 intf_ipv6
= c_data
["ipv6"]
1868 create_interface_in_kernel(
1869 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
1872 step("Sleeping for {}+1 sec..".format(HOLDDOWNTIMER
))
1873 sleep(HOLDDOWNTIMER
+ 1)
1875 for addr_type
in ADDR_TYPES
:
1881 "network": NETWORK1_1
[addr_type
],
1882 "next_hop": NEXT_HOP_IP
[addr_type
],
1889 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
1890 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1894 write_test_footer(tc_name
)
1897 def test_vrf_route_leaking_next_hop_interface_flapping_p1(request
):
1900 VRF leaking - next-hop interface is flapping.
1903 tgen
= get_topogen()
1904 tc_name
= request
.node
.name
1905 write_test_header(tc_name
)
1906 reset_config_on_routers(tgen
)
1908 if tgen
.routers_have_failure():
1909 check_router_status(tgen
)
1911 step("Create loopback interface")
1913 for addr_type
in ADDR_TYPES
:
1914 create_interface_in_kernel(
1918 LOOPBACK_2
[addr_type
],
1922 intf_red1_r11
= topo
["routers"]["red1"]["links"]["r1-link2"]["interface"]
1923 for addr_type
in ADDR_TYPES
:
1928 "network": LOOPBACK_2
[addr_type
],
1929 "interface": intf_red1_r11
,
1930 "nexthop_vrf": "RED_B",
1936 result
= create_static_routes(tgen
, input_dict_1
)
1937 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1941 step("Redistribute static..")
1951 "unicast": {"redistribute": [{"redist_type": "static"}]}
1954 "unicast": {"redistribute": [{"redist_type": "static"}]}
1962 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1963 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1965 result
= verify_bgp_convergence(tgen
, topo
)
1966 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1968 step("VRF RED_A should install a route for vrf RED_B's " "loopback ip.")
1969 for addr_type
in ADDR_TYPES
:
1975 "network": LOOPBACK_2
[addr_type
],
1976 "interface": intf_red1_r11
,
1977 "nexthop_vrf": "RED_B",
1984 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, protocol
="static")
1985 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1989 step("Repeat step-2 to 4 at least 5 times")
1991 for count
in range(1, 2):
1992 intf1
= topo
["routers"]["red1"]["links"]["r1-link2"]["interface"]
1995 "Iteration {}: Shutdown interface {} on router"
1996 "RED_1.".format(count
, intf1
)
1998 shutdown_bringup_interface(tgen
, "red1", intf1
, False)
2000 step("Verify that RED_A removes static route from routing " "table.")
2002 for addr_type
in ADDR_TYPES
:
2008 "network": LOOPBACK_2
[addr_type
],
2009 "interface": intf_red1_r11
,
2010 "nexthop_vrf": "RED_B",
2017 result
= verify_rib(
2018 tgen
, addr_type
, dut
, input_dict_1
, protocol
="static", expected
=False
2020 assert result
is not True, (
2021 "Testcase {} : Failed \n Expected Behaviour: Routes are"
2022 " not present Error {}".format(tc_name
, result
)
2025 step("Bring up interface {} on router RED_1 again.".format(intf1
))
2026 shutdown_bringup_interface(tgen
, "red1", intf1
, True)
2029 "Verify that RED_A reinstalls static route pointing to "
2030 "RED_B's IP in routing table again"
2033 for addr_type
in ADDR_TYPES
:
2039 "network": LOOPBACK_2
[addr_type
],
2040 "interface": intf_red1_r11
,
2041 "nexthop_vrf": "RED_B",
2048 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, protocol
="static")
2049 assert result
is True, "Testcase {} : Failed \n Error {}".format(
2053 write_test_footer(tc_name
)
2056 def test_restart_bgpd_daemon_p1(request
):
2059 Restart BGPd daemon on DUT to check if all the
2060 routes in respective vrfs are reinstalled..
2063 tgen
= get_topogen()
2064 tc_name
= request
.node
.name
2065 write_test_header(tc_name
)
2067 if tgen
.routers_have_failure():
2068 check_router_status(tgen
)
2070 reset_config_on_routers(tgen
)
2073 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1"
2074 " in vrf instances(RED_A and RED_B)."
2077 for addr_type
in ADDR_TYPES
:
2082 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2083 "next_hop": NEXT_HOP_IP
[addr_type
],
2087 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2088 "next_hop": NEXT_HOP_IP
[addr_type
],
2094 result
= create_static_routes(tgen
, input_dict_1
)
2095 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2100 "Advertise unique BGP prefixes(IPv4+IPv6) from BLUE_1 in"
2101 " vrf instances(BLUE_A and BLUE_B)."
2104 for addr_type
in ADDR_TYPES
:
2109 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2110 "next_hop": NEXT_HOP_IP
[addr_type
],
2114 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2115 "next_hop": NEXT_HOP_IP
[addr_type
],
2121 result
= create_static_routes(tgen
, input_dict_2
)
2122 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2126 step("Redistribute static..")
2129 for dut
in ["red1", "blue1"]:
2130 temp
= {dut
: {"bgp": []}}
2131 input_dict_3
.update(temp
)
2134 VRFS
= ["RED_A", "RED_B"]
2137 VRFS
= ["BLUE_A", "BLUE_B"]
2140 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2141 temp
[dut
]["bgp"].append(
2147 "unicast": {"redistribute": [{"redist_type": "static"}]}
2150 "unicast": {"redistribute": [{"redist_type": "static"}]}
2156 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2157 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2159 result
= verify_bgp_convergence(tgen
, topo
)
2160 assert result
is True, "Testcase {} :Failed\n Error {}".format(tc_name
, result
)
2162 step("Kill BGPd daemon on R1.")
2163 kill_router_daemons(tgen
, "r1", ["bgpd"])
2165 for addr_type
in ADDR_TYPES
:
2171 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2172 "next_hop": NEXT_HOP_IP
[addr_type
],
2176 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2177 "next_hop": NEXT_HOP_IP
[addr_type
],
2188 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2189 "next_hop": NEXT_HOP_IP
[addr_type
],
2193 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2194 "next_hop": NEXT_HOP_IP
[addr_type
],
2201 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
2202 assert result
is not True, (
2203 "Testcase {} : Failed \n "
2204 "Routes are still present in VRF RED_A and RED_B \n Error: {}".format(
2209 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
2210 assert result
is not True, (
2211 "Testcase {} : Failed \n "
2212 "Routes are still present in VRF BLUE_A and BLUE_B \n Error: {}".format(
2217 step("Bring up BGPd daemon on R1.")
2218 start_router_daemons(tgen
, "r1", ["bgpd"])
2220 result
= verify_bgp_convergence(tgen
, topo
)
2221 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2223 for addr_type
in ADDR_TYPES
:
2229 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2230 "next_hop": NEXT_HOP_IP
[addr_type
],
2234 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2235 "next_hop": NEXT_HOP_IP
[addr_type
],
2246 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2247 "next_hop": NEXT_HOP_IP
[addr_type
],
2251 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2252 "next_hop": NEXT_HOP_IP
[addr_type
],
2259 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
2260 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2262 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2263 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2265 write_test_footer(tc_name
)
2268 def test_delete_and_re_add_vrf_p1(request
):
2271 Delete a VRF instance from DUT and check if the routes get
2272 deleted from subsequent neighbour routers and appears again once VRF
2276 tgen
= get_topogen()
2277 tc_name
= request
.node
.name
2278 write_test_header(tc_name
)
2279 reset_config_on_routers(tgen
)
2281 if tgen
.routers_have_failure():
2282 pytest
.skip(tgen
.errors
)
2285 "Advertise unique prefixes in BGP using static redistribution"
2286 "for both vrfs (RED_A and RED_B) on router RED_1"
2289 for addr_type
in ADDR_TYPES
:
2294 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2295 "next_hop": NEXT_HOP_IP
[addr_type
],
2299 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2300 "next_hop": NEXT_HOP_IP
[addr_type
],
2306 result
= create_static_routes(tgen
, input_dict_1
)
2307 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2312 "Advertise unique prefixes in BGP using static redistribution"
2313 " for both vrfs (BLUE_A and BLUE_B) on router BLUE_1."
2316 for addr_type
in ADDR_TYPES
:
2321 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2322 "next_hop": NEXT_HOP_IP
[addr_type
],
2326 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
2327 "next_hop": NEXT_HOP_IP
[addr_type
],
2333 result
= create_static_routes(tgen
, input_dict_2
)
2334 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2338 step("Redistribute static for vrfs RED_A and RED_B and BLUE_A and BLUE_B")
2341 for dut
in ["red1", "blue1"]:
2342 temp
= {dut
: {"bgp": []}}
2343 input_dict_3
.update(temp
)
2346 VRFS
= ["RED_A", "RED_B"]
2349 VRFS
= ["BLUE_A", "BLUE_B"]
2352 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2353 temp
[dut
]["bgp"].append(
2359 "unicast": {"redistribute": [{"redist_type": "static"}]}
2362 "unicast": {"redistribute": [{"redist_type": "static"}]}
2368 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2369 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2371 step("Verifying RIB and FIB before deleting VRFs")
2372 result
= verify_bgp_convergence(tgen
, topo
)
2373 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
2375 for addr_type
in ADDR_TYPES
:
2381 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2382 "next_hop": NEXT_HOP_IP
[addr_type
],
2386 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2387 "next_hop": NEXT_HOP_IP
[addr_type
],
2394 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
2395 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2397 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
2398 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2400 for addr_type
in ADDR_TYPES
:
2406 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2407 "next_hop": NEXT_HOP_IP
[addr_type
],
2411 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
2412 "next_hop": NEXT_HOP_IP
[addr_type
],
2419 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2420 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2422 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2423 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2425 step("Api call to modify BGP timers")
2440 "keepalivetimer": KEEPALIVETIMER
,
2441 "holddowntimer": HOLDDOWNTIMER
,
2454 "keepalivetimer": KEEPALIVETIMER
,
2455 "holddowntimer": HOLDDOWNTIMER
,
2474 "keepalivetimer": KEEPALIVETIMER
,
2475 "holddowntimer": HOLDDOWNTIMER
,
2488 "keepalivetimer": KEEPALIVETIMER
,
2489 "holddowntimer": HOLDDOWNTIMER
,
2508 "keepalivetimer": KEEPALIVETIMER
,
2509 "holddowntimer": HOLDDOWNTIMER
,
2522 "keepalivetimer": KEEPALIVETIMER
,
2523 "holddowntimer": HOLDDOWNTIMER
,
2542 "keepalivetimer": KEEPALIVETIMER
,
2543 "holddowntimer": HOLDDOWNTIMER
,
2556 "keepalivetimer": KEEPALIVETIMER
,
2557 "holddowntimer": HOLDDOWNTIMER
,
2570 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
2571 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2573 for addr_type
in ADDR_TYPES
:
2574 clear_bgp(tgen
, addr_type
, "r1", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
2576 step("Delete vrfs RED_A and BLUE_A from R1.")
2581 {"name": "RED_A", "id": "1", "delete": True},
2582 {"name": "BLUE_A", "id": "3", "delete": True},
2587 result
= create_vrf_cfg(tgen
, input_dict
)
2588 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2591 "R2 must not receive the prefixes(in respective vrfs)"
2592 "originated from RED_1 and BLUE_1."
2595 step("Wait for {}+1 sec..".format(HOLDDOWNTIMER
))
2596 sleep(HOLDDOWNTIMER
+ 1)
2598 for addr_type
in ADDR_TYPES
:
2604 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2605 "next_hop": NEXT_HOP_IP
[addr_type
],
2613 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2614 "next_hop": NEXT_HOP_IP
[addr_type
],
2621 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
2622 assert result
is not True, (
2623 "Testcase {} :Failed \n Expected Behaviour:"
2624 " Routes are not present \n Error {}".format(tc_name
, result
)
2627 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
2628 assert result
is not True, (
2629 "Testcase {} :Failed \n Expected Behaviour:"
2630 " Routes are not present \n Error {}".format(tc_name
, result
)
2633 step("Add vrfs again RED_A and BLUE_A on R1.")
2635 result
= create_vrf_cfg(tgen
, {"r1": topo
["routers"]["r1"]})
2636 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2638 create_interfaces_cfg(tgen
, {"r1": topo
["routers"]["r1"]})
2639 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2642 "After deleting VRFs ipv6 addresses will be deleted from kernel "
2643 " Adding back ipv6 addresses"
2647 vrfs
= ["RED_A", "BLUE_A"]
2650 for c_link
, c_data
in topo
["routers"][dut
]["links"].items():
2651 if c_data
["vrf"] != vrf
:
2654 intf_name
= c_data
["interface"]
2655 intf_ipv6
= c_data
["ipv6"]
2657 create_interface_in_kernel(
2658 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
2662 "R2 should now receive the prefixes(in respective vrfs)"
2663 "again. Check the debugging logs as well. For verification"
2664 " use same commands as mention in step-3."
2667 for addr_type
in ADDR_TYPES
:
2673 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2674 "next_hop": NEXT_HOP_IP
[addr_type
],
2681 result
= verify_bgp_convergence(tgen
, topo
)
2682 assert result
is True, "Testcase {}: Failed\n Error {}".format(tc_name
, result
)
2684 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2685 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2687 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2688 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2690 for addr_type
in ADDR_TYPES
:
2696 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2697 "next_hop": NEXT_HOP_IP
[addr_type
],
2704 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2705 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2707 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2708 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2710 write_test_footer(tc_name
)
2713 def test_vrf_name_significance_p1(request
):
2716 Verify that VRF names are locally significant
2717 to a router, and end to end connectivity depends on unique
2718 virtual circuits (using VLANs or separate physical interfaces).
2721 tgen
= get_topogen()
2722 tc_name
= request
.node
.name
2723 write_test_header(tc_name
)
2724 reset_config_on_routers(tgen
)
2726 if tgen
.routers_have_failure():
2727 check_router_status(tgen
)
2730 "Advertise unique prefixes in BGP using static redistribution"
2731 "for both vrfs (RED_A and RED_B) on router RED_1"
2734 for addr_type
in ADDR_TYPES
:
2739 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2740 "next_hop": NEXT_HOP_IP
[addr_type
],
2744 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2745 "next_hop": NEXT_HOP_IP
[addr_type
],
2751 result
= create_static_routes(tgen
, input_dict_1
)
2752 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2757 "Advertise unique prefixes in BGP using static redistribution"
2758 " for both vrfs (BLUE_A and BLUE_B) on router BLUE_1."
2761 for addr_type
in ADDR_TYPES
:
2766 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
2767 "next_hop": NEXT_HOP_IP
[addr_type
],
2771 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
2772 "next_hop": NEXT_HOP_IP
[addr_type
],
2778 result
= create_static_routes(tgen
, input_dict_2
)
2779 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2783 step("Redistribute static for vrfs RED_A and RED_B and BLUE_A and BLUE_B")
2786 for dut
in ["red1", "blue1"]:
2787 temp
= {dut
: {"bgp": []}}
2788 input_dict_3
.update(temp
)
2791 VRFS
= ["RED_A", "RED_B"]
2794 VRFS
= ["BLUE_A", "BLUE_B"]
2797 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2798 temp
[dut
]["bgp"].append(
2804 "unicast": {"redistribute": [{"redist_type": "static"}]}
2807 "unicast": {"redistribute": [{"redist_type": "static"}]}
2813 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2814 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2816 step("Configure allowas-in on red2 and blue2")
2831 "allowas-in": {"number_occurences": 2}
2844 "allowas-in": {"number_occurences": 2}
2863 "allowas-in": {"number_occurences": 2}
2876 "allowas-in": {"number_occurences": 2}
2899 "allowas-in": {"number_occurences": 2}
2912 "allowas-in": {"number_occurences": 2}
2931 "allowas-in": {"number_occurences": 2}
2944 "allowas-in": {"number_occurences": 2}
2957 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
2958 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2960 step("Verifying RIB and FIB before deleting VRFs")
2962 for addr_type
in ADDR_TYPES
:
2968 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2969 "next_hop": NEXT_HOP_IP
[addr_type
],
2979 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2980 "next_hop": NEXT_HOP_IP
[addr_type
],
2987 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
2988 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2990 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
2991 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2993 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
2994 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2996 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2997 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
2999 for addr_type
in ADDR_TYPES
:
3005 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
3006 "next_hop": NEXT_HOP_IP
[addr_type
],
3017 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
3018 "next_hop": NEXT_HOP_IP
[addr_type
],
3025 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_3
)
3026 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3028 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
3029 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3031 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_3
)
3032 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3034 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_4
)
3035 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3037 step("Api call to modify BGP timers")
3052 "keepalivetimer": KEEPALIVETIMER
,
3053 "holddowntimer": HOLDDOWNTIMER
,
3066 "keepalivetimer": KEEPALIVETIMER
,
3067 "holddowntimer": HOLDDOWNTIMER
,
3086 "keepalivetimer": KEEPALIVETIMER
,
3087 "holddowntimer": HOLDDOWNTIMER
,
3100 "keepalivetimer": KEEPALIVETIMER
,
3101 "holddowntimer": HOLDDOWNTIMER
,
3120 "keepalivetimer": KEEPALIVETIMER
,
3121 "holddowntimer": HOLDDOWNTIMER
,
3134 "keepalivetimer": KEEPALIVETIMER
,
3135 "holddowntimer": HOLDDOWNTIMER
,
3154 "keepalivetimer": KEEPALIVETIMER
,
3155 "holddowntimer": HOLDDOWNTIMER
,
3168 "keepalivetimer": KEEPALIVETIMER
,
3169 "holddowntimer": HOLDDOWNTIMER
,
3192 "keepalivetimer": KEEPALIVETIMER
,
3193 "holddowntimer": HOLDDOWNTIMER
,
3206 "keepalivetimer": KEEPALIVETIMER
,
3207 "holddowntimer": HOLDDOWNTIMER
,
3226 "keepalivetimer": KEEPALIVETIMER
,
3227 "holddowntimer": HOLDDOWNTIMER
,
3240 "keepalivetimer": KEEPALIVETIMER
,
3241 "holddowntimer": HOLDDOWNTIMER
,
3264 "keepalivetimer": KEEPALIVETIMER
,
3265 "holddowntimer": HOLDDOWNTIMER
,
3278 "keepalivetimer": KEEPALIVETIMER
,
3279 "holddowntimer": HOLDDOWNTIMER
,
3298 "keepalivetimer": KEEPALIVETIMER
,
3299 "holddowntimer": HOLDDOWNTIMER
,
3312 "keepalivetimer": KEEPALIVETIMER
,
3313 "holddowntimer": HOLDDOWNTIMER
,
3326 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
3327 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3329 for addr_type
in ADDR_TYPES
:
3330 clear_bgp(tgen
, addr_type
, "r3", vrf
=["RED_A", "RED_B", "BLUE_A", "BLUE_B"])
3332 clear_bgp(tgen
, addr_type
, "red2", vrf
=["RED_A", "RED_B"])
3334 clear_bgp(tgen
, addr_type
, "blue2", vrf
=["BLUE_A", "BLUE_B"])
3336 step("Delete vrfs RED_A and BLUE_A from R3")
3341 {"name": "RED_A", "id": "1", "delete": True},
3342 {"name": "BLUE_A", "id": "3", "delete": True},
3347 result
= create_vrf_cfg(tgen
, input_dict
)
3348 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3350 step("Waiting for {}+1..".format(HOLDDOWNTIMER
))
3351 sleep(HOLDDOWNTIMER
+ 1)
3353 step("Verify RIB and FIB after deleting VRFs")
3355 for addr_type
in ADDR_TYPES
:
3361 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3362 "next_hop": NEXT_HOP_IP
[addr_type
],
3369 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
3372 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3376 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
3379 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3383 for addr_type
in ADDR_TYPES
:
3389 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
3390 "next_hop": NEXT_HOP_IP
[addr_type
],
3397 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
3400 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3404 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
3407 ), "Testcase {} :Failed \n Expected Behaviour: Routes are not present \n Error {}".format(
3411 step("Create 2 new VRFs PINK_A and GREY_A IN R3")
3413 topo_modify
= deepcopy(topo
)
3414 topo_modify
["routers"]["r3"]["vrfs"][0]["name"] = "PINK_A"
3415 topo_modify
["routers"]["r3"]["vrfs"][0]["id"] = "1"
3416 topo_modify
["routers"]["r3"]["vrfs"][2]["name"] = "GREY_A"
3417 topo_modify
["routers"]["r3"]["vrfs"][2]["id"] = "3"
3419 topo_modify
["routers"]["r3"]["links"]["red2-link1"]["vrf"] = "PINK_A"
3420 topo_modify
["routers"]["r3"]["links"]["blue2-link1"]["vrf"] = "GREY_A"
3422 topo_modify
["routers"]["r3"]["links"]["r2-link1"]["vrf"] = "PINK_A"
3423 topo_modify
["routers"]["r3"]["links"]["r2-link3"]["vrf"] = "GREY_A"
3425 topo_modify
["routers"]["r3"]["links"]["r4-link1"]["vrf"] = "PINK_A"
3426 topo_modify
["routers"]["r3"]["links"]["r4-link3"]["vrf"] = "GREY_A"
3428 topo_modify
["routers"]["r3"]["bgp"][0]["vrf"] = "PINK_A"
3429 topo_modify
["routers"]["r3"]["bgp"][2]["vrf"] = "GREY_A"
3431 result
= create_vrf_cfg(tgen
, {"r3": topo_modify
["routers"]["r3"]})
3432 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3434 create_interfaces_cfg(tgen
, {"r3": topo_modify
["routers"]["r3"]})
3435 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3437 result
= create_router_bgp(tgen
, topo_modify
["routers"])
3438 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3440 step("Api call to modify BGP timers")
3455 "keepalivetimer": KEEPALIVETIMER
,
3456 "holddowntimer": HOLDDOWNTIMER
,
3469 "keepalivetimer": KEEPALIVETIMER
,
3470 "holddowntimer": HOLDDOWNTIMER
,
3489 "keepalivetimer": KEEPALIVETIMER
,
3490 "holddowntimer": HOLDDOWNTIMER
,
3503 "keepalivetimer": KEEPALIVETIMER
,
3504 "holddowntimer": HOLDDOWNTIMER
,
3523 "keepalivetimer": KEEPALIVETIMER
,
3524 "holddowntimer": HOLDDOWNTIMER
,
3537 "keepalivetimer": KEEPALIVETIMER
,
3538 "holddowntimer": HOLDDOWNTIMER
,
3557 "keepalivetimer": KEEPALIVETIMER
,
3558 "holddowntimer": HOLDDOWNTIMER
,
3571 "keepalivetimer": KEEPALIVETIMER
,
3572 "holddowntimer": HOLDDOWNTIMER
,
3585 result
= create_router_bgp(tgen
, topo_modify
, input_dict_4
)
3586 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3588 for addr_type
in ADDR_TYPES
:
3589 clear_bgp(tgen
, addr_type
, "r3", vrf
=["PINK_A", "RED_B", "GREY_A", "BLUE_B"])
3592 "After deleting VRFs ipv6 addresses will be deleted from kernel "
3593 " Adding back ipv6 addresses"
3597 vrfs
= ["GREY_A", "PINK_A"]
3600 for c_link
, c_data
in topo_modify
["routers"][dut
]["links"].items():
3601 if c_data
["vrf"] != vrf
:
3604 intf_name
= c_data
["interface"]
3605 intf_ipv6
= c_data
["ipv6"]
3607 create_interface_in_kernel(
3608 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
3611 step("Waiting for {}+1 sec..".format(HOLDDOWNTIMER
))
3612 sleep(HOLDDOWNTIMER
+ 1)
3615 "Advertised prefixes should appear again in respective VRF"
3616 " table on routers RED_2 and BLUE_2. Verify fib and rib entries"
3619 for addr_type
in ADDR_TYPES
:
3625 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3626 "next_hop": NEXT_HOP_IP
[addr_type
],
3637 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3638 "next_hop": NEXT_HOP_IP
[addr_type
],
3645 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_1
)
3646 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3648 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_2
)
3649 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3651 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
3652 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3654 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
3655 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3657 for addr_type
in ADDR_TYPES
:
3663 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
3664 "next_hop": NEXT_HOP_IP
[addr_type
],
3675 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
3676 "next_hop": NEXT_HOP_IP
[addr_type
],
3683 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_3
)
3684 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3686 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_4
)
3687 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3689 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_3
)
3690 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3692 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_4
)
3693 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3695 write_test_footer(tc_name
)
3698 def test_restart_frr_services_p1(request
):
3701 Restart all FRR services (reboot DUT) to check if all
3702 the routes in respective vrfs are reinstalled.
3705 tgen
= get_topogen()
3706 tc_name
= request
.node
.name
3707 write_test_header(tc_name
)
3708 reset_config_on_routers(tgen
)
3710 if tgen
.routers_have_failure():
3711 check_router_status(tgen
)
3714 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1"
3715 " in vrf instances(RED_A and RED_B)."
3718 for addr_type
in ADDR_TYPES
:
3723 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3724 "next_hop": NEXT_HOP_IP
[addr_type
],
3728 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3729 "next_hop": NEXT_HOP_IP
[addr_type
],
3735 result
= create_static_routes(tgen
, input_dict_1
)
3736 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3741 "Advertise unique BGP prefixes(IPv4+IPv6) from BLUE_1 in"
3742 " vrf instances(BLUE_A and BLUE_B)."
3745 for addr_type
in ADDR_TYPES
:
3750 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3751 "next_hop": NEXT_HOP_IP
[addr_type
],
3755 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3756 "next_hop": NEXT_HOP_IP
[addr_type
],
3762 result
= create_static_routes(tgen
, input_dict_2
)
3763 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3767 step("Redistribute static..")
3770 for dut
in ["red1", "blue1"]:
3771 temp
= {dut
: {"bgp": []}}
3772 input_dict_3
.update(temp
)
3775 VRFS
= ["RED_A", "RED_B"]
3778 VRFS
= ["BLUE_A", "BLUE_B"]
3781 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
3782 temp
[dut
]["bgp"].append(
3788 "unicast": {"redistribute": [{"redist_type": "static"}]}
3791 "unicast": {"redistribute": [{"redist_type": "static"}]}
3797 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
3798 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
3800 step("Restart frr on R1")
3801 stop_router(tgen
, "r1")
3802 start_router(tgen
, "r1")
3804 for addr_type
in ADDR_TYPES
:
3811 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3812 "next_hop": NEXT_HOP_IP
[addr_type
],
3816 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3817 "next_hop": NEXT_HOP_IP
[addr_type
],
3828 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3829 "next_hop": NEXT_HOP_IP
[addr_type
],
3833 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3834 "next_hop": NEXT_HOP_IP
[addr_type
],
3841 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
3842 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3844 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
3845 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
3847 write_test_footer(tc_name
)
3850 if __name__
== "__main__":
3851 args
= ["-s"] + sys
.argv
[1:]
3852 sys
.exit(pytest
.main(args
))