2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2020 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation,
7 # Inc. ("NetDEF") in this file.
11 Following tests are covered to test EVPN-Type5 functionality:
13 1. RD verification (manual/auto).
14 2. RT verification(manual)
15 3. In an active/standby EVPN implementation, if active DCG goes down,
17 4. EVPN routes are advertised/withdrawn, based on VNFs
18 advertising/withdrawing IP prefixes.
19 5. Route-map operations for EVPN address family.
20 6. BGP attributes for EVPN address-family.
29 from copy
import deepcopy
32 # Save the Current Working Directory to find configuration files.
33 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
34 sys
.path
.append(os
.path
.join(CWD
, "../"))
35 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
37 # Required to instantiate the topology builder class.
39 # pylint: disable=C0413
40 # Import topogen and topotest helpers
41 from lib
.topotest
import version_cmp
42 from lib
.topogen
import Topogen
, get_topogen
44 from lib
.common_config
import (
49 reset_config_on_routers
,
59 create_interface_in_kernel
,
64 from lib
.topolog
import logger
66 verify_bgp_convergence
,
68 verify_best_path_as_per_bgp_attribute
,
69 verify_attributes_for_evpn_routes
,
72 from lib
.topojson
import build_topo_from_json
, build_config_from_json
74 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
77 NETWORK1_1
= {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
78 NETWORK1_2
= {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"}
79 NETWORK1_3
= {"ipv4": "40.1.1.2/32", "ipv6": "40::2/128"}
80 NETWORK1_4
= {"ipv4": "40.1.1.3/32", "ipv6": "40::3/128"}
81 NETWORK2_1
= {"ipv4": "20.1.1.1/32", "ipv6": "20::1/128"}
82 NETWORK3_1
= {"ipv4": "30.1.1.1/32", "ipv6": "30::1/128"}
83 NETWORK4_1
= {"ipv4": "100.1.1.1/32 ", "ipv6": "100::100/128"}
84 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
88 MAC_1
= "00:80:48:ba:d1:00"
89 MAC_2
= "00:80:48:ba:d1:01"
90 MAC_3
= "00:80:48:ba:d1:02"
94 VXLAN_1
= "vxlan75100"
95 VXLAN_2
= "vxlan75200"
96 VXLAN_3
= "vxlan75300"
97 BRIDGE_INTF1
= "120.0.0.1"
98 BRIDGE_INTF2
= "120.0.0.2"
99 BRIDGE_INTF3
= "120.0.0.3"
102 "vxlan_name": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
103 "vxlan_id": [75100, 75200, 75300],
105 "local_addr": {"e1": BRIDGE_INTF1
, "d1": BRIDGE_INTF2
, "d2": BRIDGE_INTF3
},
109 "brctl_name": [BRCTL_1
, BRCTL_2
, BRCTL_3
],
110 "addvxlan": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
111 "vrf": ["RED", "BLUE", "GREEN"],
116 def setup_module(mod
):
118 Sets up the pytest environment
124 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
125 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
126 logger
.info("=" * 40)
128 logger
.info("Running setup_module to create topology")
130 # This function initiates the topology build with Topogen...
131 json_file
= "{}/evpn_type5_topo1.json".format(CWD
)
132 tgen
= Topogen(json_file
, mod
.__name
__)
133 topo
= tgen
.json_topo
135 # ... and here it calls Mininet initialization functions.
137 # Starting topology, create tmp files which are loaded to routers
138 # to start daemons and then start routers
141 # Creating configuration from JSON
142 build_config_from_json(tgen
, topo
)
144 if version_cmp(platform
.release(), "4.19") < 0:
146 'EVPN tests will not run (have kernel "{}", '
147 "but it requires >= 4.19)".format(platform
.release())
149 pytest
.skip(error_msg
)
151 global BGP_CONVERGENCE
153 ADDR_TYPES
= check_address_types()
155 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
156 assert BGP_CONVERGENCE
is True, "setup_module :Failed \n Error: {}".format(
160 logger
.info("Pre-requisite config for testsuite")
161 prerequisite_config_for_test_suite(tgen
)
163 logger
.info("Running setup_module() done")
166 def teardown_module():
167 """Teardown the pytest environment"""
169 logger
.info("Running teardown_module to delete topology")
173 # Stop toplogy and Remove tmp files
177 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
179 logger
.info("=" * 40)
182 #####################################################
186 #####################################################
189 def prerequisite_config_for_test_suite(tgen
):
191 API to do prerequisite config for testsuite
195 * `tgen`: topogen object
198 step("Configure vxlan, bridge interface")
199 for dut
in ["e1", "d1", "d2"]:
200 step("[DUT: ]Configure vxlan")
205 "vxlan_name": VXLAN
["vxlan_name"],
206 "vxlan_id": VXLAN
["vxlan_id"],
207 "dstport": VXLAN
["dstport"],
208 "local_addr": VXLAN
["local_addr"][dut
],
209 "learning": VXLAN
["learning"],
215 result
= configure_vxlan(tgen
, vxlan_input
)
216 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
218 step("Configure bridge interface")
223 "brctl_name": BRCTL
["brctl_name"],
224 "addvxlan": BRCTL
["addvxlan"],
231 result
= configure_brctl(tgen
, topo
, brctl_input
)
232 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
234 step("Configure default routes")
235 add_default_routes(tgen
)
238 def add_default_routes(tgen
):
240 API to do prerequisite config for testsuite
244 * `tgen`: topogen object
247 step("Add default routes..")
253 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
254 "next_hop": topo
["routers"]["d1"]["links"]["e1-link1"][
259 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
260 "next_hop": topo
["routers"]["d2"]["links"]["e1-link1"][
269 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
270 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
275 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
276 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
285 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
286 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
291 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
292 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
300 result
= create_static_routes(tgen
, default_routes
)
301 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
304 def test_RD_verification_manual_and_auto_p0(request
):
306 RD verification (manual/auto).
310 tc_name
= request
.node
.name
311 write_test_header(tc_name
)
312 check_router_status(tgen
)
313 reset_config_on_routers(tgen
)
314 add_default_routes(tgen
)
316 if tgen
.routers_have_failure():
317 pytest
.skip(tgen
.errors
)
320 "Advertise prefixes from VNF routers R1 and R2 in associated "
321 "VRFs for both address-family."
324 "Advertise vrf RED's routes in EVPN address family from Edge-1 router"
325 ", without manual configuration of RD."
328 for addr_type
in ADDR_TYPES
:
333 "network": NETWORK1_1
[addr_type
],
334 "next_hop": NEXT_HOP_IP
[addr_type
],
342 "network": NETWORK2_1
[addr_type
],
343 "next_hop": NEXT_HOP_IP
[addr_type
],
347 "network": NETWORK3_1
[addr_type
],
348 "next_hop": NEXT_HOP_IP
[addr_type
],
355 result
= create_static_routes(tgen
, input_dict_1
)
356 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
360 step("Verify on DCG-1 and DCG-2:")
361 step("EVPN route for 10.1.1.1/32 has auto-assigned RD value.")
363 for dut
in ["d1", "d2"]:
364 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
365 result
= verify_attributes_for_evpn_routes(
366 tgen
, topo
, dut
, input_routes
, rd
="auto", rd_peer
="e1"
368 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
373 "Configure RD for vrf RED manually as 50.50.50.50:50 and "
374 "advertise vrf RED's routes in EVPN address family from "
384 "address_family": {"l2vpn": {"evpn": {"rd": "50.50.50.50:50"}}},
390 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
391 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
393 step("EVPN route for vrf RED has RD value as 50.50.50.50:50")
394 for dut
in ["d1", "d2"]:
395 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
396 result
= verify_attributes_for_evpn_routes(
397 tgen
, topo
, dut
, input_routes
, rd
="50.50.50.50:50"
399 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
404 "Configure RD for vrf RED manually as 100.100.100.100:100 and "
405 "advertise vrf RED's routes in EVPN address family from Edge-1 "
415 "l2vpn": {"evpn": {"rd": "100.100.100.100:100"}}
422 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
423 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
426 "EVPN route for vrf RED is overridden with RD value as " "100.100.100.100:100."
429 for dut
in ["d1", "d2"]:
430 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
431 result
= verify_attributes_for_evpn_routes(
432 tgen
, topo
, dut
, input_routes
, rd
="100.100.100.100:100"
434 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
439 "Configure RD for vrf BLUE manually same as vrf RED "
440 "(100.100.100.100:100) and advertise vrf RED and BLUE's routes "
441 "in EVPN address family from Edge-1 router."
451 "l2vpn": {"evpn": {"rd": "100.100.100.100:100"}}
458 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
459 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
462 "Delete manually configured RD and advertise vrf RED's routes "
463 "in EVPN address family from Edge-1 router."
473 "l2vpn": {"evpn": {"no rd": "100.100.100.100:100"}}
480 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
481 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
484 "Configure same RD value for vrf GREEN, as auto generated RD "
485 "value for vrf RED on Edge-1 router."
494 "address_family": {"l2vpn": {"evpn": {"rd": "10.0.0.33:1"}}},
500 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
501 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
503 step("Delete auto configured RD value from vrf RED in EVPN " "address family.")
511 "address_family": {"l2vpn": {"evpn": {"no rd": "10.0.0.33:1"}}},
517 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
518 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
520 step("Configure RD value as 100.100.100:100")
528 "address_family": {"l2vpn": {"evpn": {"rd": "100.100.100:100"}}},
534 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
535 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
537 write_test_footer(tc_name
)
540 def test_RT_verification_manual_p0(request
):
542 RT verification(manual)
546 tc_name
= request
.node
.name
547 write_test_header(tc_name
)
548 check_router_status(tgen
)
549 reset_config_on_routers(tgen
)
550 add_default_routes(tgen
)
552 if tgen
.routers_have_failure():
553 pytest
.skip(tgen
.errors
)
556 "Advertise prefixes from VNF routers R1 and R2 in associated "
557 "VRFs for both address-family."
559 step("Advertise VRF routes as in EVPN address family from Edge-1 " "router.")
561 for addr_type
in ADDR_TYPES
:
566 "network": NETWORK1_1
[addr_type
],
567 "next_hop": NEXT_HOP_IP
[addr_type
],
575 "network": NETWORK2_1
[addr_type
],
576 "next_hop": NEXT_HOP_IP
[addr_type
],
580 "network": NETWORK3_1
[addr_type
],
581 "next_hop": NEXT_HOP_IP
[addr_type
],
588 result
= create_static_routes(tgen
, input_dict_1
)
589 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
594 "Configure RT for vrf RED manually as export 100:100 "
595 "and advertise vrf RED's routes in EVPN address family"
596 " from Edge-1 router."
607 "unicast": {"neighbor": {"r1": {"dest_link": {"e1": {}}}}}
610 "unicast": {"neighbor": {"r1": {"dest_link": {"e1": {}}}}}
613 "evpn": {"route-target": {"export": [{"value": "100:100"}]}}
621 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
622 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
625 "Verify on dcg-1 and dcg-2, EVPN route for 10.1.1.1/32"
626 " and 10::1/128 have RT value as 100:100."
629 for dut
in ["d1", "d2"]:
630 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
631 result
= verify_attributes_for_evpn_routes(
632 tgen
, topo
, dut
, input_routes
, rt
="100:100"
634 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
639 "Configure RT for vrf RED manually as export 500:500 and"
640 " advertise vrf RED's routes in EVPN address family from"
652 "evpn": {"route-target": {"export": [{"value": "500:500"}]}}
660 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
661 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
664 "Verify on dcg-1 and dcg-2, EVPN route for 10.1.1.1/32"
665 " and 10::1/128 have RT value as 500:500."
668 for dut
in ["d1", "d2"]:
669 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
670 result
= verify_attributes_for_evpn_routes(
671 tgen
, topo
, dut
, input_routes
, rt
=["100:100", "500:500"]
673 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
678 "Import RT value 100:100 and 500:500 in vrf BLUE manually on"
679 " peer router DCG-1 and DCG-2."
693 {"value": "100:100"},
694 {"value": "500:500"},
713 {"value": "100:100"},
714 {"value": "500:500"},
725 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
726 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
729 "EVPN route for 10.1.1.1/32 and 10::1 should be installed "
730 "in vrf BLUE on DCG-1 and DCG-2 and further advertised to "
734 for addr_type
in ADDR_TYPES
:
737 "static_routes": [{"network": [NETWORK1_1
[addr_type
]], "vrf": "BLUE"}]
740 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
741 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
743 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
744 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
747 "Delete import RT value 500:500 in vrf BLUE manually on "
748 "peer router DCG-1 and DCG-2."
761 "import": [{"value": "500:500", "delete": True}]
778 "import": [{"value": "500:500", "delete": True}]
788 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
789 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
791 for dut
in ["d1", "d2"]:
792 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
793 result
= verify_attributes_for_evpn_routes(
794 tgen
, topo
, dut
, input_routes
, rt
=["100:100", "500:500"]
796 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
800 step("Delete RT export value 100:100 for vrf RED on Edge-1")
812 "export": [{"value": "100:100", "delete": True}]
822 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
823 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
826 "EVPN route for 10.1.1.1/32 and 10::1 should be withdrawn "
827 "from vrf BLUE on DCG-1,DCG-2 and VNF router."
830 for addr_type
in ADDR_TYPES
:
833 "static_routes": [{"network": [NETWORK1_1
[addr_type
]], "vrf": "BLUE"}]
836 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
, expected
=False)
837 assert result
is not True, (
838 "Testcase {} : Failed \n "
839 "Expected: Routes should not be present in {} RIB \n "
840 "Found: {}".format(tc_name
, "d1", result
)
843 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
844 assert result
is not True, (
845 "Testcase {} : Failed \n "
846 "Expected: Routes should not be present in {} RIB \n "
847 "Found: {}".format(tc_name
, "d2", result
)
851 "Configure RT value as 100:100000010000010000101010 to check "
852 "the boundary value."
866 {"value": "100:100000010000010000101010"}
877 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
878 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
881 "CLI error: RT value: 100:100000010000010000101010 should not " "be configured"
885 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
886 result
= verify_attributes_for_evpn_routes(
887 tgen
, topo
, dut
, input_routes
, rt
="100:100000010000010000101010", expected
=False
889 assert result
is not True, (
890 "Testcase {} : Failed \n "
891 "Expected: RT value out of boundary error in {} \n "
892 "Found: {}".format(tc_name
, dut
, result
)
895 write_test_footer(tc_name
)
898 def test_active_standby_evpn_implementation_p1(request
):
900 In an active/standby EVPN implementation, if active DCG goes down,
901 secondary takes over.
905 tc_name
= request
.node
.name
906 write_test_header(tc_name
)
907 check_router_status(tgen
)
908 reset_config_on_routers(tgen
)
909 add_default_routes(tgen
)
911 if tgen
.routers_have_failure():
912 pytest
.skip(tgen
.errors
)
915 "Taken care in base config: Configure BGP neighborship for both "
916 "address families(IPv4 & IPv6) between DCG-1/DCG-2 and VFN routers"
921 "BGP neighborships come up within defined VRFs. Please use below "
922 "command: sh bgp vrf all summary"
925 result
= verify_bgp_convergence(tgen
, topo
, "d1")
926 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
928 result
= verify_bgp_convergence(tgen
, topo
, "d2")
929 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
932 "Advertise prefixes from VNF routers R3 and R4 in associated "
933 "VRFs for both address-families."
936 for addr_type
in ADDR_TYPES
:
941 "network": NETWORK1_2
[addr_type
],
942 "next_hop": NEXT_HOP_IP
[addr_type
],
950 "network": NETWORK1_3
[addr_type
],
951 "next_hop": NEXT_HOP_IP
[addr_type
],
955 "network": NETWORK1_4
[addr_type
],
956 "next_hop": NEXT_HOP_IP
[addr_type
],
963 result
= create_static_routes(tgen
, input_dict_1
)
964 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
969 "Redistribute static in (IPv4 and IPv6) address-family "
970 "on Edge-1 for all VRFs."
974 for dut
in ["r3", "r4"]:
975 temp
= {dut
: {"bgp": []}}
976 input_dict_2
.update(temp
)
982 VRFS
= ["BLUE", "GREEN"]
985 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
986 temp
[dut
]["bgp"].append(
992 "unicast": {"redistribute": [{"redist_type": "static"}]}
995 "unicast": {"redistribute": [{"redist_type": "static"}]}
1001 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1002 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1004 step("Prefixes are received in respective VRFs on DCG-1/DCG-2.")
1006 for addr_type
in ADDR_TYPES
:
1011 "network": NETWORK1_2
[addr_type
],
1012 "next_hop": NEXT_HOP_IP
[addr_type
],
1020 "network": NETWORK1_3
[addr_type
],
1021 "next_hop": NEXT_HOP_IP
[addr_type
],
1025 "network": NETWORK1_4
[addr_type
],
1026 "next_hop": NEXT_HOP_IP
[addr_type
],
1033 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
1034 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1038 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1039 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1044 "Taken care in base config: Advertise VRF routes in EVPN "
1045 "address-family from DCG-1 and DCG-2 router."
1048 step("Verify on Edge-1 that EVPN routes are installed via next-hop " "as DCG-2.")
1050 for addr_type
in ADDR_TYPES
:
1055 "network": NETWORK1_2
[addr_type
],
1056 "next_hop": NEXT_HOP_IP
[addr_type
],
1064 "network": NETWORK1_3
[addr_type
],
1065 "next_hop": NEXT_HOP_IP
[addr_type
],
1069 "network": NETWORK1_4
[addr_type
],
1070 "next_hop": NEXT_HOP_IP
[addr_type
],
1077 if addr_type
== "ipv4":
1078 result
= verify_rib(
1079 tgen
, addr_type
, "e1", input_routes
, next_hop
=BRIDGE_INTF2
1081 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1085 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
1086 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1091 "Configure 'next-hop self' on DCG-1 for peer Edge-1 in EVPN " "address-family."
1104 "ipv4": {"d1-link1": {"next_hop_self": True}}
1115 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1116 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1119 "Creating route-map so ipv6 glpbal ip wpuld be preferred " "as next-hop"
1123 "Verify on Edge-1 that EVPN routes are now preferred via "
1124 "next-hop as DCG-1(iBGP) due to shortest AS-Path."
1127 for addr_type
in ADDR_TYPES
:
1129 logger
.info("Verifying only ipv4 routes")
1130 if addr_type
!= "ipv4":
1137 "network": NETWORK1_2
[addr_type
],
1138 "next_hop": NEXT_HOP_IP
[addr_type
],
1146 "network": NETWORK1_3
[addr_type
],
1147 "next_hop": NEXT_HOP_IP
[addr_type
],
1151 "network": NETWORK1_4
[addr_type
],
1152 "next_hop": NEXT_HOP_IP
[addr_type
],
1159 next_hop
= topo
["routers"]["d1"]["links"]["e1-link1"]["ipv4"].split("/")[0]
1161 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
, next_hop
=next_hop
)
1162 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1166 write_test_footer(tc_name
)
1169 def test_evpn_routes_from_VNFs_p1(request
):
1171 EVPN routes are advertised/withdrawn, based on VNFs
1172 advertising/withdrawing IP prefixes.
1175 tgen
= get_topogen()
1176 tc_name
= request
.node
.name
1177 write_test_header(tc_name
)
1178 check_router_status(tgen
)
1179 reset_config_on_routers(tgen
)
1180 add_default_routes(tgen
)
1182 if tgen
.routers_have_failure():
1183 pytest
.skip(tgen
.errors
)
1186 "Advertise prefixes from VNF routers R1 and R2 in associated "
1187 "VRFs for both address-family."
1190 for addr_type
in ADDR_TYPES
:
1195 "network": NETWORK1_1
[addr_type
],
1196 "next_hop": NEXT_HOP_IP
[addr_type
],
1204 "network": NETWORK2_1
[addr_type
],
1205 "next_hop": NEXT_HOP_IP
[addr_type
],
1209 "network": NETWORK3_1
[addr_type
],
1210 "next_hop": NEXT_HOP_IP
[addr_type
],
1217 result
= create_static_routes(tgen
, input_dict_1
)
1218 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1223 "Taken care in base config: Advertise VNFs'(R1 and R2) "
1224 "originated routes in EVPN address-family from Edge-1 to "
1225 "DCG-1 and DCG-2 routers."
1228 "Taken care in base config: Advertise IPv4 and IPv6 routes "
1229 "from default vrf in EVPN address-family from Edge-1."
1233 "Verify on DCG-2 that VNF routes are received in respective "
1234 "VRFs along with auto derived RD/RT values 'show bgp l2vpn evpn'"
1236 for dut
in ["d1", "d2"]:
1237 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1238 result
= verify_evpn_routes(tgen
, topo
, dut
, input_routes
)
1239 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
1240 tc_name
, dut
, result
1243 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1244 result
= verify_evpn_routes(tgen
, topo
, dut
, input_routes
)
1245 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
1246 tc_name
, dut
, result
1250 "Verify on R3 and R4 that DCG-2 further advertises all EVPN "
1251 "routes to corresponding VRFs."
1253 for addr_type
in ADDR_TYPES
:
1254 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1255 result
= verify_rib(tgen
, addr_type
, "r3", input_routes
)
1256 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1260 for addr_type
in ADDR_TYPES
:
1261 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1262 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
)
1263 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1268 "Verify that DCG-2 receives EVPN routes associated to default "
1269 "VRF and install in default IP routing table as well."
1271 for addr_type
in ADDR_TYPES
:
1272 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1273 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1274 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1278 for addr_type
in ADDR_TYPES
:
1279 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1280 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1281 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1285 step("Withdraw the IP prefixes from VFN(R1).")
1288 static_routes
= topo
["routers"][dut
]["static_routes"]
1289 for static_route
in static_routes
:
1290 static_route
["delete"] = True
1291 temp
= {dut
: {"static_routes": [static_route
]}}
1292 input_dict_2
.update(temp
)
1294 result
= create_static_routes(tgen
, input_dict_2
)
1295 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1300 "Verify that DCG-2 removes EVPN routes corresponding to vrf RED and "
1301 "send an withdraw to VNF(R3) as well."
1303 for addr_type
in ADDR_TYPES
:
1304 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1305 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
1306 assert result
is not True, (
1307 "Testcase {} : Failed \n "
1308 "Expected: Routes should not be present in {} RIB \n "
1309 "Found: {}".format(tc_name
, "d2", result
)
1312 for addr_type
in ADDR_TYPES
:
1313 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1314 result
= verify_rib(tgen
, addr_type
, "r3", input_routes
, expected
=False)
1315 assert result
is not True, (
1316 "Testcase {} : Failed \n "
1317 "Expected: Routes should not be present in {} RIB \n "
1318 "Found: {}".format(tc_name
, "r3", result
)
1321 step("Re-advertise IP prefixes from VFN(R1).")
1323 "Advertise prefixes from VNF routers R1 and R2 in associated "
1324 "VRFs for both address-family."
1327 for addr_type
in ADDR_TYPES
:
1332 "network": NETWORK1_1
[addr_type
],
1333 "next_hop": NEXT_HOP_IP
[addr_type
],
1341 "network": NETWORK2_1
[addr_type
],
1342 "next_hop": NEXT_HOP_IP
[addr_type
],
1346 "network": NETWORK3_1
[addr_type
],
1347 "next_hop": NEXT_HOP_IP
[addr_type
],
1354 result
= create_static_routes(tgen
, input_dict_1
)
1355 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1360 "Verify that DCG-2 receives EVPN routes corresponding to vrf RED "
1361 "again and send an update to VNF(R3) as well."
1363 for addr_type
in ADDR_TYPES
:
1364 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1365 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1366 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1370 for addr_type
in ADDR_TYPES
:
1371 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1372 result
= verify_rib(tgen
, addr_type
, "r3", input_routes
)
1373 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1377 step("Delete vrf BLUE from router Edge-1")
1378 input_dict_3
= {"e1": {"vrfs": [{"name": "BLUE", "id": "2", "delete": True}]}}
1380 result
= create_vrf_cfg(tgen
, input_dict_3
)
1381 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1384 "Verify that DCG-2 removes EVPN routes corresponding to "
1385 "vrf BLUE and send an withdraw to VNF(R4) as well."
1387 for addr_type
in ADDR_TYPES
:
1389 "r2": {"static_routes": [{"network": NETWORK2_1
[addr_type
], "vrf": "BLUE"}]}
1392 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
1393 assert result
is not True, (
1394 "Testcase {} : Failed \n "
1395 "Expected: Routes should not be present in {} RIB \n "
1396 "Found: {}".format(tc_name
, "d2", result
)
1399 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
, expected
=False)
1400 assert result
is not True, (
1401 "Testcase {} : Failed \n "
1402 "Expected: Routes should not be present in {} RIB \n "
1403 "Found: {}".format(tc_name
, "r4", result
)
1406 step("Add vrf BLUE on router Edge-1 again.")
1407 interface
= topo
["routers"]["e1"]["links"]["r2-link1"]["interface"]
1412 "interface": interface
,
1418 "vrfs": [{"name": "BLUE", "id": "2"}],
1421 result
= create_vrf_cfg(tgen
, input_dict_3
)
1422 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1425 "After deleting VRFs ipv6 addresses wil be deleted "
1426 "from kernel Adding back ipv6 addresses"
1432 for c_link
, c_data
in topo
["routers"][dut
]["links"].items():
1434 if c_data
["vrf"] != vrf
:
1437 intf_name
= c_data
["interface"]
1438 intf_ipv6
= c_data
["ipv6"]
1440 create_interface_in_kernel(
1441 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
1444 result
= verify_bgp_convergence(tgen
, topo
, dut
)
1445 assert result
is True, "Failed to converge on {}".format(dut
)
1448 "Verify that DCG-2 receives EVPN routes corresponding to "
1449 "vrf BLUE again and send an update to VNF(R4) as well."
1451 for addr_type
in ADDR_TYPES
:
1453 "r2": {"static_routes": [{"network": NETWORK2_1
[addr_type
], "vrf": "BLUE"}]}
1456 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1457 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1461 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
)
1462 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1466 step("Withdraw IPv6 address-family in EVPN advertisements for " "VRF GREEN")
1477 "advertise": {addr_type
: {"unicast": {"delete": True}}}
1486 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1487 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1490 "Verify that EVPN routes (IPv6)associated with vrf GREEN are "
1491 "withdrawn from DCG-2 and VNF R4."
1494 "r2": {"static_routes": [{"network": NETWORK3_1
[addr_type
], "vrf": "GREEN"}]}
1497 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
1498 assert result
is not True, (
1499 "Testcase {} : Failed \n "
1500 "Expected: Routes should not be present in {} RIB \n "
1501 "Found: {}".format(tc_name
, "d2", result
)
1504 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
, expected
=False)
1505 assert result
is not True, (
1506 "Testcase {} : Failed \n "
1507 "Expected: Routes should not be present in {} RIB \n "
1508 "Found: {}".format(tc_name
, "r4", result
)
1511 step("Advertise IPv6 address-family in EVPN advertisements " "for VRF GREEN.")
1520 "l2vpn": {"evpn": {"advertise": {addr_type
: {"unicast": {}}}}}
1527 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1528 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1530 for addr_type
in ADDR_TYPES
:
1533 "static_routes": [{"network": NETWORK3_1
[addr_type
], "vrf": "GREEN"}]
1537 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1538 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1542 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
)
1543 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1547 write_test_footer(tc_name
)
1550 @pytest.mark
.parametrize(
1551 "attribute", [{"route-type": "prefix"}, {"vni": VNI_1
}, {"rt": "300:300"}]
1553 def test_route_map_operations_for_evpn_address_family_p1(request
, attribute
):
1555 Route-map operations for EVPN address family.
1558 tgen
= get_topogen()
1559 tc_name
= request
.node
.name
1560 write_test_header(tc_name
)
1561 check_router_status(tgen
)
1562 reset_config_on_routers(tgen
)
1563 add_default_routes(tgen
)
1566 "Advertise prefixes from VNF routers R1 and R2 in associated "
1567 "VRFs for both address-family."
1570 for addr_type
in ADDR_TYPES
:
1575 "network": NETWORK1_1
[addr_type
],
1576 "next_hop": NEXT_HOP_IP
[addr_type
],
1584 "network": NETWORK2_1
[addr_type
],
1585 "next_hop": NEXT_HOP_IP
[addr_type
],
1589 "network": NETWORK3_1
[addr_type
],
1590 "next_hop": NEXT_HOP_IP
[addr_type
],
1597 result
= create_static_routes(tgen
, input_dict_1
)
1598 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1602 if tgen
.routers_have_failure():
1603 pytest
.skip(tgen
.errors
)
1606 "Advertise VRF routes in EVPN address family from Edge-1 router."
1607 " Configure a route-map on e1 to filter EVPN routes based on"
1608 " below keywords: route-type: prefix"
1611 for key
, value
in attribute
.items():
1613 logger
.info("Creating extcommunity using raw_config")
1617 "bgp extcommunity-list standard ECOMM300 permit {} {}".format(
1623 result
= apply_raw_config(tgen
, raw_config
)
1624 assert result
is True, "Testcase {} : Failed Error: {}".format(
1631 "rmap_route_type": [
1632 {"action": "permit", "set": {"extcommunity": {key
: value
}}}
1638 "rmap_route_type": [
1639 {"action": "permit", "match": {"extcommunity": "ECOMM300"}}
1649 "rmap_route_type": [
1650 {"action": "permit", "match": {"evpn": {key
: value
}}}
1656 "rmap_route_type": [
1657 {"action": "permit", "match": {"evpn": {key
: value
}}}
1662 result
= create_route_maps(tgen
, input_dict_1
)
1663 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1681 "name": "rmap_route_type",
1708 "name": "rmap_route_type",
1724 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1725 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1728 "Verify on router DCG-2 that EVPN routes corresponding to all "
1729 "VRFs are received. As all EVPN routes are type-5 only."
1732 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1733 result
= verify_evpn_routes(tgen
, topo
, "d2", input_routes
)
1734 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1736 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1737 result
= verify_evpn_routes(tgen
, topo
, "d2", input_routes
)
1738 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1740 write_test_footer(tc_name
)
1743 def test_evpn_address_family_with_graceful_restart_p0(request
):
1745 Verify Graceful-restart function for EVPN address-family.
1748 tgen
= get_topogen()
1749 tc_name
= request
.node
.name
1750 write_test_header(tc_name
)
1751 check_router_status(tgen
)
1752 reset_config_on_routers(tgen
)
1753 add_default_routes(tgen
)
1755 if tgen
.routers_have_failure():
1756 pytest
.skip(tgen
.errors
)
1758 for addr_type
in ADDR_TYPES
:
1763 "network": NETWORK1_2
[addr_type
],
1764 "next_hop": NEXT_HOP_IP
[addr_type
],
1772 "network": NETWORK1_3
[addr_type
],
1773 "next_hop": NEXT_HOP_IP
[addr_type
],
1777 "network": NETWORK1_4
[addr_type
],
1778 "next_hop": NEXT_HOP_IP
[addr_type
],
1785 result
= create_static_routes(tgen
, input_dict_1
)
1786 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1791 "Redistribute static in (IPv4 and IPv6) address-family "
1792 "on Edge-1 for all VRFs."
1796 for dut
in ["r3", "r4"]:
1797 temp
= {dut
: {"bgp": []}}
1798 input_dict_2
.update(temp
)
1804 VRFS
= ["BLUE", "GREEN"]
1807 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
1808 temp
[dut
]["bgp"].append(
1814 "unicast": {"redistribute": [{"redist_type": "static"}]}
1817 "unicast": {"redistribute": [{"redist_type": "static"}]}
1823 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1824 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1827 "Verify on router Edge-1 that EVPN routes corresponding to "
1828 "all VRFs are received from both routers DCG-1 and DCG-2"
1831 for addr_type
in ADDR_TYPES
:
1836 "network": NETWORK1_2
[addr_type
],
1837 "next_hop": NEXT_HOP_IP
[addr_type
],
1845 "network": NETWORK1_3
[addr_type
],
1846 "next_hop": NEXT_HOP_IP
[addr_type
],
1850 "network": NETWORK1_4
[addr_type
],
1851 "next_hop": NEXT_HOP_IP
[addr_type
],
1858 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
1859 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1864 "Configure DCG-2 as GR restarting node for EVPN session between"
1865 " DCG-2 and EDGE-1, following by a session reset using 'clear bgp *'"
1874 "graceful-restart": {
1875 "graceful-restart": True,
1882 result
= create_router_bgp(tgen
, topo
, input_dict_gr
)
1883 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1886 "Verify that DCG-2 changes it's role to GR-restarting router "
1887 "and EDGE-1 becomes the GR-helper."
1890 step("Kill BGPd daemon on DCG-2.")
1891 kill_router_daemons(tgen
, "d2", ["bgpd"])
1894 "Verify that EDGE-1 keep stale entries for EVPN RT-5 routes "
1895 "received from DCG-2 before the restart."
1898 for addr_type
in ADDR_TYPES
:
1903 "network": NETWORK1_3
[addr_type
],
1904 "next_hop": NEXT_HOP_IP
[addr_type
],
1908 "network": NETWORK1_4
[addr_type
],
1909 "next_hop": NEXT_HOP_IP
[addr_type
],
1915 result
= verify_evpn_routes(tgen
, topo
, "e1", input_routes
)
1916 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1921 "Verify that DCG-2 keeps BGP routes in Zebra until BGPd "
1922 "comes up or end of 'rib-stale-time'"
1925 step("Start BGPd daemon on DCG-2.")
1926 start_router_daemons(tgen
, "d2", ["bgpd"])
1928 step("Verify that EDGE-1 removed all the stale entries.")
1929 for addr_type
in ADDR_TYPES
:
1934 "network": NETWORK1_3
[addr_type
],
1935 "next_hop": NEXT_HOP_IP
[addr_type
],
1939 "network": NETWORK1_4
[addr_type
],
1940 "next_hop": NEXT_HOP_IP
[addr_type
],
1946 result
= verify_evpn_routes(tgen
, topo
, "e1", input_routes
)
1947 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1952 "Verify that DCG-2 refresh zebra with EVPN routes. "
1953 "(no significance of 'rib-stale-time'"
1956 for addr_type
in ADDR_TYPES
:
1961 "network": NETWORK1_3
[addr_type
],
1962 "next_hop": NEXT_HOP_IP
[addr_type
],
1966 "network": NETWORK1_4
[addr_type
],
1967 "next_hop": NEXT_HOP_IP
[addr_type
],
1973 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1974 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1978 write_test_footer(tc_name
)
1981 @pytest.mark
.parametrize("attribute", ["locPrf", "weight", "path"])
1982 def test_bgp_attributes_for_evpn_address_family_p1(request
, attribute
):
1984 BGP attributes for EVPN address-family.
1987 tgen
= get_topogen()
1988 tc_name
= request
.node
.name
1989 write_test_header(tc_name
)
1990 check_router_status(tgen
)
1991 reset_config_on_routers(tgen
)
1992 add_default_routes(tgen
)
1994 if tgen
.routers_have_failure():
1995 pytest
.skip(tgen
.errors
)
1998 "Advertise prefixes from VNF routers R1 and R2 in associated "
1999 "VRFs for both address-family."
2002 for addr_type
in ADDR_TYPES
:
2007 "network": NETWORK1_1
[addr_type
],
2008 "next_hop": NEXT_HOP_IP
[addr_type
],
2016 "network": NETWORK2_1
[addr_type
],
2017 "next_hop": NEXT_HOP_IP
[addr_type
],
2021 "network": NETWORK3_1
[addr_type
],
2022 "next_hop": NEXT_HOP_IP
[addr_type
],
2029 result
= create_static_routes(tgen
, input_dict_1
)
2030 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2034 topo_local
= deepcopy(topo
)
2036 logger
.info("Modifying topology b/w e1 and d1 from iBGP to eBGP")
2037 step("Delete BGP config for vrf RED.")
2039 if attribute
== "locPrf":
2043 {"name": "RED", "no_vni": VNI_1
},
2044 {"name": "BLUE", "no_vni": VNI_2
},
2045 {"name": "GREEN", "no_vni": VNI_3
},
2049 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
2050 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
2056 temp
= {dut
: {"bgp": []}}
2057 input_dict_2
.update(temp
)
2059 INDEX
= [0, 1, 2, 3]
2060 VRFS
= ["RED", "BLUE", "GREEN", None]
2061 AS_NUM
= [100, 100, 100, 100]
2063 for index
, vrf
, as_num
in zip(INDEX
, VRFS
, AS_NUM
):
2064 topo_local
["routers"][dut
]["bgp"][index
]["local_as"] = 200
2066 temp
[dut
]["bgp"].append(
2067 {"local_as": as_num
, "vrf": vrf
, "delete": True}
2070 temp
[dut
]["bgp"].append({"local_as": as_num
, "delete": True})
2072 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
2073 assert result
is True, "Testcase {} on d1 :Failed \n Error: {}".format(
2077 result
= create_router_bgp(tgen
, topo_local
["routers"])
2078 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
2082 step("Advertise VRF routes in EVPN address-family from DCG-1 " "and DCG-2 routers.")
2084 for addr_type
in ADDR_TYPES
:
2089 "network": NETWORK1_2
[addr_type
],
2090 "next_hop": NEXT_HOP_IP
[addr_type
],
2098 "network": NETWORK1_3
[addr_type
],
2099 "next_hop": NEXT_HOP_IP
[addr_type
],
2103 "network": NETWORK1_4
[addr_type
],
2104 "next_hop": NEXT_HOP_IP
[addr_type
],
2111 result
= create_static_routes(tgen
, input_dict_1
)
2112 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2117 "Redistribute static in (IPv4 and IPv6) address-family "
2118 "on Edge-1 for all VRFs."
2122 for dut
in ["r3", "r4"]:
2123 temp
= {dut
: {"bgp": []}}
2124 input_dict_2
.update(temp
)
2130 VRFS
= ["BLUE", "GREEN"]
2133 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2134 temp
[dut
]["bgp"].append(
2140 "unicast": {"redistribute": [{"redist_type": "static"}]}
2143 "unicast": {"redistribute": [{"redist_type": "static"}]}
2149 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
2150 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2153 "Verify on router Edge-1 that EVPN routes corresponding to "
2154 "all VRFs are received from both routers DCG-1 and DCG-2"
2157 for addr_type
in ADDR_TYPES
:
2162 "network": NETWORK1_2
[addr_type
],
2163 "next_hop": NEXT_HOP_IP
[addr_type
],
2171 "network": NETWORK1_3
[addr_type
],
2172 "next_hop": NEXT_HOP_IP
[addr_type
],
2176 "network": NETWORK1_4
[addr_type
],
2177 "next_hop": NEXT_HOP_IP
[addr_type
],
2184 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
2185 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
2190 "Configure a route-map on Edge-1 to modify below BGP attributes "
2191 "for EVPN address-family:"
2194 if attribute
== "path":
2203 "as_num": "123 231 321",
2204 "as_action": "prepend",
2213 attribute
: {"as_num": "121", "as_action": "prepend"}
2224 "rmap_d1": [{"action": "permit", "set": {attribute
: 120}}],
2225 "rmap_d2": [{"action": "permit", "set": {attribute
: 150}}],
2229 result
= create_route_maps(tgen
, input_dict_1
)
2230 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2274 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
2275 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2278 "Verify on router Edge-1 that EVPN routes are preferred via"
2279 " DCG-1 or DCG-2 based on best path selection criteria "
2280 "(according to the configured BGP attribute values in route-map)."
2283 for addr_type
in ADDR_TYPES
:
2288 "network": NETWORK1_2
[addr_type
],
2289 "next_hop": NEXT_HOP_IP
[addr_type
],
2297 "network": NETWORK1_3
[addr_type
],
2298 "next_hop": NEXT_HOP_IP
[addr_type
],
2302 "network": NETWORK1_4
[addr_type
],
2303 "next_hop": NEXT_HOP_IP
[addr_type
],
2310 result
= verify_best_path_as_per_bgp_attribute(
2311 tgen
, addr_type
, "e1", input_routes
, attribute
2313 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2317 write_test_footer(tc_name
)
2320 if __name__
== "__main__":
2321 args
= ["-s"] + sys
.argv
[1:]
2322 sys
.exit(pytest
.main(args
))