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:
25 1. In absence of an overlay index all IP-Prefixes(RT-5)
26 are advertised with default values for below parameters:
27 --> Ethernet Tag ID = GW IP address = ESI=0
28 2. EVPN CLI output and JSON format validation.
29 3. RT verification(auto)
37 from copy
import deepcopy
40 # Save the Current Working Directory to find configuration files.
41 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
42 sys
.path
.append(os
.path
.join(CWD
, "../"))
43 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
45 # Required to instantiate the topology builder class.
47 # pylint: disable=C0413
48 # Import topogen and topotest helpers
49 from lib
.topotest
import version_cmp
50 from lib
.topogen
import Topogen
, get_topogen
52 from lib
.common_config
import (
57 reset_config_on_routers
,
69 from lib
.topolog
import logger
71 verify_bgp_convergence
,
73 verify_attributes_for_evpn_routes
,
75 from lib
.topojson
import build_config_from_json
78 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
80 # Reading the data from JSON File for topology creation
82 TCPDUMP_FILE
= "evpn_log.txt"
83 NETWORK1_1
= {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
84 NETWORK1_2
= {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"}
85 NETWORK1_3
= {"ipv4": "40.1.1.2/32", "ipv6": "40::2/128"}
86 NETWORK1_4
= {"ipv4": "40.1.1.3/32", "ipv6": "40::3/128"}
87 NETWORK2_1
= {"ipv4": "20.1.1.1/32", "ipv6": "20::1/128"}
88 NETWORK3_1
= {"ipv4": "30.1.1.1/32", "ipv6": "30::1/128"}
89 NETWORK4_1
= {"ipv4": "100.1.1.1/32 ", "ipv6": "100::100/128"}
90 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
94 MAC_1
= "00:80:48:ba:d1:00"
95 MAC_2
= "00:80:48:ba:d1:01"
96 MAC_3
= "00:80:48:ba:d1:02"
100 VXLAN_1
= "vxlan75100"
101 VXLAN_2
= "vxlan75200"
102 VXLAN_3
= "vxlan75300"
103 BRIDGE_INTF1
= "120.0.0.1"
104 BRIDGE_INTF2
= "120.0.0.2"
105 BRIDGE_INTF3
= "120.0.0.3"
106 MULTICAST_MAC1
= "01:00:5e:00:52:02"
109 "vxlan_name": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
110 "vxlan_id": [75100, 75200, 75300],
112 "local_addr": {"e1": BRIDGE_INTF1
, "d1": BRIDGE_INTF2
, "d2": BRIDGE_INTF3
},
116 "brctl_name": [BRCTL_1
, BRCTL_2
, BRCTL_3
],
117 "addvxlan": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
118 "vrf": ["RED", "BLUE", "GREEN"],
123 def setup_module(mod
):
125 Sets up the pytest environment
130 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
131 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
132 logger
.info("=" * 40)
134 logger
.info("Running setup_module to create topology")
136 # This function initiates the topology build with Topogen...
137 json_file
= "{}/evpn_type5_chaos_topo1.json".format(CWD
)
138 tgen
= Topogen(json_file
, mod
.__name
__)
140 topo
= tgen
.json_topo
141 # ... and here it calls Mininet initialization functions.
143 # Starting topology, create tmp files which are loaded to routers
144 # to start daemons and then start routers
147 # Creating configuration from JSON
148 build_config_from_json(tgen
, topo
)
150 if version_cmp(platform
.release(), "4.19") < 0:
152 'EVPN tests will not run (have kernel "{}", '
153 "but it requires >= 4.19)".format(platform
.release())
155 pytest
.skip(error_msg
)
157 global BGP_CONVERGENCE
159 ADDR_TYPES
= check_address_types()
161 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
162 assert BGP_CONVERGENCE
is True, "setup_module :Failed \n Error: {}".format(
166 logger
.info("Pre-requisite config for testsuite")
167 prerequisite_config_for_test_suite(tgen
)
169 logger
.info("Running setup_module() done")
172 def teardown_module():
173 """Teardown the pytest environment"""
175 logger
.info("Running teardown_module to delete topology")
179 # Stop toplogy and Remove tmp files
183 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
185 logger
.info("=" * 40)
188 #####################################################
192 #####################################################
195 def prerequisite_config_for_test_suite(tgen
):
197 API to do prerequisite config for testsuite
201 * `tgen`: topogen object
204 step("Configure vxlan, bridge interface")
205 for dut
in ["e1", "d1", "d2"]:
206 step("[DUT: ]Configure vxlan")
211 "vxlan_name": VXLAN
["vxlan_name"],
212 "vxlan_id": VXLAN
["vxlan_id"],
213 "dstport": VXLAN
["dstport"],
214 "local_addr": VXLAN
["local_addr"][dut
],
215 "learning": VXLAN
["learning"],
221 result
= configure_vxlan(tgen
, vxlan_input
)
222 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
224 step("Configure bridge interface")
229 "brctl_name": BRCTL
["brctl_name"],
230 "addvxlan": BRCTL
["addvxlan"],
237 result
= configure_brctl(tgen
, topo
, brctl_input
)
238 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
240 step("Configure default routes")
241 add_default_routes(tgen
)
244 def add_default_routes(tgen
):
246 API to do prerequisite config for testsuite
250 * `tgen`: topogen object
253 step("Add default routes..")
259 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
260 "next_hop": topo
["routers"]["d1"]["links"]["e1-link1"][
265 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
266 "next_hop": topo
["routers"]["d2"]["links"]["e1-link1"][
275 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
276 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
281 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
282 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
291 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
292 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
297 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
298 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
306 result
= create_static_routes(tgen
, default_routes
)
307 assert result
is True, "Testcase :Failed \n Error: {}".format(result
)
310 def test_verify_overlay_index_p1(request
):
312 In absence of an overlay index all IP-Prefixes(RT-5)
313 are advertised with default values for below parameters:
314 --> Ethernet Tag ID = GW IP address = ESI=0
318 tc_name
= request
.node
.name
319 write_test_header(tc_name
)
320 check_router_status(tgen
)
321 reset_config_on_routers(tgen
)
322 add_default_routes(tgen
)
324 if tgen
.routers_have_failure():
325 pytest
.skip(tgen
.errors
)
327 step("Following steps are taken care in base config:")
329 "Configure BGP neighborship for both address families"
330 "(IPv4 & IPv6) between Edge-1 and VFN routers(R1 and R2)"
333 "Advertise prefixes from VNF routers R1 and R2 in associated "
334 "VRFs for both address-family."
336 step("Advertise VRF routes as in EVPN address family from Edge-1 " "router.")
338 for addr_type
in ADDR_TYPES
:
343 "network": NETWORK1_1
[addr_type
],
344 "next_hop": NEXT_HOP_IP
[addr_type
],
352 "network": NETWORK2_1
[addr_type
],
353 "next_hop": NEXT_HOP_IP
[addr_type
],
357 "network": NETWORK3_1
[addr_type
],
358 "next_hop": NEXT_HOP_IP
[addr_type
],
365 result
= create_static_routes(tgen
, input_dict_1
)
366 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
370 step("Verify: Prefixes are received in all VRFs on Edge-1 router.")
372 for addr_type
in ADDR_TYPES
:
373 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
374 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
375 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
379 for addr_type
in ADDR_TYPES
:
380 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
381 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
382 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
387 "Verify that EVPN routes, received on DCG-1 and DCG-2 do not "
388 "carry any overlay index and these indexes are set to default "
392 for addr_type
in ADDR_TYPES
:
393 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
395 result
= verify_attributes_for_evpn_routes(
396 tgen
, topo
, "d1", input_routes
, ethTag
=0
398 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
402 result
= verify_attributes_for_evpn_routes(
403 tgen
, topo
, "d2", input_routes
, ethTag
=0
405 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
409 write_test_footer(tc_name
)
412 def test_evpn_cli_json_available_p1(request
):
414 EVPN CLI output and JSON format validation.
418 tc_name
= request
.node
.name
419 write_test_header(tc_name
)
420 check_router_status(tgen
)
421 reset_config_on_routers(tgen
)
422 add_default_routes(tgen
)
424 if tgen
.routers_have_failure():
425 pytest
.skip(tgen
.errors
)
427 step("Need to verify below CLIs and associated JSON format " "outputs:")
432 "show evpn vni detail",
433 "show bgp l2vpn evpn all overlay",
434 "show bgp l2vpn evpn vni",
439 result
= verify_cli_json(tgen
, input_dict
)
440 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
442 write_test_footer(tc_name
)
445 def test_RT_verification_auto_p0(request
):
447 RT verification(auto)
451 tc_name
= request
.node
.name
452 write_test_header(tc_name
)
453 check_router_status(tgen
)
454 reset_config_on_routers(tgen
)
455 add_default_routes(tgen
)
457 if tgen
.routers_have_failure():
458 pytest
.skip(tgen
.errors
)
461 "Advertise overlapping prefixes from VNFs R1 and R2 in all VRFs "
462 "RED, GREEN and BLUE 100.1.1.1/32 and 100::100/128"
465 for addr_type
in ADDR_TYPES
:
470 "network": NETWORK4_1
[addr_type
],
471 "next_hop": NEXT_HOP_IP
[addr_type
],
479 "network": NETWORK4_1
[addr_type
],
480 "next_hop": NEXT_HOP_IP
[addr_type
],
484 "network": NETWORK4_1
[addr_type
],
485 "next_hop": NEXT_HOP_IP
[addr_type
],
492 result
= create_static_routes(tgen
, input_dict_1
)
493 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
498 "Verify that Edge-1 receives same prefixes in all 3 VRFs via "
499 "corresponding next-hop in associated VRF sh bgp vrf all"
502 for addr_type
in ADDR_TYPES
:
507 "network": NETWORK4_1
[addr_type
],
508 "next_hop": NEXT_HOP_IP
[addr_type
],
516 "network": NETWORK4_1
[addr_type
],
517 "next_hop": NEXT_HOP_IP
[addr_type
],
521 "network": NETWORK4_1
[addr_type
],
522 "next_hop": NEXT_HOP_IP
[addr_type
],
529 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
530 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
535 "Configure 4-byte local AS number on Edge-1 and establish EVPN "
536 "neighborship with DCG-1 & DCG-2."
539 topo_local
= deepcopy(topo
)
541 step("Delete BGP config for vrf RED.")
546 {"name": "RED", "no_vni": VNI_1
},
547 {"name": "BLUE", "no_vni": VNI_2
},
548 {"name": "GREEN", "no_vni": VNI_3
},
552 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
553 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
557 temp
= {dut
: {"bgp": []}}
558 input_dict_2
.update(temp
)
561 VRFS
= ["RED", "BLUE", "GREEN", None]
562 AS_NUM
= [100, 100, 100, 100]
564 for index
, vrf
, as_num
in zip(INDEX
, VRFS
, AS_NUM
):
565 topo_local
["routers"][dut
]["bgp"][index
]["local_as"] = 4294967293
567 temp
[dut
]["bgp"].append(
568 {"local_as": as_num
, "vrf": vrf
, "delete": True}
571 temp
[dut
]["bgp"].append({"local_as": as_num
, "delete": True})
573 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
574 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
576 result
= create_router_bgp(tgen
, topo_local
["routers"])
577 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
582 {"name": "RED", "vni": VNI_1
},
583 {"name": "BLUE", "vni": VNI_2
},
584 {"name": "GREEN", "vni": VNI_3
},
588 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
589 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
592 "Verify that all overlapping prefixes across different VRFs are "
593 "advertised in EVPN with unique RD value(auto derived)."
596 "Verify that FRR uses only the lower 2 bytes of ASN+VNI for auto "
600 for addr_type
in ADDR_TYPES
:
602 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
605 "r2": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "BLUE"}]}
609 "static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "GREEN"}]
613 result
= verify_attributes_for_evpn_routes(
614 tgen
, topo
, "e1", input_routes_1
, rd
="auto", rd_peer
="e1"
616 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
620 result
= verify_attributes_for_evpn_routes(
621 tgen
, topo
, "e1", input_routes_1
, rt
="auto", rt_peer
="e1"
623 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
627 result
= verify_attributes_for_evpn_routes(
628 tgen
, topo
, "e1", input_routes_2
, rd
="auto", rd_peer
="e1"
630 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
634 result
= verify_attributes_for_evpn_routes(
635 tgen
, topo
, "e1", input_routes_2
, rt
="auto", rt_peer
="e1"
637 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
641 result
= verify_attributes_for_evpn_routes(
642 tgen
, topo
, "e1", input_routes_3
, rd
="auto", rd_peer
="e1"
644 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
648 result
= verify_attributes_for_evpn_routes(
649 tgen
, topo
, "e1", input_routes_3
, rt
="auto", rt_peer
="e1"
651 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
656 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
657 " from EVPN address-family to respective VRFs."
660 "Verify if DCG-2(eBGP peer) automatically imports the prefixes "
661 "from EVPN address-family to respective VRFs or not."
664 for addr_type
in ADDR_TYPES
:
669 "network": NETWORK4_1
[addr_type
],
670 "next_hop": NEXT_HOP_IP
[addr_type
],
678 "network": NETWORK4_1
[addr_type
],
679 "next_hop": NEXT_HOP_IP
[addr_type
],
683 "network": NETWORK4_1
[addr_type
],
684 "next_hop": NEXT_HOP_IP
[addr_type
],
691 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
692 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
696 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
697 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
702 "Change the VNI number for all 3 VRFs on Edge-1 as:"
703 "RED : 75400, GREEN: 75500, BLUE: 75600"
709 {"name": "RED", "no_vni": VNI_1
},
710 {"name": "BLUE", "no_vni": VNI_2
},
711 {"name": "GREEN", "no_vni": VNI_3
},
715 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
716 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
721 {"name": "RED", "vni": 75400},
722 {"name": "BLUE", "vni": 75500},
723 {"name": "GREEN", "vni": 75600},
727 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
728 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
730 step("Delete configured vxlan")
736 "vxlan_name": VXLAN
["vxlan_name"],
737 "vxlan_id": VXLAN
["vxlan_id"],
738 "dstport": VXLAN
["dstport"],
739 "local_addr": VXLAN
["local_addr"][dut
],
740 "learning": VXLAN
["learning"],
747 result
= configure_vxlan(tgen
, vxlan_input
)
748 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
750 step("Configured vxlan")
751 VXLAN
["vxlan_id"] = [75400, 75500, 75600]
756 "vxlan_name": VXLAN
["vxlan_name"],
757 "vxlan_id": VXLAN
["vxlan_id"],
758 "dstport": VXLAN
["dstport"],
759 "local_addr": VXLAN
["local_addr"][dut
],
760 "learning": VXLAN
["learning"],
766 result
= configure_vxlan(tgen
, vxlan_input
)
767 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
769 step("Configure bridge interface")
774 "brctl_name": BRCTL
["brctl_name"],
775 "addvxlan": BRCTL
["addvxlan"],
782 result
= configure_brctl(tgen
, topo
, brctl_input
)
783 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
786 "Verify on Edge-1 that auto derived RT value has changed for "
787 "each VRF based on VNI number.."
793 {"RED": {"vni": 75400}},
794 {"BLUE": {"vni": 75500}},
795 {"GREEN": {"vni": 75600}},
800 result
= verify_vrf_vni(tgen
, input_dict
)
801 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
804 "Verify on Edge-1 that auto derived RT value has changed for "
805 "each VRF based on VNI number."
808 for addr_type
in ADDR_TYPES
:
810 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
813 result
= verify_attributes_for_evpn_routes(
814 tgen
, topo
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
816 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
821 "Verify on DCG-2 that prefixes are not imported from EVPN "
822 "address-family to VRFs as RT values are different on sending("
823 "edge-1) and receiving(DCG-2) end."
826 for addr_type
in ADDR_TYPES
:
828 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
831 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
832 assert result
is not True, (
833 "Testcase {} : Failed \n "
834 "Expected: Routes should not be present in {} RIB \n "
835 "Found: {}".format(tc_name
, "d2", result
)
839 "Revert back to original VNI number for all 3 VRFs on Edge-1 "
840 "as: RED : 75100, GREEN: 75200, BLUE: 75300"
846 {"name": "RED", "no_vni": 75400},
847 {"name": "BLUE", "no_vni": 75500},
848 {"name": "GREEN", "no_vni": 75600},
852 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
853 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
858 {"name": "RED", "vni": VNI_1
},
859 {"name": "BLUE", "vni": VNI_2
},
860 {"name": "GREEN", "vni": VNI_3
},
864 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
865 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
867 step("Delete configured vxlan")
873 "vxlan_name": VXLAN
["vxlan_name"],
874 "vxlan_id": VXLAN
["vxlan_id"],
875 "dstport": VXLAN
["dstport"],
876 "local_addr": VXLAN
["local_addr"][dut
],
877 "learning": VXLAN
["learning"],
883 result
= configure_vxlan(tgen
, vxlan_input
)
884 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
886 step("Configured vxlan")
887 VXLAN
["vxlan_id"] = [75100, 75200, 75300]
892 "vxlan_name": VXLAN
["vxlan_name"],
893 "vxlan_id": VXLAN
["vxlan_id"],
894 "dstport": VXLAN
["dstport"],
895 "local_addr": VXLAN
["local_addr"][dut
],
896 "learning": VXLAN
["learning"],
901 result
= configure_vxlan(tgen
, vxlan_input
)
902 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
904 step("Configure bridge interface")
909 "brctl_name": BRCTL
["brctl_name"],
910 "addvxlan": BRCTL
["addvxlan"],
917 result
= configure_brctl(tgen
, topo
, brctl_input
)
918 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
921 "Verify on Edge-1 that auto derived RT value has changed for "
922 "each VRF based on VNI number."
925 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
926 " from EVPN address-family to respective VRFs."
929 for addr_type
in ADDR_TYPES
:
931 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
934 result
= verify_attributes_for_evpn_routes(
935 tgen
, topo
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
937 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
941 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
942 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
946 step("Test with smaller VNI numbers (1-75000)")
948 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": VNI_1
}]}}
949 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
950 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
952 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "vni": 111}]}}
953 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
954 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
957 "Verify that DCG-2 receives EVPN prefixes along with auto "
958 "derived RT values(based on smaller VNI numbers)"
961 for addr_type
in ADDR_TYPES
:
963 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
966 result
= verify_attributes_for_evpn_routes(
967 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
969 assert result
is not True, (
970 "Testcase {} : Failed \n "
971 "Expected: Malformed Auto-RT value should not be accepted in {} \n "
972 "Found: {}".format(tc_name
, "d2", result
)
975 step("Configure VNI number more than boundary limit (16777215)")
977 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 111}]}}
978 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
979 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
981 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "vni": 16777215}]}}
982 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
983 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
985 step("CLI error for malformed VNI.")
988 "vrfs": [{"RED": {"vni": 16777215, "routerMac": "None", "state": "Down"}}]
992 result
= verify_vrf_vni(tgen
, input_dict
)
993 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
995 for addr_type
in ADDR_TYPES
:
997 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
1000 result
= verify_attributes_for_evpn_routes(
1001 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
1003 assert result
is not True, (
1004 "Testcase {} : Failed \n "
1005 "Expected: Malformed Auto-RT value should not be accepted in {} \n "
1006 "Found: {}".format(tc_name
, "d2", result
)
1009 step("Un-configure VNI number more than boundary limit (16777215)")
1011 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 16777215}]}}
1012 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1013 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1015 write_test_footer(tc_name
)
1018 if __name__
== "__main__":
1019 args
= ["-s"] + sys
.argv
[1:]
1020 sys
.exit(pytest
.main(args
))