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)
39 from copy
import deepcopy
40 from time
import sleep
43 # Save the Current Working Directory to find configuration files.
44 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
45 sys
.path
.append(os
.path
.join(CWD
, "../"))
46 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
48 # Required to instantiate the topology builder class.
50 # pylint: disable=C0413
51 # Import topogen and topotest helpers
52 from lib
.topotest
import version_cmp
53 from lib
.topogen
import Topogen
, get_topogen
54 from mininet
.topo
import Topo
56 from lib
.common_config
import (
61 reset_config_on_routers
,
68 create_interface_in_kernel
,
77 from lib
.topolog
import logger
79 verify_bgp_convergence
,
82 verify_best_path_as_per_bgp_attribute
,
83 verify_attributes_for_evpn_routes
,
86 from lib
.topojson
import build_topo_from_json
, build_config_from_json
88 pytestmark
= [pytest
.mark
.bgpd
, pytest
.mark
.staticd
]
91 # Reading the data from JSON File for topology creation
92 jsonFile
= "{}/evpn_type5_chaos_topo1.json".format(CWD
)
94 with
open(jsonFile
, "r") as topoJson
:
95 topo
= json
.load(topoJson
)
97 assert False, "Could not read file {}".format(jsonFile
)
99 # Reading the data from JSON File for topology creation
101 TCPDUMP_FILE
= "evpn_log.txt"
102 LOGDIR
= "/tmp/topotests/"
103 NETWORK1_1
= {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
104 NETWORK1_2
= {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"}
105 NETWORK1_3
= {"ipv4": "40.1.1.2/32", "ipv6": "40::2/128"}
106 NETWORK1_4
= {"ipv4": "40.1.1.3/32", "ipv6": "40::3/128"}
107 NETWORK2_1
= {"ipv4": "20.1.1.1/32", "ipv6": "20::1/128"}
108 NETWORK3_1
= {"ipv4": "30.1.1.1/32", "ipv6": "30::1/128"}
109 NETWORK4_1
= {"ipv4": "100.1.1.1/32 ", "ipv6": "100::100/128"}
110 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
114 MAC_1
= "00:80:48:ba:d1:00"
115 MAC_2
= "00:80:48:ba:d1:01"
116 MAC_3
= "00:80:48:ba:d1:02"
120 VXLAN_1
= "vxlan75100"
121 VXLAN_2
= "vxlan75200"
122 VXLAN_3
= "vxlan75300"
123 BRIDGE_INTF1
= "120.0.0.1"
124 BRIDGE_INTF2
= "120.0.0.2"
125 BRIDGE_INTF3
= "120.0.0.3"
126 MULTICAST_MAC1
= "01:00:5e:00:52:02"
129 "vxlan_name": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
130 "vxlan_id": [75100, 75200, 75300],
132 "local_addr": {"e1": BRIDGE_INTF1
, "d1": BRIDGE_INTF2
, "d2": BRIDGE_INTF3
},
136 "brctl_name": [BRCTL_1
, BRCTL_2
, BRCTL_3
],
137 "addvxlan": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
138 "vrf": ["RED", "BLUE", "GREEN"],
143 class CreateTopo(Topo
):
145 Test BasicTopo - topology 1
147 * `Topo`: Topology object
150 def build(self
, *_args
, **_opts
):
152 tgen
= get_topogen(self
)
154 # Building topology from json file
155 build_topo_from_json(tgen
, topo
)
158 def setup_module(mod
):
160 Sets up the pytest environment
166 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
167 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
168 logger
.info("=" * 40)
170 logger
.info("Running setup_module to create topology")
172 # This function initiates the topology build with Topogen...
173 tgen
= Topogen(CreateTopo
, mod
.__name
__)
174 # ... and here it calls Mininet initialization functions.
176 # Starting topology, create tmp files which are loaded to routers
177 # to start deamons and then start routers
180 # Creating configuration from JSON
181 build_config_from_json(tgen
, topo
)
183 if version_cmp(platform
.release(), "4.19") < 0:
185 'EVPN tests will not run (have kernel "{}", '
186 "but it requires >= 4.19)".format(platform
.release())
188 pytest
.skip(error_msg
)
190 global BGP_CONVERGENCE
192 ADDR_TYPES
= check_address_types()
194 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
195 assert BGP_CONVERGENCE
is True, "setup_module :Failed \n Error: {}".format(
199 logger
.info("Pre-requisite config for testsuite")
200 prerequisite_config_for_test_suite(tgen
)
202 logger
.info("Running setup_module() done")
205 def teardown_module():
206 """Teardown the pytest environment"""
208 logger
.info("Running teardown_module to delete topology")
212 # Stop toplogy and Remove tmp files
216 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
218 logger
.info("=" * 40)
221 #####################################################
225 #####################################################
228 def prerequisite_config_for_test_suite(tgen
):
230 API to do prerequisite config for testsuite
234 * `tgen`: topogen object
237 step("Configure vxlan, bridge interface")
238 for dut
in ["e1", "d1", "d2"]:
239 step("[DUT: ]Configure vxlan")
244 "vxlan_name": VXLAN
["vxlan_name"],
245 "vxlan_id": VXLAN
["vxlan_id"],
246 "dstport": VXLAN
["dstport"],
247 "local_addr": VXLAN
["local_addr"][dut
],
248 "learning": VXLAN
["learning"],
254 result
= configure_vxlan(tgen
, vxlan_input
)
255 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
259 step("Configure bridge interface")
264 "brctl_name": BRCTL
["brctl_name"],
265 "addvxlan": BRCTL
["addvxlan"],
272 result
= configure_brctl(tgen
, topo
, brctl_input
)
273 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
277 step("Configure default routes")
278 add_default_routes(tgen
)
281 def add_default_routes(tgen
):
283 API to do prerequisite config for testsuite
287 * `tgen`: topogen object
290 step("Add default routes..")
296 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
297 "next_hop": topo
["routers"]["d1"]["links"]["e1-link1"][
302 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
303 "next_hop": topo
["routers"]["d2"]["links"]["e1-link1"][
312 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
313 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
318 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
319 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
328 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
329 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
334 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
335 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
343 result
= create_static_routes(tgen
, default_routes
)
344 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
347 def test_verify_overlay_index_p1(request
):
349 In absence of an overlay index all IP-Prefixes(RT-5)
350 are advertised with default values for below parameters:
351 --> Ethernet Tag ID = GW IP address = ESI=0
355 tc_name
= request
.node
.name
356 write_test_header(tc_name
)
357 check_router_status(tgen
)
358 reset_config_on_routers(tgen
)
359 add_default_routes(tgen
)
361 if tgen
.routers_have_failure():
362 pytest
.skip(tgen
.errors
)
364 step("Following steps are taken care in base config:")
366 "Configure BGP neighborship for both address families"
367 "(IPv4 & IPv6) between Edge-1 and VFN routers(R1 and R2)"
370 "Advertise prefixes from VNF routers R1 and R2 in associated "
371 "VRFs for both address-family."
373 step("Advertise VRF routes as in EVPN address family from Edge-1 " "router.")
375 for addr_type
in ADDR_TYPES
:
380 "network": NETWORK1_1
[addr_type
],
381 "next_hop": NEXT_HOP_IP
[addr_type
],
389 "network": NETWORK2_1
[addr_type
],
390 "next_hop": NEXT_HOP_IP
[addr_type
],
394 "network": NETWORK3_1
[addr_type
],
395 "next_hop": NEXT_HOP_IP
[addr_type
],
402 result
= create_static_routes(tgen
, input_dict_1
)
403 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
407 step("Verify: Prefixes are received in all VRFs on Edge-1 router.")
409 for addr_type
in ADDR_TYPES
:
410 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
411 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
412 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
416 for addr_type
in ADDR_TYPES
:
417 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
418 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
419 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
424 "Verify that EVPN routes, received on DCG-1 and DCG-2 do not "
425 "carry any overlay index and these indexes are set to default "
429 for addr_type
in ADDR_TYPES
:
430 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
432 result
= verify_attributes_for_evpn_routes(
433 tgen
, topo
, "d1", input_routes
, ethTag
=0
435 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
439 result
= verify_attributes_for_evpn_routes(
440 tgen
, topo
, "d2", input_routes
, ethTag
=0
442 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
446 write_test_footer(tc_name
)
449 def test_evpn_cli_json_available_p1(request
):
451 EVPN CLI output and JSON format validation.
455 tc_name
= request
.node
.name
456 write_test_header(tc_name
)
457 check_router_status(tgen
)
458 reset_config_on_routers(tgen
)
459 add_default_routes(tgen
)
461 if tgen
.routers_have_failure():
462 pytest
.skip(tgen
.errors
)
464 step("Need to verify below CLIs and associated JSON format " "outputs:")
469 "show evpn vni detail",
470 "show bgp l2vpn evpn all overlay",
471 "show bgp l2vpn evpn vni",
476 result
= verify_cli_json(tgen
, input_dict
)
477 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
479 write_test_footer(tc_name
)
482 def test_RT_verification_auto_p0(request
):
484 RT verification(auto)
488 tc_name
= request
.node
.name
489 write_test_header(tc_name
)
490 check_router_status(tgen
)
491 reset_config_on_routers(tgen
)
492 add_default_routes(tgen
)
494 if tgen
.routers_have_failure():
495 pytest
.skip(tgen
.errors
)
498 "Advertise overlapping prefixes from VNFs R1 and R2 in all VRFs "
499 "RED, GREEN and BLUE 100.1.1.1/32 and 100::100/128"
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
= create_static_routes(tgen
, input_dict_1
)
530 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
535 "Verify that Edge-1 receives same prefixes in all 3 VRFs via "
536 "corresponding next-hop in associated VRF sh bgp vrf all"
539 for addr_type
in ADDR_TYPES
:
544 "network": NETWORK4_1
[addr_type
],
545 "next_hop": NEXT_HOP_IP
[addr_type
],
553 "network": NETWORK4_1
[addr_type
],
554 "next_hop": NEXT_HOP_IP
[addr_type
],
558 "network": NETWORK4_1
[addr_type
],
559 "next_hop": NEXT_HOP_IP
[addr_type
],
566 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
567 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
572 "Configure 4-byte local AS number on Edge-1 and establish EVPN "
573 "neighborship with DCG-1 & DCG-2."
576 topo_local
= deepcopy(topo
)
578 step("Delete BGP config for vrf RED.")
583 {"name": "RED", "no_vni": VNI_1
},
584 {"name": "BLUE", "no_vni": VNI_2
},
585 {"name": "GREEN", "no_vni": VNI_3
},
589 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
590 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
594 temp
= {dut
: {"bgp": []}}
595 input_dict_2
.update(temp
)
598 VRFS
= ["RED", "BLUE", "GREEN", None]
599 AS_NUM
= [100, 100, 100, 100]
601 for index
, vrf
, as_num
in zip(INDEX
, VRFS
, AS_NUM
):
602 topo_local
["routers"][dut
]["bgp"][index
]["local_as"] = 4294967293
604 temp
[dut
]["bgp"].append(
605 {"local_as": as_num
, "vrf": vrf
, "delete": True}
608 temp
[dut
]["bgp"].append({"local_as": as_num
, "delete": True})
610 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
611 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
613 result
= create_router_bgp(tgen
, topo_local
["routers"])
614 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
619 {"name": "RED", "vni": VNI_1
},
620 {"name": "BLUE", "vni": VNI_2
},
621 {"name": "GREEN", "vni": VNI_3
},
625 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
626 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
629 "Verify that all overlapping prefixes across different VRFs are "
630 "advertised in EVPN with unique RD value(auto derived)."
633 "Verify that FRR uses only the lower 2 bytes of ASN+VNI for auto "
637 for addr_type
in ADDR_TYPES
:
639 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
642 "r2": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "BLUE"}]}
646 "static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "GREEN"}]
650 result
= verify_attributes_for_evpn_routes(
651 tgen
, topo
, "e1", input_routes_1
, rd
="auto", rd_peer
="e1"
653 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
657 result
= verify_attributes_for_evpn_routes(
658 tgen
, topo
, "e1", input_routes_1
, rt
="auto", rt_peer
="e1"
660 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
664 result
= verify_attributes_for_evpn_routes(
665 tgen
, topo
, "e1", input_routes_2
, rd
="auto", rd_peer
="e1"
667 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
671 result
= verify_attributes_for_evpn_routes(
672 tgen
, topo
, "e1", input_routes_2
, rt
="auto", rt_peer
="e1"
674 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
678 result
= verify_attributes_for_evpn_routes(
679 tgen
, topo
, "e1", input_routes_3
, rd
="auto", rd_peer
="e1"
681 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
685 result
= verify_attributes_for_evpn_routes(
686 tgen
, topo
, "e1", input_routes_3
, rt
="auto", rt_peer
="e1"
688 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
693 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
694 " from EVPN address-family to respective VRFs."
697 "Verify if DCG-2(eBGP peer) automatically imports the prefixes "
698 "from EVPN address-family to respective VRFs or not."
701 for addr_type
in ADDR_TYPES
:
706 "network": NETWORK4_1
[addr_type
],
707 "next_hop": NEXT_HOP_IP
[addr_type
],
715 "network": NETWORK4_1
[addr_type
],
716 "next_hop": NEXT_HOP_IP
[addr_type
],
720 "network": NETWORK4_1
[addr_type
],
721 "next_hop": NEXT_HOP_IP
[addr_type
],
728 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
729 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
733 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
734 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
739 "Change the VNI number for all 3 VRFs on Edge-1 as:"
740 "RED : 75400, GREEN: 75500, BLUE: 75600"
746 {"name": "RED", "no_vni": VNI_1
},
747 {"name": "BLUE", "no_vni": VNI_2
},
748 {"name": "GREEN", "no_vni": VNI_3
},
752 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
753 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
758 {"name": "RED", "vni": 75400},
759 {"name": "BLUE", "vni": 75500},
760 {"name": "GREEN", "vni": 75600},
764 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
765 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
767 step("Delete configured vxlan")
773 "vxlan_name": VXLAN
["vxlan_name"],
774 "vxlan_id": VXLAN
["vxlan_id"],
775 "dstport": VXLAN
["dstport"],
776 "local_addr": VXLAN
["local_addr"][dut
],
777 "learning": VXLAN
["learning"],
784 result
= configure_vxlan(tgen
, vxlan_input
)
785 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
787 step("Configured vxlan")
788 VXLAN
["vxlan_id"] = [75400, 75500, 75600]
793 "vxlan_name": VXLAN
["vxlan_name"],
794 "vxlan_id": VXLAN
["vxlan_id"],
795 "dstport": VXLAN
["dstport"],
796 "local_addr": VXLAN
["local_addr"][dut
],
797 "learning": VXLAN
["learning"],
803 result
= configure_vxlan(tgen
, vxlan_input
)
804 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
806 step("Configure bridge interface")
811 "brctl_name": BRCTL
["brctl_name"],
812 "addvxlan": BRCTL
["addvxlan"],
819 result
= configure_brctl(tgen
, topo
, brctl_input
)
820 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
823 "Verify on Edge-1 that auto derived RT value has changed for "
824 "each VRF based on VNI number.."
830 {"RED": {"vni": 75400}},
831 {"BLUE": {"vni": 75500}},
832 {"GREEN": {"vni": 75600}},
837 result
= verify_vrf_vni(tgen
, input_dict
)
838 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
841 "Verify on Edge-1 that auto derived RT value has changed for "
842 "each VRF based on VNI number."
845 for addr_type
in ADDR_TYPES
:
847 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
850 result
= verify_attributes_for_evpn_routes(
851 tgen
, topo
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
853 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
858 "Verify on DCG-2 that prefixes are not imported from EVPN "
859 "address-family to VRFs as RT values are different on sending("
860 "edge-1) and receiving(DCG-2) end."
863 for addr_type
in ADDR_TYPES
:
865 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
868 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
869 assert result
is not True, "Testcase {} :Failed \n "
870 "Routes are still present: {}".format(tc_name
, result
)
871 logger
.info("Expected Behavior: {}".format(result
))
874 "Revert back to original VNI number for all 3 VRFs on Edge-1 "
875 "as: RED : 75100, GREEN: 75200, BLUE: 75300"
881 {"name": "RED", "no_vni": 75400},
882 {"name": "BLUE", "no_vni": 75500},
883 {"name": "GREEN", "no_vni": 75600},
887 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
888 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
893 {"name": "RED", "vni": VNI_1
},
894 {"name": "BLUE", "vni": VNI_2
},
895 {"name": "GREEN", "vni": VNI_3
},
899 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
900 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
902 step("Delete configured vxlan")
908 "vxlan_name": VXLAN
["vxlan_name"],
909 "vxlan_id": VXLAN
["vxlan_id"],
910 "dstport": VXLAN
["dstport"],
911 "local_addr": VXLAN
["local_addr"][dut
],
912 "learning": VXLAN
["learning"],
918 result
= configure_vxlan(tgen
, vxlan_input
)
919 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
921 step("Configured vxlan")
922 VXLAN
["vxlan_id"] = [75100, 75200, 75300]
927 "vxlan_name": VXLAN
["vxlan_name"],
928 "vxlan_id": VXLAN
["vxlan_id"],
929 "dstport": VXLAN
["dstport"],
930 "local_addr": VXLAN
["local_addr"][dut
],
931 "learning": VXLAN
["learning"],
936 result
= configure_vxlan(tgen
, vxlan_input
)
937 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
939 step("Configure bridge interface")
944 "brctl_name": BRCTL
["brctl_name"],
945 "addvxlan": BRCTL
["addvxlan"],
952 result
= configure_brctl(tgen
, topo
, brctl_input
)
953 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
956 "Verify on Edge-1 that auto derived RT value has changed for "
957 "each VRF based on VNI number."
960 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
961 " from EVPN address-family to respective VRFs."
964 for addr_type
in ADDR_TYPES
:
966 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
969 result
= verify_attributes_for_evpn_routes(
970 tgen
, topo
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
972 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
976 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
977 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
981 step("Test with smaller VNI numbers (1-75000)")
983 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": VNI_1
}]}}
984 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
985 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
987 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "vni": 111}]}}
988 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
989 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
992 "Verify that DCG-2 receives EVPN prefixes along with auto "
993 "derived RT values(based on smaller VNI numbers)"
996 for addr_type
in ADDR_TYPES
:
998 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
1001 result
= verify_attributes_for_evpn_routes(
1002 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
1004 assert result
is not True, "Testcase {} :Failed \n "
1005 "Malfaromed Auto-RT value accepted: {}".format(tc_name
, result
)
1006 logger
.info("Expected Behavior: {}".format(result
))
1008 step("Configure VNI number more than boundary limit (16777215)")
1010 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 111}]}}
1011 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1012 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1014 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "vni": 16777215}]}}
1015 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1016 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1018 step("CLI error for malformed VNI.")
1021 "vrfs": [{"RED": {"vni": 16777215, "routerMac": "None", "state": "Down"}}]
1025 result
= verify_vrf_vni(tgen
, input_dict
)
1026 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1028 for addr_type
in ADDR_TYPES
:
1030 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
1033 result
= verify_attributes_for_evpn_routes(
1034 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
1036 assert result
is not True, "Testcase {} :Failed \n "
1037 "Malfaromed Auto-RT value accepted: {}".format(tc_name
, result
)
1038 logger
.info("Expected Behavior: {}".format(result
))
1040 step("Un-configure VNI number more than boundary limit (16777215)")
1042 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 16777215}]}}
1043 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1044 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1046 write_test_footer(tc_name
)
1049 if __name__
== "__main__":
1050 args
= ["-s"] + sys
.argv
[1:]
1051 sys
.exit(pytest
.main(args
))