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 EVPN-Type5 functionality:
26 1. RD verification (manual/auto).
27 2. RT verification(manual)
28 3. In an active/standby EVPN implementation, if active DCG goes down,
30 4. EVPN routes are advertised/withdrawn, based on VNFs
31 advertising/withdrawing IP prefixes.
32 5. Route-map operations for EVPN address family.
33 6. BGP attributes for EVPN address-family.
42 from copy
import deepcopy
45 # Save the Current Working Directory to find configuration files.
46 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
47 sys
.path
.append(os
.path
.join(CWD
, "../"))
48 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
50 # Required to instantiate the topology builder class.
52 # pylint: disable=C0413
53 # Import topogen and topotest helpers
54 from lib
.topotest
import version_cmp
55 from lib
.topogen
import Topogen
, get_topogen
57 from lib
.common_config
import (
62 reset_config_on_routers
,
72 create_interface_in_kernel
,
77 from lib
.topolog
import logger
79 verify_bgp_convergence
,
81 verify_best_path_as_per_bgp_attribute
,
82 verify_attributes_for_evpn_routes
,
85 from lib
.topojson
import build_topo_from_json
, build_config_from_json
87 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
90 NETWORK1_1
= {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
91 NETWORK1_2
= {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"}
92 NETWORK1_3
= {"ipv4": "40.1.1.2/32", "ipv6": "40::2/128"}
93 NETWORK1_4
= {"ipv4": "40.1.1.3/32", "ipv6": "40::3/128"}
94 NETWORK2_1
= {"ipv4": "20.1.1.1/32", "ipv6": "20::1/128"}
95 NETWORK3_1
= {"ipv4": "30.1.1.1/32", "ipv6": "30::1/128"}
96 NETWORK4_1
= {"ipv4": "100.1.1.1/32 ", "ipv6": "100::100/128"}
97 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
101 MAC_1
= "00:80:48:ba:d1:00"
102 MAC_2
= "00:80:48:ba:d1:01"
103 MAC_3
= "00:80:48:ba:d1:02"
107 VXLAN_1
= "vxlan75100"
108 VXLAN_2
= "vxlan75200"
109 VXLAN_3
= "vxlan75300"
110 BRIDGE_INTF1
= "120.0.0.1"
111 BRIDGE_INTF2
= "120.0.0.2"
112 BRIDGE_INTF3
= "120.0.0.3"
115 "vxlan_name": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
116 "vxlan_id": [75100, 75200, 75300],
118 "local_addr": {"e1": BRIDGE_INTF1
, "d1": BRIDGE_INTF2
, "d2": BRIDGE_INTF3
},
122 "brctl_name": [BRCTL_1
, BRCTL_2
, BRCTL_3
],
123 "addvxlan": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
124 "vrf": ["RED", "BLUE", "GREEN"],
129 def setup_module(mod
):
131 Sets up the pytest environment
137 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
138 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
139 logger
.info("=" * 40)
141 logger
.info("Running setup_module to create topology")
143 # This function initiates the topology build with Topogen...
144 json_file
= "{}/evpn_type5_topo1.json".format(CWD
)
145 tgen
= Topogen(json_file
, mod
.__name
__)
146 topo
= tgen
.json_topo
148 # ... and here it calls Mininet initialization functions.
150 # Starting topology, create tmp files which are loaded to routers
151 # to start daemons and then start routers
154 # Creating configuration from JSON
155 build_config_from_json(tgen
, topo
)
157 if version_cmp(platform
.release(), "4.19") < 0:
159 'EVPN tests will not run (have kernel "{}", '
160 "but it requires >= 4.19)".format(platform
.release())
162 pytest
.skip(error_msg
)
164 global BGP_CONVERGENCE
166 ADDR_TYPES
= check_address_types()
168 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
169 assert BGP_CONVERGENCE
is True, "setup_module :Failed \n Error: {}".format(
173 logger
.info("Pre-requisite config for testsuite")
174 prerequisite_config_for_test_suite(tgen
)
176 logger
.info("Running setup_module() done")
179 def teardown_module():
180 """Teardown the pytest environment"""
182 logger
.info("Running teardown_module to delete topology")
186 # Stop toplogy and Remove tmp files
190 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
192 logger
.info("=" * 40)
195 #####################################################
199 #####################################################
202 def prerequisite_config_for_test_suite(tgen
):
204 API to do prerequisite config for testsuite
208 * `tgen`: topogen object
211 step("Configure vxlan, bridge interface")
212 for dut
in ["e1", "d1", "d2"]:
213 step("[DUT: ]Configure vxlan")
218 "vxlan_name": VXLAN
["vxlan_name"],
219 "vxlan_id": VXLAN
["vxlan_id"],
220 "dstport": VXLAN
["dstport"],
221 "local_addr": VXLAN
["local_addr"][dut
],
222 "learning": VXLAN
["learning"],
228 result
= configure_vxlan(tgen
, vxlan_input
)
229 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
231 step("Configure bridge interface")
236 "brctl_name": BRCTL
["brctl_name"],
237 "addvxlan": BRCTL
["addvxlan"],
244 result
= configure_brctl(tgen
, topo
, brctl_input
)
245 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
247 step("Configure default routes")
248 add_default_routes(tgen
)
251 def add_default_routes(tgen
):
253 API to do prerequisite config for testsuite
257 * `tgen`: topogen object
260 step("Add default routes..")
266 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
267 "next_hop": topo
["routers"]["d1"]["links"]["e1-link1"][
272 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
273 "next_hop": topo
["routers"]["d2"]["links"]["e1-link1"][
282 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
283 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
288 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
289 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
298 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
299 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
304 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
305 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
313 result
= create_static_routes(tgen
, default_routes
)
314 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
317 def test_RD_verification_manual_and_auto_p0(request
):
319 RD verification (manual/auto).
323 tc_name
= request
.node
.name
324 write_test_header(tc_name
)
325 check_router_status(tgen
)
326 reset_config_on_routers(tgen
)
327 add_default_routes(tgen
)
329 if tgen
.routers_have_failure():
330 pytest
.skip(tgen
.errors
)
333 "Advertise prefixes from VNF routers R1 and R2 in associated "
334 "VRFs for both address-family."
337 "Advertise vrf RED's routes in EVPN address family from Edge-1 router"
338 ", without manual configuration of RD."
341 for addr_type
in ADDR_TYPES
:
346 "network": NETWORK1_1
[addr_type
],
347 "next_hop": NEXT_HOP_IP
[addr_type
],
355 "network": NETWORK2_1
[addr_type
],
356 "next_hop": NEXT_HOP_IP
[addr_type
],
360 "network": NETWORK3_1
[addr_type
],
361 "next_hop": NEXT_HOP_IP
[addr_type
],
368 result
= create_static_routes(tgen
, input_dict_1
)
369 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
373 step("Verify on DCG-1 and DCG-2:")
374 step("EVPN route for 10.1.1.1/32 has auto-assigned RD value.")
376 for dut
in ["d1", "d2"]:
377 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
378 result
= verify_attributes_for_evpn_routes(
379 tgen
, topo
, dut
, input_routes
, rd
="auto", rd_peer
="e1"
381 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
386 "Configure RD for vrf RED manually as 50.50.50.50:50 and "
387 "advertise vrf RED's routes in EVPN address family from "
397 "address_family": {"l2vpn": {"evpn": {"rd": "50.50.50.50:50"}}},
403 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
404 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
406 step("EVPN route for vrf RED has RD value as 50.50.50.50:50")
407 for dut
in ["d1", "d2"]:
408 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
409 result
= verify_attributes_for_evpn_routes(
410 tgen
, topo
, dut
, input_routes
, rd
="50.50.50.50:50"
412 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
417 "Configure RD for vrf RED manually as 100.100.100.100:100 and "
418 "advertise vrf RED's routes in EVPN address family from Edge-1 "
428 "l2vpn": {"evpn": {"rd": "100.100.100.100:100"}}
435 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
436 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
439 "EVPN route for vrf RED is overridden with RD value as " "100.100.100.100:100."
442 for dut
in ["d1", "d2"]:
443 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
444 result
= verify_attributes_for_evpn_routes(
445 tgen
, topo
, dut
, input_routes
, rd
="100.100.100.100:100"
447 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
452 "Configure RD for vrf BLUE manually same as vrf RED "
453 "(100.100.100.100:100) and advertise vrf RED and BLUE's routes "
454 "in EVPN address family from Edge-1 router."
464 "l2vpn": {"evpn": {"rd": "100.100.100.100:100"}}
471 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
472 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
475 "Delete manually configured RD and advertise vrf RED's routes "
476 "in EVPN address family from Edge-1 router."
486 "l2vpn": {"evpn": {"no rd": "100.100.100.100:100"}}
493 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
494 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
497 "Configure same RD value for vrf GREEN, as auto generated RD "
498 "value for vrf RED on Edge-1 router."
507 "address_family": {"l2vpn": {"evpn": {"rd": "10.0.0.33:1"}}},
513 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
514 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
516 step("Delete auto configured RD value from vrf RED in EVPN " "address family.")
524 "address_family": {"l2vpn": {"evpn": {"no rd": "10.0.0.33:1"}}},
530 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
531 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
533 step("Configure RD value as 100.100.100:100")
541 "address_family": {"l2vpn": {"evpn": {"rd": "100.100.100:100"}}},
547 result
= create_router_bgp(tgen
, topo
, input_dict_rd
)
548 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
550 write_test_footer(tc_name
)
553 def test_RT_verification_manual_p0(request
):
555 RT verification(manual)
559 tc_name
= request
.node
.name
560 write_test_header(tc_name
)
561 check_router_status(tgen
)
562 reset_config_on_routers(tgen
)
563 add_default_routes(tgen
)
565 if tgen
.routers_have_failure():
566 pytest
.skip(tgen
.errors
)
569 "Advertise prefixes from VNF routers R1 and R2 in associated "
570 "VRFs for both address-family."
572 step("Advertise VRF routes as in EVPN address family from Edge-1 " "router.")
574 for addr_type
in ADDR_TYPES
:
579 "network": NETWORK1_1
[addr_type
],
580 "next_hop": NEXT_HOP_IP
[addr_type
],
588 "network": NETWORK2_1
[addr_type
],
589 "next_hop": NEXT_HOP_IP
[addr_type
],
593 "network": NETWORK3_1
[addr_type
],
594 "next_hop": NEXT_HOP_IP
[addr_type
],
601 result
= create_static_routes(tgen
, input_dict_1
)
602 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
607 "Configure RT for vrf RED manually as export 100:100 "
608 "and advertise vrf RED's routes in EVPN address family"
609 " from Edge-1 router."
620 "unicast": {"neighbor": {"r1": {"dest_link": {"e1": {}}}}}
623 "unicast": {"neighbor": {"r1": {"dest_link": {"e1": {}}}}}
626 "evpn": {"route-target": {"export": [{"value": "100:100"}]}}
634 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
635 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
638 "Verify on dcg-1 and dcg-2, EVPN route for 10.1.1.1/32"
639 " and 10::1/128 have RT value as 100:100."
642 for dut
in ["d1", "d2"]:
643 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
644 result
= verify_attributes_for_evpn_routes(
645 tgen
, topo
, dut
, input_routes
, rt
="100:100"
647 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
652 "Configure RT for vrf RED manually as export 500:500 and"
653 " advertise vrf RED's routes in EVPN address family from"
665 "evpn": {"route-target": {"export": [{"value": "500:500"}]}}
673 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
674 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
677 "Verify on dcg-1 and dcg-2, EVPN route for 10.1.1.1/32"
678 " and 10::1/128 have RT value as 500:500."
681 for dut
in ["d1", "d2"]:
682 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
683 result
= verify_attributes_for_evpn_routes(
684 tgen
, topo
, dut
, input_routes
, rt
=["100:100", "500:500"]
686 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
691 "Import RT value 100:100 and 500:500 in vrf BLUE manually on"
692 " peer router DCG-1 and DCG-2."
706 {"value": "100:100"},
707 {"value": "500:500"},
726 {"value": "100:100"},
727 {"value": "500:500"},
738 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
739 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
742 "EVPN route for 10.1.1.1/32 and 10::1 should be installed "
743 "in vrf BLUE on DCG-1 and DCG-2 and further advertised to "
747 for addr_type
in ADDR_TYPES
:
750 "static_routes": [{"network": [NETWORK1_1
[addr_type
]], "vrf": "BLUE"}]
753 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
754 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
756 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
757 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
760 "Delete import RT value 500:500 in vrf BLUE manually on "
761 "peer router DCG-1 and DCG-2."
774 "import": [{"value": "500:500", "delete": True}]
791 "import": [{"value": "500:500", "delete": True}]
801 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
802 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
804 for dut
in ["d1", "d2"]:
805 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
806 result
= verify_attributes_for_evpn_routes(
807 tgen
, topo
, dut
, input_routes
, rt
=["100:100", "500:500"]
809 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
813 step("Delete RT export value 100:100 for vrf RED on Edge-1")
825 "export": [{"value": "100:100", "delete": True}]
835 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
836 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
839 "EVPN route for 10.1.1.1/32 and 10::1 should be withdrawn "
840 "from vrf BLUE on DCG-1,DCG-2 and VNF router."
843 for addr_type
in ADDR_TYPES
:
846 "static_routes": [{"network": [NETWORK1_1
[addr_type
]], "vrf": "BLUE"}]
849 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
, expected
=False)
850 assert result
is not True, (
851 "Testcase {} : Failed \n "
852 "Expected: Routes should not be present in {} RIB \n "
853 "Found: {}".format(tc_name
, "d1", result
)
856 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
857 assert result
is not True, (
858 "Testcase {} : Failed \n "
859 "Expected: Routes should not be present in {} RIB \n "
860 "Found: {}".format(tc_name
, "d2", result
)
864 "Configure RT value as 100:100000010000010000101010 to check "
865 "the boundary value."
879 {"value": "100:100000010000010000101010"}
890 result
= create_router_bgp(tgen
, topo
, input_dict_rt
)
891 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
894 "CLI error: RT value: 100:100000010000010000101010 should not " "be configured"
898 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
899 result
= verify_attributes_for_evpn_routes(
900 tgen
, topo
, dut
, input_routes
, rt
="100:100000010000010000101010", expected
=False
902 assert result
is not True, (
903 "Testcase {} : Failed \n "
904 "Expected: RT value out of boundary error in {} \n "
905 "Found: {}".format(tc_name
, dut
, result
)
908 write_test_footer(tc_name
)
911 def test_active_standby_evpn_implementation_p1(request
):
913 In an active/standby EVPN implementation, if active DCG goes down,
914 secondary takes over.
918 tc_name
= request
.node
.name
919 write_test_header(tc_name
)
920 check_router_status(tgen
)
921 reset_config_on_routers(tgen
)
922 add_default_routes(tgen
)
924 if tgen
.routers_have_failure():
925 pytest
.skip(tgen
.errors
)
928 "Taken care in base config: Configure BGP neighborship for both "
929 "address families(IPv4 & IPv6) between DCG-1/DCG-2 and VFN routers"
934 "BGP neighborships come up within defined VRFs. Please use below "
935 "command: sh bgp vrf all summary"
938 result
= verify_bgp_convergence(tgen
, topo
, "d1")
939 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
941 result
= verify_bgp_convergence(tgen
, topo
, "d2")
942 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
945 "Advertise prefixes from VNF routers R3 and R4 in associated "
946 "VRFs for both address-families."
949 for addr_type
in ADDR_TYPES
:
954 "network": NETWORK1_2
[addr_type
],
955 "next_hop": NEXT_HOP_IP
[addr_type
],
963 "network": NETWORK1_3
[addr_type
],
964 "next_hop": NEXT_HOP_IP
[addr_type
],
968 "network": NETWORK1_4
[addr_type
],
969 "next_hop": NEXT_HOP_IP
[addr_type
],
976 result
= create_static_routes(tgen
, input_dict_1
)
977 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
982 "Redistribute static in (IPv4 and IPv6) address-family "
983 "on Edge-1 for all VRFs."
987 for dut
in ["r3", "r4"]:
988 temp
= {dut
: {"bgp": []}}
989 input_dict_2
.update(temp
)
995 VRFS
= ["BLUE", "GREEN"]
998 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
999 temp
[dut
]["bgp"].append(
1005 "unicast": {"redistribute": [{"redist_type": "static"}]}
1008 "unicast": {"redistribute": [{"redist_type": "static"}]}
1014 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1015 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1017 step("Prefixes are received in respective VRFs on DCG-1/DCG-2.")
1019 for addr_type
in ADDR_TYPES
:
1024 "network": NETWORK1_2
[addr_type
],
1025 "next_hop": NEXT_HOP_IP
[addr_type
],
1033 "network": NETWORK1_3
[addr_type
],
1034 "next_hop": NEXT_HOP_IP
[addr_type
],
1038 "network": NETWORK1_4
[addr_type
],
1039 "next_hop": NEXT_HOP_IP
[addr_type
],
1046 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
1047 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1051 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1052 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1057 "Taken care in base config: Advertise VRF routes in EVPN "
1058 "address-family from DCG-1 and DCG-2 router."
1061 step("Verify on Edge-1 that EVPN routes are installed via next-hop " "as DCG-2.")
1063 for addr_type
in ADDR_TYPES
:
1068 "network": NETWORK1_2
[addr_type
],
1069 "next_hop": NEXT_HOP_IP
[addr_type
],
1077 "network": NETWORK1_3
[addr_type
],
1078 "next_hop": NEXT_HOP_IP
[addr_type
],
1082 "network": NETWORK1_4
[addr_type
],
1083 "next_hop": NEXT_HOP_IP
[addr_type
],
1090 if addr_type
== "ipv4":
1091 result
= verify_rib(
1092 tgen
, addr_type
, "e1", input_routes
, next_hop
=BRIDGE_INTF2
1094 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1098 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
1099 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1104 "Configure 'next-hop self' on DCG-1 for peer Edge-1 in EVPN " "address-family."
1117 "ipv4": {"d1-link1": {"next_hop_self": True}}
1128 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1129 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1132 "Creating route-map so ipv6 glpbal ip wpuld be preferred " "as next-hop"
1136 "Verify on Edge-1 that EVPN routes are now preferred via "
1137 "next-hop as DCG-1(iBGP) due to shortest AS-Path."
1140 for addr_type
in ADDR_TYPES
:
1142 logger
.info("Verifying only ipv4 routes")
1143 if addr_type
!= "ipv4":
1150 "network": NETWORK1_2
[addr_type
],
1151 "next_hop": NEXT_HOP_IP
[addr_type
],
1159 "network": NETWORK1_3
[addr_type
],
1160 "next_hop": NEXT_HOP_IP
[addr_type
],
1164 "network": NETWORK1_4
[addr_type
],
1165 "next_hop": NEXT_HOP_IP
[addr_type
],
1172 next_hop
= topo
["routers"]["d1"]["links"]["e1-link1"]["ipv4"].split("/")[0]
1174 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
, next_hop
=next_hop
)
1175 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1179 write_test_footer(tc_name
)
1182 def test_evpn_routes_from_VNFs_p1(request
):
1184 EVPN routes are advertised/withdrawn, based on VNFs
1185 advertising/withdrawing IP prefixes.
1188 tgen
= get_topogen()
1189 tc_name
= request
.node
.name
1190 write_test_header(tc_name
)
1191 check_router_status(tgen
)
1192 reset_config_on_routers(tgen
)
1193 add_default_routes(tgen
)
1195 if tgen
.routers_have_failure():
1196 pytest
.skip(tgen
.errors
)
1199 "Advertise prefixes from VNF routers R1 and R2 in associated "
1200 "VRFs for both address-family."
1203 for addr_type
in ADDR_TYPES
:
1208 "network": NETWORK1_1
[addr_type
],
1209 "next_hop": NEXT_HOP_IP
[addr_type
],
1217 "network": NETWORK2_1
[addr_type
],
1218 "next_hop": NEXT_HOP_IP
[addr_type
],
1222 "network": NETWORK3_1
[addr_type
],
1223 "next_hop": NEXT_HOP_IP
[addr_type
],
1230 result
= create_static_routes(tgen
, input_dict_1
)
1231 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1236 "Taken care in base config: Advertise VNFs'(R1 and R2) "
1237 "originated routes in EVPN address-family from Edge-1 to "
1238 "DCG-1 and DCG-2 routers."
1241 "Taken care in base config: Advertise IPv4 and IPv6 routes "
1242 "from default vrf in EVPN address-family from Edge-1."
1246 "Verify on DCG-2 that VNF routes are received in respective "
1247 "VRFs along with auto derived RD/RT values 'show bgp l2vpn evpn'"
1249 for dut
in ["d1", "d2"]:
1250 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1251 result
= verify_evpn_routes(tgen
, topo
, dut
, input_routes
)
1252 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
1253 tc_name
, dut
, result
1256 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1257 result
= verify_evpn_routes(tgen
, topo
, dut
, input_routes
)
1258 assert result
is True, "Testcase {} on {} :Failed \n Error: {}".format(
1259 tc_name
, dut
, result
1263 "Verify on R3 and R4 that DCG-2 further advertises all EVPN "
1264 "routes to corresponding VRFs."
1266 for addr_type
in ADDR_TYPES
:
1267 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1268 result
= verify_rib(tgen
, addr_type
, "r3", input_routes
)
1269 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1273 for addr_type
in ADDR_TYPES
:
1274 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1275 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
)
1276 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1281 "Verify that DCG-2 receives EVPN routes associated to default "
1282 "VRF and install in default IP routing table as well."
1284 for addr_type
in ADDR_TYPES
:
1285 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1286 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1287 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1291 for addr_type
in ADDR_TYPES
:
1292 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1293 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1294 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1298 step("Withdraw the IP prefixes from VFN(R1).")
1301 static_routes
= topo
["routers"][dut
]["static_routes"]
1302 for static_route
in static_routes
:
1303 static_route
["delete"] = True
1304 temp
= {dut
: {"static_routes": [static_route
]}}
1305 input_dict_2
.update(temp
)
1307 result
= create_static_routes(tgen
, input_dict_2
)
1308 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1313 "Verify that DCG-2 removes EVPN routes corresponding to vrf RED and "
1314 "send an withdraw to VNF(R3) as well."
1316 for addr_type
in ADDR_TYPES
:
1317 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1318 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
1319 assert result
is not True, (
1320 "Testcase {} : Failed \n "
1321 "Expected: Routes should not be present in {} RIB \n "
1322 "Found: {}".format(tc_name
, "d2", result
)
1325 for addr_type
in ADDR_TYPES
:
1326 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1327 result
= verify_rib(tgen
, addr_type
, "r3", input_routes
, expected
=False)
1328 assert result
is not True, (
1329 "Testcase {} : Failed \n "
1330 "Expected: Routes should not be present in {} RIB \n "
1331 "Found: {}".format(tc_name
, "r3", result
)
1334 step("Re-advertise IP prefixes from VFN(R1).")
1336 "Advertise prefixes from VNF routers R1 and R2 in associated "
1337 "VRFs for both address-family."
1340 for addr_type
in ADDR_TYPES
:
1345 "network": NETWORK1_1
[addr_type
],
1346 "next_hop": NEXT_HOP_IP
[addr_type
],
1354 "network": NETWORK2_1
[addr_type
],
1355 "next_hop": NEXT_HOP_IP
[addr_type
],
1359 "network": NETWORK3_1
[addr_type
],
1360 "next_hop": NEXT_HOP_IP
[addr_type
],
1367 result
= create_static_routes(tgen
, input_dict_1
)
1368 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1373 "Verify that DCG-2 receives EVPN routes corresponding to vrf RED "
1374 "again and send an update to VNF(R3) as well."
1376 for addr_type
in ADDR_TYPES
:
1377 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1378 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1379 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1383 for addr_type
in ADDR_TYPES
:
1384 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1385 result
= verify_rib(tgen
, addr_type
, "r3", input_routes
)
1386 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1390 step("Delete vrf BLUE from router Edge-1")
1391 input_dict_3
= {"e1": {"vrfs": [{"name": "BLUE", "id": "2", "delete": True}]}}
1393 result
= create_vrf_cfg(tgen
, input_dict_3
)
1394 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1397 "Verify that DCG-2 removes EVPN routes corresponding to "
1398 "vrf BLUE and send an withdraw to VNF(R4) as well."
1400 for addr_type
in ADDR_TYPES
:
1402 "r2": {"static_routes": [{"network": NETWORK2_1
[addr_type
], "vrf": "BLUE"}]}
1405 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
1406 assert result
is not True, (
1407 "Testcase {} : Failed \n "
1408 "Expected: Routes should not be present in {} RIB \n "
1409 "Found: {}".format(tc_name
, "d2", result
)
1412 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
, expected
=False)
1413 assert result
is not True, (
1414 "Testcase {} : Failed \n "
1415 "Expected: Routes should not be present in {} RIB \n "
1416 "Found: {}".format(tc_name
, "r4", result
)
1419 step("Add vrf BLUE on router Edge-1 again.")
1420 interface
= topo
["routers"]["e1"]["links"]["r2-link1"]["interface"]
1425 "interface": interface
,
1431 "vrfs": [{"name": "BLUE", "id": "2"}],
1434 result
= create_vrf_cfg(tgen
, input_dict_3
)
1435 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1438 "After deleting VRFs ipv6 addresses wil be deleted "
1439 "from kernel Adding back ipv6 addresses"
1445 for c_link
, c_data
in topo
["routers"][dut
]["links"].items():
1447 if c_data
["vrf"] != vrf
:
1450 intf_name
= c_data
["interface"]
1451 intf_ipv6
= c_data
["ipv6"]
1453 create_interface_in_kernel(
1454 tgen
, dut
, intf_name
, intf_ipv6
, vrf
, create
=False
1457 result
= verify_bgp_convergence(tgen
, topo
, dut
)
1458 assert result
is True, "Failed to converge on {}".format(dut
)
1461 "Verify that DCG-2 receives EVPN routes corresponding to "
1462 "vrf BLUE again and send an update to VNF(R4) as well."
1464 for addr_type
in ADDR_TYPES
:
1466 "r2": {"static_routes": [{"network": NETWORK2_1
[addr_type
], "vrf": "BLUE"}]}
1469 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1470 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1474 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
)
1475 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1479 step("Withdraw IPv6 address-family in EVPN advertisements for " "VRF GREEN")
1490 "advertise": {addr_type
: {"unicast": {"delete": True}}}
1499 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1500 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1503 "Verify that EVPN routes (IPv6)associated with vrf GREEN are "
1504 "withdrawn from DCG-2 and VNF R4."
1507 "r2": {"static_routes": [{"network": NETWORK3_1
[addr_type
], "vrf": "GREEN"}]}
1510 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
1511 assert result
is not True, (
1512 "Testcase {} : Failed \n "
1513 "Expected: Routes should not be present in {} RIB \n "
1514 "Found: {}".format(tc_name
, "d2", result
)
1517 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
, expected
=False)
1518 assert result
is not True, (
1519 "Testcase {} : Failed \n "
1520 "Expected: Routes should not be present in {} RIB \n "
1521 "Found: {}".format(tc_name
, "r4", result
)
1524 step("Advertise IPv6 address-family in EVPN advertisements " "for VRF GREEN.")
1533 "l2vpn": {"evpn": {"advertise": {addr_type
: {"unicast": {}}}}}
1540 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
1541 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1543 for addr_type
in ADDR_TYPES
:
1546 "static_routes": [{"network": NETWORK3_1
[addr_type
], "vrf": "GREEN"}]
1550 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1551 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1555 result
= verify_rib(tgen
, addr_type
, "r4", input_routes
)
1556 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1560 write_test_footer(tc_name
)
1563 @pytest.mark
.parametrize(
1564 "attribute", [{"route-type": "prefix"}, {"vni": VNI_1
}, {"rt": "300:300"}]
1566 def test_route_map_operations_for_evpn_address_family_p1(request
, attribute
):
1568 Route-map operations for EVPN address family.
1571 tgen
= get_topogen()
1572 tc_name
= request
.node
.name
1573 write_test_header(tc_name
)
1574 check_router_status(tgen
)
1575 reset_config_on_routers(tgen
)
1576 add_default_routes(tgen
)
1579 "Advertise prefixes from VNF routers R1 and R2 in associated "
1580 "VRFs for both address-family."
1583 for addr_type
in ADDR_TYPES
:
1588 "network": NETWORK1_1
[addr_type
],
1589 "next_hop": NEXT_HOP_IP
[addr_type
],
1597 "network": NETWORK2_1
[addr_type
],
1598 "next_hop": NEXT_HOP_IP
[addr_type
],
1602 "network": NETWORK3_1
[addr_type
],
1603 "next_hop": NEXT_HOP_IP
[addr_type
],
1610 result
= create_static_routes(tgen
, input_dict_1
)
1611 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1615 if tgen
.routers_have_failure():
1616 pytest
.skip(tgen
.errors
)
1619 "Advertise VRF routes in EVPN address family from Edge-1 router."
1620 " Configure a route-map on e1 to filter EVPN routes based on"
1621 " below keywords: route-type: prefix"
1624 for key
, value
in attribute
.items():
1626 logger
.info("Creating extcommunity using raw_config")
1630 "bgp extcommunity-list standard ECOMM300 permit {} {}".format(
1636 result
= apply_raw_config(tgen
, raw_config
)
1637 assert result
is True, "Testcase {} : Failed Error: {}".format(
1644 "rmap_route_type": [
1645 {"action": "permit", "set": {"extcommunity": {key
: value
}}}
1651 "rmap_route_type": [
1652 {"action": "permit", "match": {"extcommunity": "ECOMM300"}}
1662 "rmap_route_type": [
1663 {"action": "permit", "match": {"evpn": {key
: value
}}}
1669 "rmap_route_type": [
1670 {"action": "permit", "match": {"evpn": {key
: value
}}}
1675 result
= create_route_maps(tgen
, input_dict_1
)
1676 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1694 "name": "rmap_route_type",
1721 "name": "rmap_route_type",
1737 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1738 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1741 "Verify on router DCG-2 that EVPN routes corresponding to all "
1742 "VRFs are received. As all EVPN routes are type-5 only."
1745 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
1746 result
= verify_evpn_routes(tgen
, topo
, "d2", input_routes
)
1747 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1749 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
1750 result
= verify_evpn_routes(tgen
, topo
, "d2", input_routes
)
1751 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1753 write_test_footer(tc_name
)
1756 def test_evpn_address_family_with_graceful_restart_p0(request
):
1758 Verify Graceful-restart function for EVPN address-family.
1761 tgen
= get_topogen()
1762 tc_name
= request
.node
.name
1763 write_test_header(tc_name
)
1764 check_router_status(tgen
)
1765 reset_config_on_routers(tgen
)
1766 add_default_routes(tgen
)
1768 if tgen
.routers_have_failure():
1769 pytest
.skip(tgen
.errors
)
1771 for addr_type
in ADDR_TYPES
:
1776 "network": NETWORK1_2
[addr_type
],
1777 "next_hop": NEXT_HOP_IP
[addr_type
],
1785 "network": NETWORK1_3
[addr_type
],
1786 "next_hop": NEXT_HOP_IP
[addr_type
],
1790 "network": NETWORK1_4
[addr_type
],
1791 "next_hop": NEXT_HOP_IP
[addr_type
],
1798 result
= create_static_routes(tgen
, input_dict_1
)
1799 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1804 "Redistribute static in (IPv4 and IPv6) address-family "
1805 "on Edge-1 for all VRFs."
1809 for dut
in ["r3", "r4"]:
1810 temp
= {dut
: {"bgp": []}}
1811 input_dict_2
.update(temp
)
1817 VRFS
= ["BLUE", "GREEN"]
1820 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
1821 temp
[dut
]["bgp"].append(
1827 "unicast": {"redistribute": [{"redist_type": "static"}]}
1830 "unicast": {"redistribute": [{"redist_type": "static"}]}
1836 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
1837 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1840 "Verify on router Edge-1 that EVPN routes corresponding to "
1841 "all VRFs are received from both routers DCG-1 and DCG-2"
1844 for addr_type
in ADDR_TYPES
:
1849 "network": NETWORK1_2
[addr_type
],
1850 "next_hop": NEXT_HOP_IP
[addr_type
],
1858 "network": NETWORK1_3
[addr_type
],
1859 "next_hop": NEXT_HOP_IP
[addr_type
],
1863 "network": NETWORK1_4
[addr_type
],
1864 "next_hop": NEXT_HOP_IP
[addr_type
],
1871 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
1872 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1877 "Configure DCG-2 as GR restarting node for EVPN session between"
1878 " DCG-2 and EDGE-1, following by a session reset using 'clear bgp *'"
1887 "graceful-restart": {
1888 "graceful-restart": True,
1895 result
= create_router_bgp(tgen
, topo
, input_dict_gr
)
1896 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1899 "Verify that DCG-2 changes it's role to GR-restarting router "
1900 "and EDGE-1 becomes the GR-helper."
1903 step("Kill BGPd daemon on DCG-2.")
1904 kill_router_daemons(tgen
, "d2", ["bgpd"])
1907 "Verify that EDGE-1 keep stale entries for EVPN RT-5 routes "
1908 "received from DCG-2 before the restart."
1911 for addr_type
in ADDR_TYPES
:
1916 "network": NETWORK1_3
[addr_type
],
1917 "next_hop": NEXT_HOP_IP
[addr_type
],
1921 "network": NETWORK1_4
[addr_type
],
1922 "next_hop": NEXT_HOP_IP
[addr_type
],
1928 result
= verify_evpn_routes(tgen
, topo
, "e1", input_routes
)
1929 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1934 "Verify that DCG-2 keeps BGP routes in Zebra until BGPd "
1935 "comes up or end of 'rib-stale-time'"
1938 step("Start BGPd daemon on DCG-2.")
1939 start_router_daemons(tgen
, "d2", ["bgpd"])
1941 step("Verify that EDGE-1 removed all the stale entries.")
1942 for addr_type
in ADDR_TYPES
:
1947 "network": NETWORK1_3
[addr_type
],
1948 "next_hop": NEXT_HOP_IP
[addr_type
],
1952 "network": NETWORK1_4
[addr_type
],
1953 "next_hop": NEXT_HOP_IP
[addr_type
],
1959 result
= verify_evpn_routes(tgen
, topo
, "e1", input_routes
)
1960 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1965 "Verify that DCG-2 refresh zebra with EVPN routes. "
1966 "(no significance of 'rib-stale-time'"
1969 for addr_type
in ADDR_TYPES
:
1974 "network": NETWORK1_3
[addr_type
],
1975 "next_hop": NEXT_HOP_IP
[addr_type
],
1979 "network": NETWORK1_4
[addr_type
],
1980 "next_hop": NEXT_HOP_IP
[addr_type
],
1986 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
1987 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
1991 write_test_footer(tc_name
)
1994 @pytest.mark
.parametrize("attribute", ["locPrf", "weight", "path"])
1995 def test_bgp_attributes_for_evpn_address_family_p1(request
, attribute
):
1997 BGP attributes for EVPN address-family.
2000 tgen
= get_topogen()
2001 tc_name
= request
.node
.name
2002 write_test_header(tc_name
)
2003 check_router_status(tgen
)
2004 reset_config_on_routers(tgen
)
2005 add_default_routes(tgen
)
2007 if tgen
.routers_have_failure():
2008 pytest
.skip(tgen
.errors
)
2011 "Advertise prefixes from VNF routers R1 and R2 in associated "
2012 "VRFs for both address-family."
2015 for addr_type
in ADDR_TYPES
:
2020 "network": NETWORK1_1
[addr_type
],
2021 "next_hop": NEXT_HOP_IP
[addr_type
],
2029 "network": NETWORK2_1
[addr_type
],
2030 "next_hop": NEXT_HOP_IP
[addr_type
],
2034 "network": NETWORK3_1
[addr_type
],
2035 "next_hop": NEXT_HOP_IP
[addr_type
],
2042 result
= create_static_routes(tgen
, input_dict_1
)
2043 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2047 topo_local
= deepcopy(topo
)
2049 logger
.info("Modifying topology b/w e1 and d1 from iBGP to eBGP")
2050 step("Delete BGP config for vrf RED.")
2052 if attribute
== "locPrf":
2056 {"name": "RED", "no_vni": VNI_1
},
2057 {"name": "BLUE", "no_vni": VNI_2
},
2058 {"name": "GREEN", "no_vni": VNI_3
},
2062 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
2063 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
2069 temp
= {dut
: {"bgp": []}}
2070 input_dict_2
.update(temp
)
2072 INDEX
= [0, 1, 2, 3]
2073 VRFS
= ["RED", "BLUE", "GREEN", None]
2074 AS_NUM
= [100, 100, 100, 100]
2076 for index
, vrf
, as_num
in zip(INDEX
, VRFS
, AS_NUM
):
2077 topo_local
["routers"][dut
]["bgp"][index
]["local_as"] = 200
2079 temp
[dut
]["bgp"].append(
2080 {"local_as": as_num
, "vrf": vrf
, "delete": True}
2083 temp
[dut
]["bgp"].append({"local_as": as_num
, "delete": True})
2085 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
2086 assert result
is True, "Testcase {} on d1 :Failed \n Error: {}".format(
2090 result
= create_router_bgp(tgen
, topo_local
["routers"])
2091 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
2095 step("Advertise VRF routes in EVPN address-family from DCG-1 " "and DCG-2 routers.")
2097 for addr_type
in ADDR_TYPES
:
2102 "network": NETWORK1_2
[addr_type
],
2103 "next_hop": NEXT_HOP_IP
[addr_type
],
2111 "network": NETWORK1_3
[addr_type
],
2112 "next_hop": NEXT_HOP_IP
[addr_type
],
2116 "network": NETWORK1_4
[addr_type
],
2117 "next_hop": NEXT_HOP_IP
[addr_type
],
2124 result
= create_static_routes(tgen
, input_dict_1
)
2125 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2130 "Redistribute static in (IPv4 and IPv6) address-family "
2131 "on Edge-1 for all VRFs."
2135 for dut
in ["r3", "r4"]:
2136 temp
= {dut
: {"bgp": []}}
2137 input_dict_2
.update(temp
)
2143 VRFS
= ["BLUE", "GREEN"]
2146 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2147 temp
[dut
]["bgp"].append(
2153 "unicast": {"redistribute": [{"redist_type": "static"}]}
2156 "unicast": {"redistribute": [{"redist_type": "static"}]}
2162 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
2163 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2166 "Verify on router Edge-1 that EVPN routes corresponding to "
2167 "all VRFs are received from both routers DCG-1 and DCG-2"
2170 for addr_type
in ADDR_TYPES
:
2175 "network": NETWORK1_2
[addr_type
],
2176 "next_hop": NEXT_HOP_IP
[addr_type
],
2184 "network": NETWORK1_3
[addr_type
],
2185 "next_hop": NEXT_HOP_IP
[addr_type
],
2189 "network": NETWORK1_4
[addr_type
],
2190 "next_hop": NEXT_HOP_IP
[addr_type
],
2197 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
2198 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
2203 "Configure a route-map on Edge-1 to modify below BGP attributes "
2204 "for EVPN address-family:"
2207 if attribute
== "path":
2216 "as_num": "123 231 321",
2217 "as_action": "prepend",
2226 attribute
: {"as_num": "121", "as_action": "prepend"}
2237 "rmap_d1": [{"action": "permit", "set": {attribute
: 120}}],
2238 "rmap_d2": [{"action": "permit", "set": {attribute
: 150}}],
2242 result
= create_route_maps(tgen
, input_dict_1
)
2243 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2287 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
2288 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
2291 "Verify on router Edge-1 that EVPN routes are preferred via"
2292 " DCG-1 or DCG-2 based on best path selection criteria "
2293 "(according to the configured BGP attribute values in route-map)."
2296 for addr_type
in ADDR_TYPES
:
2301 "network": NETWORK1_2
[addr_type
],
2302 "next_hop": NEXT_HOP_IP
[addr_type
],
2310 "network": NETWORK1_3
[addr_type
],
2311 "next_hop": NEXT_HOP_IP
[addr_type
],
2315 "network": NETWORK1_4
[addr_type
],
2316 "next_hop": NEXT_HOP_IP
[addr_type
],
2323 result
= verify_best_path_as_per_bgp_attribute(
2324 tgen
, addr_type
, "e1", input_routes
, attribute
2326 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2330 write_test_footer(tc_name
)
2333 if __name__
== "__main__":
2334 args
= ["-s"] + sys
.argv
[1:]
2335 sys
.exit(pytest
.main(args
))