2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2021 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 Dynamic Route Leaking:
12 1. Verify that with multiple tenant VRFs, dynamically imported routes are
13 further advertised to eBGP peers.
14 2. Verify the route-map operations along with dynamic import command
15 3. Verify that deleting static routes from originating VRF also deletes
16 routes from other VRFs and peers.
17 4. Verify that deleting and adding "import" command multiple times shows
26 from time
import sleep
28 # Save the Current Working Directory to find configuration files.
29 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
30 sys
.path
.append(os
.path
.join(CWD
, "../"))
31 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
33 # Required to instantiate the topology builder class.
35 # pylint: disable=C0413
36 # Import topogen and topotest helpers
37 from lib
.topogen
import Topogen
, get_topogen
38 from lib
.topotest
import version_cmp
40 from lib
.common_config
import (
45 reset_config_on_routers
,
51 create_bgp_community_lists
,
52 get_frr_ipv6_linklocal
,
55 from lib
.topolog
import logger
57 verify_bgp_convergence
,
62 from lib
.topojson
import build_config_from_json
64 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
67 NETWORK1_1
= {"ipv4": "11.11.11.1/32", "ipv6": "11:11::1/128"}
68 NETWORK1_2
= {"ipv4": "11.11.11.11/32", "ipv6": "11:11::11/128"}
69 NETWORK1_3
= {"ipv4": "10.10.10.1/32", "ipv6": "10:10::1/128"}
70 NETWORK1_4
= {"ipv4": "10.10.10.100/32", "ipv6": "10:10::100/128"}
71 NETWORK1_5
= {"ipv4": "110.110.110.1/32", "ipv6": "110:110::1/128"}
72 NETWORK1_6
= {"ipv4": "110.110.110.100/32", "ipv6": "110:110::100/128"}
74 NETWORK2_1
= {"ipv4": "22.22.22.2/32", "ipv6": "22:22::2/128"}
75 NETWORK2_2
= {"ipv4": "22.22.22.22/32", "ipv6": "22:22::22/128"}
76 NETWORK2_3
= {"ipv4": "20.20.20.20/32", "ipv6": "20:20::20/128"}
77 NETWORK2_4
= {"ipv4": "20.20.20.200/32", "ipv6": "20:20::200/128"}
78 NETWORK2_5
= {"ipv4": "220.220.220.20/32", "ipv6": "220:220::20/128"}
79 NETWORK2_6
= {"ipv4": "220.220.220.200/32", "ipv6": "220:220::200/128"}
81 NETWORK3_1
= {"ipv4": "30.30.30.3/32", "ipv6": "30:30::3/128"}
82 NETWORK3_2
= {"ipv4": "30.30.30.30/32", "ipv6": "30:30::30/128"}
85 "ipv4": ["11.11.11.1", "22.22.22.2", "22.22.22.22"],
86 "ipv6": ["11:11::1", "22:22::2", "22:22::22"],
88 PREFERRED_NEXT_HOP
= "global"
89 VRF_LIST
= ["RED", "BLUE", "GREEN"]
90 COMM_VAL_1
= "100:100"
91 COMM_VAL_2
= "500:500"
92 COMM_VAL_3
= "600:600"
95 def setup_module(mod
):
97 Sets up the pytest environment
102 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
103 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
104 logger
.info("=" * 40)
106 logger
.info("Running setup_module to create topology")
108 # This function initiates the topology build with Topogen...
109 json_file
= "{}/bgp_vrf_dynamic_route_leak_topo3.json".format(CWD
)
110 tgen
= Topogen(json_file
, mod
.__name
__)
112 topo
= tgen
.json_topo
113 # ... and here it calls Mininet initialization functions.
115 # Starting topology, create tmp files which are loaded to routers
116 # to start daemons and then start routers
119 # Run these tests for kernel version 4.19 or above
120 if version_cmp(platform
.release(), "4.19") < 0:
122 "BGP vrf dynamic route leak tests will not run "
123 '(have kernel "{}", but it requires >= 4.19)'.format(platform
.release())
125 pytest
.skip(error_msg
)
127 # Creating configuration from JSON
128 build_config_from_json(tgen
, topo
)
130 global BGP_CONVERGENCE
132 ADDR_TYPES
= check_address_types()
134 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
135 assert BGP_CONVERGENCE
is True, "setup_module : Failed \n Error: {}".format(
139 logger
.info("Running setup_module() done")
142 def teardown_module():
143 """Teardown the pytest environment"""
145 logger
.info("Running teardown_module to delete topology")
149 # Stop toplogy and Remove tmp files
153 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
155 logger
.info("=" * 40)
158 #####################################################
162 #####################################################
165 def test_dynamic_import_routes_advertised_to_ebgp_peers_p0(request
):
167 Verify that with multiple tenant VRFs, dynamically imported routes are
168 further advertised to eBGP peers.
172 tc_name
= request
.node
.name
173 write_test_header(tc_name
)
174 reset_config_on_routers(tgen
)
175 if tgen
.routers_have_failure():
176 pytest
.skip(tgen
.errors
)
179 "Configure static routes on R2 and R3 and redistribute in BGP for "
180 "BLUE and RED vrf instances"
182 for dut
, network
in zip(
183 ["r2", "r3"], [[NETWORK1_1
, NETWORK1_2
], [NETWORK2_1
, NETWORK2_2
]]
185 for vrf_name
, network_vrf
in zip(["RED", "BLUE"], network
):
186 step("Configure static route for VRF : {} on {}".format(vrf_name
, dut
))
187 for addr_type
in ADDR_TYPES
:
192 "network": [network_vrf
[addr_type
]],
193 "next_hop": "blackhole",
200 result
= create_static_routes(tgen
, static_routes
)
201 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
205 for dut
, as_num
in zip(["r2", "r3"], ["2", "3"]):
206 for vrf_name
in ["RED", "BLUE"]:
207 step("Redistribute static route on BGP VRF : {}".format(vrf_name
))
209 for addr_type
in ADDR_TYPES
:
213 "unicast": {"redistribute": [{"redist_type": "static"}]}
221 {"vrf": vrf_name
, "local_as": as_num
, "address_family": temp
}
226 result
= create_router_bgp(tgen
, topo
, redist_dict
)
227 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
232 "Verify that R2 and R3 has installed redistributed routes in BLUE "
235 for dut
, network
in zip(
236 ["r2", "r3"], [[NETWORK2_1
, NETWORK2_2
], [NETWORK1_1
, NETWORK1_2
]]
238 for vrf_name
, network_vrf
in zip(["RED", "BLUE"], network
):
239 for addr_type
in ADDR_TYPES
:
244 "network": [network_vrf
[addr_type
]],
245 "next_hop": "blackhole",
251 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
)
252 assert result
is True, "Testcase {} : Failed \n Error {}".format(
256 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
)
257 assert result
is True, "Testcase {} : Failed \n Error {}".format(
262 "Import BLUE vrf's route in tenant vrf RED on R2 and then import "
263 "vrf RED's routes into BLUE vrf on R3"
266 for dut
, as_num
, vrf_name
, vrf_import
in zip(
267 ["r2", "r3"], ["2", "3"], ["RED", "BLUE"], ["BLUE", "RED"]
269 step("Import vrf {} int vrf {}, on router {}".format(vrf_import
, vrf_name
, dut
))
271 for addr_type
in ADDR_TYPES
:
272 temp
.update({addr_type
: {"unicast": {"import": {"vrf": vrf_import
}}}})
276 "bgp": [{"vrf": vrf_name
, "local_as": as_num
, "address_family": temp
}]
280 result
= create_router_bgp(tgen
, topo
, import_dict
)
281 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
286 "Verify that R2's vrf RED and R3's vrf BLUE has installed 4 set of "
287 "prefixes. Routes imported from BLUE vrf (originated R2's & received "
288 "from R3). Vrf RED's local routes (originated by R2's & received "
292 "Verify that R2 and R3 has installed redistributed routes in BLUE "
296 for dut
, vrf_name
in zip(["r2", "r3"], ["RED", "BLUE"]):
297 for addr_type
in ADDR_TYPES
:
303 NETWORK1_1
[addr_type
],
304 NETWORK1_2
[addr_type
],
305 NETWORK2_1
[addr_type
],
306 NETWORK2_2
[addr_type
],
308 "next_hop": "blackhole",
314 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
)
315 assert result
is True, "Testcase {} : Failed \n Error {}".format(
319 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
)
320 assert result
is True, "Testcase {} : Failed \n Error {}".format(
325 "Additionally, R2 receives R3's BLUE vrf's prefixes and then import "
326 "into vrf RED. These imported routes are advertised back to "
327 "(originator)R3 but now in vrf RED, however R3 doesn't install these "
328 "in vrf RED. Denied due to own AS"
330 for addr_type
in ADDR_TYPES
:
336 NETWORK1_1
[addr_type
],
337 NETWORK1_2
[addr_type
],
338 NETWORK2_1
[addr_type
],
339 NETWORK2_2
[addr_type
],
341 "next_hop": "blackhole",
347 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
350 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
351 tc_name
, result
, static_routes
["r3"]["static_routes"][0]["network"]
354 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
355 assert result
is not True, "Testcase {} : Failed \n Error {}".format(
359 step("Remove import vrf BLUE from vrf RED's instance on R2.")
361 for addr_type
in ADDR_TYPES
:
363 {addr_type
: {"unicast": {"import": {"vrf": "BLUE", "delete": True}}}}
367 "r2": {"bgp": [{"vrf": "RED", "local_as": 2, "address_family": temp
}]}
370 result
= create_router_bgp(tgen
, topo
, import_dict
)
371 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
373 "Verify on R3 that, there is no change in FIB of vrf BLUE and R2's "
374 "BLUE vrf originated routes are removed from vrf RED on R3."
376 for vrf_name
in ["RED", "BLUE"]:
377 for addr_type
in ADDR_TYPES
:
378 if vrf_name
== "RED":
379 network_vrf
= [NETWORK1_1
[addr_type
], NETWORK2_1
[addr_type
]]
380 elif vrf_name
== "BLUE":
382 NETWORK1_1
[addr_type
],
383 NETWORK1_2
[addr_type
],
384 NETWORK2_1
[addr_type
],
385 NETWORK2_2
[addr_type
],
391 "network": network_vrf
,
392 "next_hop": "blackhole",
398 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
)
399 assert result
is True, "Testcase {} : Failed \n Error {}".format(
403 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
)
404 assert result
is True, "Testcase {} : Failed \n Error {}".format(
408 step("Remove import vrf BLUE from vrf RED's instance on R2.")
410 for addr_type
in ADDR_TYPES
:
411 temp
.update({addr_type
: {"unicast": {"import": {"vrf": "BLUE"}}}})
414 "r2": {"bgp": [{"vrf": "RED", "local_as": 2, "address_family": temp
}]}
417 result
= create_router_bgp(tgen
, topo
, import_dict
)
418 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
421 "All the routes described in earlier step should be added, once "
422 "import command on R2 is re-added."
424 for dut
, vrf_name
in zip(["r2", "r3"], ["RED", "BLUE"]):
425 for addr_type
in ADDR_TYPES
:
431 NETWORK1_1
[addr_type
],
432 NETWORK1_2
[addr_type
],
433 NETWORK2_1
[addr_type
],
434 NETWORK2_2
[addr_type
],
436 "next_hop": "blackhole",
442 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
)
443 assert result
is True, "Testcase {} : Failed \n Error {}".format(
447 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
)
448 assert result
is True, "Testcase {} : Failed \n Error {}".format(
452 step("Remove import vrf RED from BLUE vrf on R3")
454 for addr_type
in ADDR_TYPES
:
456 {addr_type
: {"unicast": {"import": {"vrf": "RED", "delete": True}}}}
460 "r3": {"bgp": [{"vrf": "BLUE", "local_as": 3, "address_family": temp
}]}
463 result
= create_router_bgp(tgen
, topo
, import_dict
)
464 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
467 "Verify on R2 that, there is no change in FIB of vrf RED and R3's "
468 "vrf RED's originated routes are removed from vrf BLUE on R2."
470 for vrf_name
in ["RED", "BLUE"]:
471 for addr_type
in ADDR_TYPES
:
472 if vrf_name
== "BLUE":
473 network_vrf
= [NETWORK1_2
[addr_type
], NETWORK2_2
[addr_type
]]
474 elif vrf_name
== "RED":
476 NETWORK1_1
[addr_type
],
477 NETWORK1_2
[addr_type
],
478 NETWORK2_1
[addr_type
],
479 NETWORK2_2
[addr_type
],
485 "network": network_vrf
,
486 "next_hop": "blackhole",
492 result
= verify_bgp_rib(tgen
, addr_type
, "r2", static_routes
)
493 assert result
is True, "Testcase {} : Failed \n Error {}".format(
497 result
= verify_rib(tgen
, addr_type
, "r2", static_routes
)
498 assert result
is True, "Testcase {} : Failed \n Error {}".format(
502 step("Add import vrf RED from BLUE vrf on R3")
504 for addr_type
in ADDR_TYPES
:
505 temp
.update({addr_type
: {"unicast": {"import": {"vrf": "RED"}}}})
508 "r3": {"bgp": [{"vrf": "BLUE", "local_as": 3, "address_family": temp
}]}
511 result
= create_router_bgp(tgen
, topo
, import_dict
)
512 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
515 "All the routes described in earlier step should be added, once "
516 "import command on R2 is re-added."
518 for dut
, vrf_name
in zip(["r2", "r3"], ["RED", "BLUE"]):
519 for addr_type
in ADDR_TYPES
:
525 NETWORK1_1
[addr_type
],
526 NETWORK1_2
[addr_type
],
527 NETWORK2_1
[addr_type
],
528 NETWORK2_2
[addr_type
],
530 "next_hop": "blackhole",
536 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
)
537 assert result
is True, "Testcase {} : Failed \n Error {}".format(
541 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
)
542 assert result
is True, "Testcase {} : Failed \n Error {}".format(
546 write_test_footer(tc_name
)
549 def test_dynamic_imported_matching_prefix_based_on_community_list_p0(request
):
551 Verify the route-map operations along with dynamic import command
555 tc_name
= request
.node
.name
556 write_test_header(tc_name
)
557 reset_config_on_routers(tgen
)
558 if tgen
.routers_have_failure():
559 pytest
.skip(tgen
.errors
)
562 "Configure static routes on R3 for vrf RED and redistribute in BGP " "instance"
564 for vrf_name
, networks
in zip(
565 ["RED", "BLUE"], [[NETWORK1_1
, NETWORK1_2
], [NETWORK2_1
, NETWORK2_2
]]
567 for addr_type
in ADDR_TYPES
:
572 "network": [networks
[0][addr_type
], networks
[1][addr_type
]],
573 "next_hop": "blackhole",
580 result
= create_static_routes(tgen
, static_routes
)
581 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
586 "Configure route-map to set community attribute for a specific " "prefix on R3"
588 for addr_type
in ADDR_TYPES
:
593 "pflist_ABC_{}".format(addr_type
): [
596 "network": NETWORK1_1
[addr_type
],
604 result
= create_prefix_lists(tgen
, input_dict_pf
)
605 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
611 "bgp_community_lists": [
613 "community_type": "expanded",
621 result
= create_bgp_community_lists(tgen
, input_dict_cl
)
622 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
624 for addr_type
in ADDR_TYPES
:
628 "rmap_XYZ_{}".format(addr_type
): [
633 "prefix_lists": "pflist_ABC_{}".format(addr_type
)
636 "set": {"community": {"num": COMM_VAL_1
}},
642 result
= create_route_maps(tgen
, input_dict_rm
)
643 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
648 "Apply this route-map on R3 to set community under vrf RED/BLUE "
649 "while redistributing the prefixes into BGP"
652 for addr_type
in ADDR_TYPES
:
659 "redist_type": "static",
661 "route-map": "rmap_XYZ_{}".format(addr_type
)
670 for vrf_name
in ["RED", "BLUE"]:
672 "r3": {"bgp": [{"vrf": vrf_name
, "local_as": 3, "address_family": temp
}]}
675 result
= create_router_bgp(tgen
, topo
, redist_dict
)
676 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
681 "Verify that specific prefixes matched in route-map have community "
682 "attribute value 100:100 tagged"
684 input_dict_comm
= {"community": COMM_VAL_1
}
685 for addr_type
in ADDR_TYPES
:
686 result
= verify_bgp_community(
687 tgen
, addr_type
, "r3", [NETWORK1_1
[addr_type
]], input_dict_comm
, vrf
="RED"
689 assert result
is True, "Testcase {} : Failed \n Error {}".format(
694 "Configure a route-map for filtering the prefixes based on community "
695 "attribute while importing into default vrf"
697 for addr_type
in ADDR_TYPES
:
701 "rmap_IMP_{}".format(addr_type
): [
705 "match": {"community_list": {"id": "COMM"}},
706 "set": {"community": {"num": COMM_VAL_2
}},
712 result
= create_route_maps(tgen
, input_dict_rm
)
713 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
718 "Apply the route-map while Importing vrf RED/BLUE's prefixes into "
719 "GREEN vrf on router R3"
722 for vrf_name
in ["RED", "BLUE"]:
723 for addr_type
in ADDR_TYPES
:
724 temp
.update({addr_type
: {"unicast": {"import": {"vrf": vrf_name
}}}})
727 "r3": {"bgp": [{"vrf": "GREEN", "local_as": 3, "address_family": temp
}]}
730 result
= create_router_bgp(tgen
, topo
, inport_dict
)
731 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
736 for addr_type
in ADDR_TYPES
:
741 "import": {"vrf": "route-map rmap_IMP_{}".format(addr_type
)}
748 "r3": {"bgp": [{"vrf": "GREEN", "local_as": 3, "address_family": temp
}]}
751 result
= create_router_bgp(tgen
, topo
, inport_dict
)
752 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
754 input_dict_comm
= {"community": COMM_VAL_2
}
756 "Verify on R3 that only prefixes with community value {} in vrf RED "
757 "are imported to vrf GREEN. While importing, the community value "
758 "has been changed to {}".format(COMM_VAL_1
, COMM_VAL_2
)
761 for addr_type
in ADDR_TYPES
:
764 "static_routes": [{"network": [NETWORK1_1
[addr_type
]], "vrf": "GREEN"}]
768 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
)
769 assert result
is True, "Testcase {} : Failed \n Error {}".format(
773 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
)
774 assert result
is True, "Testcase {} : Failed \n Error {}".format(
783 NETWORK2_1
[addr_type
],
784 NETWORK2_2
[addr_type
],
785 NETWORK1_2
[addr_type
],
793 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
796 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
797 tc_name
, result
, static_routes
["r3"]["static_routes"][0]["network"]
800 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
803 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
804 tc_name
, result
, static_routes
["r3"]["static_routes"][0]["network"]
807 result
= verify_bgp_community(
808 tgen
, addr_type
, "r3", [NETWORK1_1
[addr_type
]], input_dict_comm
, vrf
="GREEN"
810 assert result
is True, "Testcase {} : Failed \n Error {}".format(
814 for action
, value
in zip(["Delete", "Add"], [True, False]):
815 step("{} import vrf RED/BLUE command one by one from vrf GREEN".format(action
))
817 for vrf_name
in ["RED", "BLUE"]:
818 for addr_type
in ADDR_TYPES
:
822 "unicast": {"import": {"vrf": vrf_name
, "delete": value
}}
828 "r3": {"bgp": [{"vrf": "GREEN", "local_as": 3, "address_family": temp
}]}
831 result
= create_router_bgp(tgen
, topo
, inport_dict
)
832 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
837 "Verify that when import vrf RED/BLUE is {} one by one, all "
838 "routes of respective vrf disappear from vrf GREEN without "
839 "affecting (BLUE/RED) routes".format(action
.lower())
841 for addr_type
in ADDR_TYPES
:
845 {"network": [NETWORK1_1
[addr_type
]], "vrf": "GREEN"}
851 result
= verify_bgp_rib(
852 tgen
, addr_type
, "r3", static_routes
, expected
=False
856 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
859 static_routes
["r3"]["static_routes"][0]["network"],
863 tgen
, addr_type
, "r3", static_routes
, expected
=False
867 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
870 static_routes
["r3"]["static_routes"][0]["network"],
873 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
)
874 assert result
is True, "Testcase {} : Failed \n Error {}".format(
878 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
)
879 assert result
is True, "Testcase {} : Failed \n Error {}".format(
883 for action
, value
in zip(["Delete", "Re-add"], [True, False]):
885 "{} route-map IMP from global config when import and route-maps "
886 "are applied in vrf GREEN".format(action
)
888 for addr_type
in ADDR_TYPES
:
892 "rmap_IMP_{}".format(addr_type
): [
896 "match": {"community_list": {"id": "COMM"}},
897 "set": {"community": {"num": COMM_VAL_2
}},
904 result
= create_route_maps(tgen
, input_dict_rm
)
905 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
910 "Verify that when import vrf RED/BLUE is {} one by one, all "
911 "routes of respective vrf disappear from vrf GREEN without "
912 "affecting (BLUE/RED) routes".format(action
.lower())
914 for addr_type
in ADDR_TYPES
:
918 {"network": [NETWORK1_1
[addr_type
]], "vrf": "GREEN"}
924 result
= verify_bgp_rib(
925 tgen
, addr_type
, "r3", static_routes
, expected
=False
929 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
932 static_routes
["r3"]["static_routes"][0]["network"],
936 tgen
, addr_type
, "r3", static_routes
, expected
=False
940 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
943 static_routes
["r3"]["static_routes"][0]["network"],
946 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
)
947 assert result
is True, "Testcase {} : Failed \n Error {}".format(
951 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
)
952 assert result
is True, "Testcase {} : Failed \n Error {}".format(
956 write_test_footer(tc_name
)
959 def test_dynamic_import_routes_delete_static_route_p1(request
):
961 Verify that deleting static routes from originating VRF also deletes
962 routes from other VRFs and peers.
966 tc_name
= request
.node
.name
967 write_test_header(tc_name
)
968 reset_config_on_routers(tgen
)
969 if tgen
.routers_have_failure():
970 pytest
.skip(tgen
.errors
)
973 "Configure static routes on R3 for each tenant vrf and redistribute "
974 "in respective BGP instance"
976 vrf_list
= VRF_LIST
+ ["default"]
977 for vrf_name
, network
in zip(
978 vrf_list
, [NETWORK1_1
, NETWORK2_1
, NETWORK3_1
, NETWORK1_2
]
980 step("Configure static route for VRF : {}".format(vrf_name
))
981 for addr_type
in ADDR_TYPES
:
986 "network": [network
[addr_type
]],
987 "next_hop": "blackhole",
994 result
= create_static_routes(tgen
, static_routes
)
995 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
999 step("Redistribute static route on BGP VRF : {}".format(vrf_name
))
1001 for addr_type
in ADDR_TYPES
:
1003 {addr_type
: {"unicast": {"redistribute": [{"redist_type": "static"}]}}}
1007 "r3": {"bgp": [{"vrf": vrf_name
, "local_as": 3, "address_family": temp
}]}
1010 result
= create_router_bgp(tgen
, topo
, redist_dict
)
1011 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1015 for vrf_name
, network
in zip(vrf_list
, [NETWORK1_1
, NETWORK2_1
, NETWORK3_1
]):
1017 "Verify that R3 has installed redistributed routes in respective "
1018 "vrfs: {}".format(vrf_name
)
1020 for addr_type
in ADDR_TYPES
:
1025 "network": [network
[addr_type
]],
1026 "next_hop": "blackhole",
1033 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
)
1034 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1038 step("Import routes among vrfs as mentioned below on router R3")
1040 for vrf_name
, vrf_import
in zip(
1041 ["GREEN", "BLUE", "default"], ["RED", "GREEN", "BLUE"]
1044 for addr_type
in ADDR_TYPES
:
1045 temp
.update({addr_type
: {"unicast": {"import": {"vrf": vrf_import
}}}})
1048 "r3": {"bgp": [{"vrf": vrf_name
, "local_as": 3, "address_family": temp
}]}
1051 result
= create_router_bgp(tgen
, topo
, import_dict
)
1052 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1056 for vrf_name
, vrf_import
, installed
, not_installed
in zip(
1057 ["BLUE", "default"],
1059 [NETWORK3_1
, NETWORK2_1
],
1060 [NETWORK1_1
, NETWORK3_1
],
1063 "Verify that only locally originated routes of vrf {} are "
1064 "advertised to vrf {}".format(vrf_import
, vrf_name
)
1067 for addr_type
in ADDR_TYPES
:
1071 {"network": [installed
[addr_type
]], "vrf": vrf_name
}
1075 result
= verify_bgp_rib(tgen
, addr_type
, "r2", static_routes
)
1076 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1080 result
= verify_rib(tgen
, addr_type
, "r2", static_routes
)
1081 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1086 "Verify that non local originated routes {} of vrf {} are "
1087 "not advertised to vrf {}".format(
1088 not_installed
[addr_type
], vrf_import
, vrf_name
1095 {"network": [not_installed
[addr_type
]], "vrf": vrf_name
}
1099 result
= verify_bgp_rib(
1100 tgen
, addr_type
, "r2", static_routes
, expected
=False
1102 assert result
is not True, (
1103 "Testcase {} : Failed \nError {}\n"
1104 "Routes {} still in BGP table".format(
1105 tc_name
, result
, static_routes
["r2"]["static_routes"][0]["network"]
1109 result
= verify_rib(tgen
, addr_type
, "r2", static_routes
, expected
=False)
1112 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
1113 tc_name
, result
, static_routes
["r2"]["static_routes"][0]["network"]
1116 step("Delete static routes from vrf RED")
1117 for addr_type
in ADDR_TYPES
:
1122 "network": [NETWORK1_1
[addr_type
]],
1123 "next_hop": "blackhole",
1131 result
= create_static_routes(tgen
, static_routes
)
1132 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1136 "Verify on R2 and R3, that only vrf RED and GREEN's RIB/FIB withdraw "
1139 for dut
in ["r2", "r3"]:
1141 "Verify on {}, that only vrf RED and GREEN's RIB/FIB withdraw "
1142 "deleted routes".format(dut
)
1144 for vrf_name
in ["RED", "GREEN"]:
1145 for addr_type
in ADDR_TYPES
:
1149 {"network": [NETWORK1_1
[addr_type
]], "vrf": vrf_name
}
1153 result
= verify_bgp_rib(
1154 tgen
, addr_type
, "r2", static_routes
, expected
=False
1158 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
1161 static_routes
["r2"]["static_routes"][0]["network"],
1164 result
= verify_rib(
1165 tgen
, addr_type
, "r2", static_routes
, expected
=False
1169 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
1172 static_routes
[dut
]["static_routes"][0]["network"],
1175 step("Delete static routes from vrf BLUE")
1176 for addr_type
in ADDR_TYPES
:
1181 "network": [NETWORK2_1
[addr_type
]],
1182 "next_hop": "blackhole",
1190 result
= create_static_routes(tgen
, static_routes
)
1191 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1195 for dut
in ["r2", "r3"]:
1197 "Verify on {}, that only default and BLUE vrf's RIB/FIB "
1198 "withdraw deleted routes".format(dut
)
1200 for vrf_name
in ["BLUE", "default"]:
1201 for addr_type
in ADDR_TYPES
:
1205 {"network": [NETWORK2_1
[addr_type
]], "vrf": vrf_name
}
1209 result
= verify_bgp_rib(
1210 tgen
, addr_type
, dut
, static_routes
, expected
=False
1214 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
1217 static_routes
[dut
]["static_routes"][0]["network"],
1220 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
, expected
=False)
1223 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
1226 static_routes
[dut
]["static_routes"][0]["network"],
1229 step("Delete static routes from vrf default")
1230 for addr_type
in ADDR_TYPES
:
1235 "network": [NETWORK1_2
[addr_type
]],
1236 "next_hop": "blackhole",
1243 result
= create_static_routes(tgen
, static_routes
)
1244 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1248 for dut
in ["r2", "r3"]:
1250 "Verify on {}, that only default vrf RIB/FIB withdraw deleted "
1251 "routes".format(dut
)
1253 for addr_type
in ADDR_TYPES
:
1257 {"network": [NETWORK1_2
[addr_type
]], "vrf": vrf_name
}
1261 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
, expected
=False)
1262 assert result
is not True, (
1263 "Testcase {} : Failed \nError {}\n"
1264 "Routes {} still in BGP table".format(
1265 tc_name
, result
, static_routes
[dut
]["static_routes"][0]["network"]
1269 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
, expected
=False)
1270 assert result
is not True, "Testcase {} : Failed \n Error {}".format(
1274 step("Add back all the routes that were deleted")
1275 for vrf_name
, network
in zip(
1276 vrf_list
, [NETWORK1_1
, NETWORK2_1
, NETWORK3_1
, NETWORK1_2
]
1278 step("Configure static route for VRF : {}".format(vrf_name
))
1279 for addr_type
in ADDR_TYPES
:
1284 "network": [network
[addr_type
]],
1285 "next_hop": "blackhole",
1292 result
= create_static_routes(tgen
, static_routes
)
1293 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1297 step("Redistribute static route on BGP VRF : {}".format(vrf_name
))
1299 for addr_type
in ADDR_TYPES
:
1301 {addr_type
: {"unicast": {"redistribute": [{"redist_type": "static"}]}}}
1305 "r3": {"bgp": [{"vrf": vrf_name
, "local_as": 3, "address_family": temp
}]}
1308 result
= create_router_bgp(tgen
, topo
, redist_dict
)
1309 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1313 for vrf_name
, network
in zip(vrf_list
, [NETWORK1_1
, NETWORK2_1
, NETWORK3_1
]):
1315 "Verify that R3 has installed redistributed routes in respective "
1316 "vrfs: {}".format(vrf_name
)
1318 for addr_type
in ADDR_TYPES
:
1323 "network": [network
[addr_type
]],
1324 "next_hop": "blackhole",
1331 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
)
1332 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1336 write_test_footer(tc_name
)
1339 def test_dynamic_import_routes_add_delete_import_command_p1(request
):
1341 Verify that deleting and adding "import" command multiple times shows
1345 tgen
= get_topogen()
1346 tc_name
= request
.node
.name
1347 write_test_header(tc_name
)
1348 reset_config_on_routers(tgen
)
1349 if tgen
.routers_have_failure():
1350 pytest
.skip(tgen
.errors
)
1353 "Configure static routes on R2 for vrf RED and redistribute in "
1354 "respective BGP instance"
1356 for addr_type
in ADDR_TYPES
:
1361 "network": [NETWORK2_1
[addr_type
]],
1362 "next_hop": "blackhole",
1369 result
= create_static_routes(tgen
, static_routes
)
1370 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1374 step("Redistribute static route on BGP VRF RED")
1376 for addr_type
in ADDR_TYPES
:
1378 {addr_type
: {"unicast": {"redistribute": [{"redist_type": "static"}]}}}
1382 "r2": {"bgp": [{"vrf": "RED", "local_as": 2, "address_family": temp
}]}
1385 result
= create_router_bgp(tgen
, topo
, redist_dict
)
1386 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1388 step("Verify that R2 has installed redistributed routes in respective " "vrfs only")
1389 for addr_type
in ADDR_TYPES
:
1392 "static_routes": [{"network": [NETWORK2_1
[addr_type
]], "vrf": "RED"}]
1395 result
= verify_bgp_rib(tgen
, addr_type
, "r2", static_routes
)
1396 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1400 result
= verify_rib(tgen
, addr_type
, "r2", static_routes
)
1401 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1405 step("Import vrf RED's routes into vrf GREEN on R2")
1407 for addr_type
in ADDR_TYPES
:
1408 temp
.update({addr_type
: {"unicast": {"import": {"vrf": "RED"}}}})
1411 "r2": {"bgp": [{"vrf": "GREEN", "local_as": 2, "address_family": temp
}]}
1413 result
= create_router_bgp(tgen
, topo
, import_dict
)
1414 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1417 "Verify on R2, that it installs imported routes from vrf RED to vrf "
1420 for addr_type
in ADDR_TYPES
:
1423 "static_routes": [{"network": [NETWORK2_1
[addr_type
]], "vrf": "GREEN"}]
1426 result
= verify_bgp_rib(tgen
, addr_type
, "r2", static_routes
)
1427 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1431 result
= verify_rib(tgen
, addr_type
, "r2", static_routes
)
1432 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1436 step("On R3 import routes from vrfs GREEN to default")
1438 for addr_type
in ADDR_TYPES
:
1439 temp
.update({addr_type
: {"unicast": {"import": {"vrf": "GREEN"}}}})
1441 import_dict
= {"r3": {"bgp": [{"local_as": 3, "address_family": temp
}]}}
1442 result
= create_router_bgp(tgen
, topo
, import_dict
)
1443 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1446 "Verify that R2's vrf RED routes are now imported into vrf default "
1447 "of R3, next-hop pointing to vrf GREEN"
1449 for addr_type
in ADDR_TYPES
:
1451 "r3": {"static_routes": [{"network": [NETWORK2_1
[addr_type
]]}]}
1454 next_hop_1
= topo
["routers"]["r2"]["links"]["r3-link3"][addr_type
].split("/")[0]
1455 result
= verify_bgp_rib(
1456 tgen
, addr_type
, "r3", static_routes
, next_hop
=next_hop_1
1458 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1462 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, next_hop
=next_hop_1
)
1463 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1468 "Delete import command from R3's default vrf instance for both "
1469 "address-families 1 by 1 (ipv4/ipv6)"
1472 for addr_type
in ADDR_TYPES
:
1474 {addr_type
: {"unicast": {"import": {"vrf": "GREEN", "delete": True}}}}
1477 import_dict
= {"r3": {"bgp": [{"local_as": 3, "address_family": temp
}]}}
1478 result
= create_router_bgp(tgen
, topo
, import_dict
)
1479 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1482 "Verify that R2's vrf RED routes are now removed from vrf "
1483 "default on R3, however vrf GREEN still retains those"
1485 for addr_type
in ADDR_TYPES
:
1487 "r3": {"static_routes": [{"network": [NETWORK2_1
[addr_type
]]}]}
1489 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1492 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
1493 tc_name
, result
, static_routes
["r3"]["static_routes"][0]["network"]
1496 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1497 assert result
is not True, "Testcase {} : Failed \n Error {}".format(
1502 "Delete import command from R2's vrf GREEN instance for both "
1503 "address-families 1 by 1 (ipv4/ipv6)"
1506 for addr_type
in ADDR_TYPES
:
1508 {addr_type
: {"unicast": {"import": {"vrf": "RED", "delete": True}}}}
1512 "r2": {"bgp": [{"vrf": "GREEN", "local_as": 2, "address_family": temp
}]}
1514 result
= create_router_bgp(tgen
, topo
, import_dict
)
1515 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1517 "Verify that R2's vrf RED routes are now removed from vrf GREEN "
1518 "on R2 & R3 as well"
1520 for dut
in ["r2", "r3"]:
1521 for addr_type
in ADDR_TYPES
:
1525 {"network": [NETWORK2_1
[addr_type
]], "vrf": "GREEN"}
1529 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
, expected
=False)
1530 assert result
is not True, (
1531 "Testcase {} : Failed \nError {}\n"
1532 "Routes {} still in BGP table".format(
1533 tc_name
, result
, static_routes
[dut
]["static_routes"][0]["network"]
1537 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
, expected
=False)
1540 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
1541 tc_name
, result
, static_routes
[dut
]["static_routes"][0]["network"]
1545 "Add import command from R3's default vrf instance for both "
1546 "address-families 1 by 1 (ipv4/ipv6)"
1549 for addr_type
in ADDR_TYPES
:
1550 temp
.update({addr_type
: {"unicast": {"import": {"vrf": "GREEN"}}}})
1552 import_dict
= {"r3": {"bgp": [{"local_as": 3, "address_family": temp
}]}}
1553 result
= create_router_bgp(tgen
, topo
, import_dict
)
1554 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1556 step("Verify that there are no routes installed on R3's vrf default " "RIB/FIB.")
1557 for addr_type
in ADDR_TYPES
:
1559 "r3": {"static_routes": [{"network": [NETWORK2_1
[addr_type
]]}]}
1561 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1564 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
1565 tc_name
, result
, static_routes
["r3"]["static_routes"][0]["network"]
1568 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1569 assert result
is not True, "Testcase {} : Failed \n Error {}".format(
1574 "Add import command from R2's vrf GREEN instance for both "
1575 "address-families 1 by 1 (ipv4/ipv6)."
1578 for addr_type
in ADDR_TYPES
:
1579 temp
.update({addr_type
: {"unicast": {"import": {"vrf": "RED"}}}})
1582 "r2": {"bgp": [{"vrf": "GREEN", "local_as": 2, "address_family": temp
}]}
1584 result
= create_router_bgp(tgen
, topo
, import_dict
)
1585 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1588 "Verify that R2's vrf RED routes are now imported into vrf "
1589 "default of R3, next-hop pointing to vrf GREEN"
1591 for dut
in ["r2", "r3"]:
1592 for addr_type
in ADDR_TYPES
:
1596 {"network": [NETWORK2_1
[addr_type
]], "vrf": "GREEN"}
1601 next_hop_1
= topo
["routers"]["r2"]["links"]["r3-link3"][
1604 result
= verify_bgp_rib(
1605 tgen
, addr_type
, dut
, static_routes
, next_hop
=next_hop_1
1608 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
)
1609 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1614 result
= verify_rib(
1615 tgen
, addr_type
, dut
, static_routes
, next_hop
=next_hop_1
1618 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
)
1620 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1625 "Delete import command from R3's default vrf instance for both "
1626 "address-families 1 by 1 (ipv4/ipv6)."
1629 for addr_type
in ADDR_TYPES
:
1631 {addr_type
: {"unicast": {"import": {"vrf": "GREEN", "delete": True}}}}
1634 import_dict
= {"r3": {"bgp": [{"local_as": 3, "address_family": temp
}]}}
1635 result
= create_router_bgp(tgen
, topo
, import_dict
)
1636 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1639 "Verify that R2's vrf RED routes are now removed from vrf "
1640 "default on R3, however vrf GREEN still retains those."
1642 for addr_type
in ADDR_TYPES
:
1645 "static_routes": [{"network": [NETWORK2_1
[addr_type
]], "vrf": "GREEN"}]
1648 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
)
1649 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1653 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
)
1654 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1659 "r2": {"static_routes": [{"network": [NETWORK2_1
[addr_type
]]}]}
1661 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1664 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
1665 tc_name
, result
, static_routes
["r3"]["static_routes"][0]["network"]
1668 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1669 assert result
is not True, "Testcase {} : Failed \n Error {}".format(
1673 step("Delete redistribute static from R2 for vrf RED")
1675 for addr_type
in ADDR_TYPES
:
1680 "redistribute": [{"redist_type": "static", "delete": True}]
1687 "r2": {"bgp": [{"vrf": "RED", "local_as": 2, "address_family": temp
}]}
1690 result
= create_router_bgp(tgen
, topo
, redist_dict
)
1691 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1694 "Verify that R2's vrf RED routes are now removed from vrf GREEN "
1695 "on R2 & R3 as well."
1697 for dut
in ["r2", "r3"]:
1698 for addr_type
in ADDR_TYPES
:
1702 {"network": [NETWORK2_1
[addr_type
]], "vrf": "GREEN"}
1706 result
= verify_bgp_rib(tgen
, addr_type
, dut
, static_routes
, expected
=False)
1707 assert result
is not True, (
1708 "Testcase {} : Failed \nError {}\n"
1709 "Routes {} still in BGP table".format(
1710 tc_name
, result
, static_routes
[dut
]["static_routes"][0]["network"]
1714 result
= verify_rib(tgen
, addr_type
, dut
, static_routes
, expected
=False)
1717 ), "Testcase {} : Failed Error {}" "Routes {} still in Route table".format(
1718 tc_name
, result
, static_routes
[dut
]["static_routes"][0]["network"]
1722 "Add import command from R3's default vrf instance for both "
1723 "address-families 1 by 1 (ipv4/ipv6)."
1726 for addr_type
in ADDR_TYPES
:
1727 temp
.update({addr_type
: {"unicast": {"import": {"vrf": "GREEN"}}}})
1729 import_dict
= {"r3": {"bgp": [{"local_as": 3, "address_family": temp
}]}}
1730 result
= create_router_bgp(tgen
, topo
, import_dict
)
1731 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1733 step("Verify that there are no routes installed on R3's vrf default " "RIB/FIB")
1734 for addr_type
in ADDR_TYPES
:
1736 "r3": {"static_routes": [{"network": [NETWORK2_1
[addr_type
]]}]}
1738 result
= verify_bgp_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1741 ), "Testcase {} : Failed \nError {}\n" "Routes {} still in BGP table".format(
1742 tc_name
, result
, static_routes
["r3"]["static_routes"][0]["network"]
1745 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, expected
=False)
1746 assert result
is not True, "Testcase {} : Failed \n Error {}".format(
1750 step("Add redistribute static from R2 for vrf RED")
1752 for addr_type
in ADDR_TYPES
:
1754 {addr_type
: {"unicast": {"redistribute": [{"redist_type": "static"}]}}}
1758 "r2": {"bgp": [{"vrf": "RED", "local_as": 2, "address_family": temp
}]}
1761 result
= create_router_bgp(tgen
, topo
, redist_dict
)
1762 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1765 "Verify that R2's vrf RED routes are now imported into vrf "
1766 "default of R3, next-hop pointing to vrf GREEN"
1768 for addr_type
in ADDR_TYPES
:
1770 "r3": {"static_routes": [{"network": [NETWORK2_1
[addr_type
]]}]}
1772 next_hop_1
= topo
["routers"]["r2"]["links"]["r3-link3"][addr_type
].split("/")[0]
1773 result
= verify_bgp_rib(
1774 tgen
, addr_type
, "r3", static_routes
, next_hop
=next_hop_1
1776 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1780 result
= verify_rib(tgen
, addr_type
, "r3", static_routes
, next_hop
=next_hop_1
)
1781 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1785 write_test_footer(tc_name
)
1788 if __name__
== "__main__":
1789 args
= ["-s"] + sys
.argv
[1:]
1790 sys
.exit(pytest
.main(args
))