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 # Reading the data from JSON File for topology creation
89 jsonFile
= "{}/evpn_type5_chaos_topo1.json".format(CWD
)
91 with
open(jsonFile
, "r") as topoJson
:
92 topo
= json
.load(topoJson
)
94 assert False, "Could not read file {}".format(jsonFile
)
96 # Reading the data from JSON File for topology creation
98 TCPDUMP_FILE
= "evpn_log.txt"
99 LOGDIR
= "/tmp/topotests/"
100 NETWORK1_1
= {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
101 NETWORK1_2
= {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"}
102 NETWORK1_3
= {"ipv4": "40.1.1.2/32", "ipv6": "40::2/128"}
103 NETWORK1_4
= {"ipv4": "40.1.1.3/32", "ipv6": "40::3/128"}
104 NETWORK2_1
= {"ipv4": "20.1.1.1/32", "ipv6": "20::1/128"}
105 NETWORK3_1
= {"ipv4": "30.1.1.1/32", "ipv6": "30::1/128"}
106 NETWORK4_1
= {"ipv4": "100.1.1.1/32 ", "ipv6": "100::100/128"}
107 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
111 MAC_1
= "00:80:48:ba:d1:00"
112 MAC_2
= "00:80:48:ba:d1:01"
113 MAC_3
= "00:80:48:ba:d1:02"
117 VXLAN_1
= "vxlan75100"
118 VXLAN_2
= "vxlan75200"
119 VXLAN_3
= "vxlan75300"
120 BRIDGE_INTF1
= "120.0.0.1"
121 BRIDGE_INTF2
= "120.0.0.2"
122 BRIDGE_INTF3
= "120.0.0.3"
123 MULTICAST_MAC1
= "01:00:5e:00:52:02"
126 "vxlan_name": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
127 "vxlan_id": [75100, 75200, 75300],
129 "local_addr": {"e1": BRIDGE_INTF1
, "d1": BRIDGE_INTF2
, "d2": BRIDGE_INTF3
},
133 "brctl_name": [BRCTL_1
, BRCTL_2
, BRCTL_3
],
134 "addvxlan": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
135 "vrf": ["RED", "BLUE", "GREEN"],
140 class CreateTopo(Topo
):
142 Test BasicTopo - topology 1
144 * `Topo`: Topology object
147 def build(self
, *_args
, **_opts
):
149 tgen
= get_topogen(self
)
151 # Building topology from json file
152 build_topo_from_json(tgen
, topo
)
155 def setup_module(mod
):
157 Sets up the pytest environment
163 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
164 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
165 logger
.info("=" * 40)
167 logger
.info("Running setup_module to create topology")
169 # This function initiates the topology build with Topogen...
170 tgen
= Topogen(CreateTopo
, mod
.__name
__)
171 # ... and here it calls Mininet initialization functions.
173 # Starting topology, create tmp files which are loaded to routers
174 # to start deamons and then start routers
177 # Creating configuration from JSON
178 build_config_from_json(tgen
, topo
)
180 if version_cmp(platform
.release(), '4.19') < 0:
181 error_msg
= ('EVPN tests will not run (have kernel "{}", '
182 'but it requires >= 4.19)'.format(platform
.release()))
183 pytest
.skip(error_msg
)
185 global BGP_CONVERGENCE
187 ADDR_TYPES
= check_address_types()
189 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
190 assert BGP_CONVERGENCE
is True, "setup_module :Failed \n Error: {}".format(
194 logger
.info("Pre-requisite config for testsuite")
195 prerequisite_config_for_test_suite(tgen
)
197 logger
.info("Running setup_module() done")
200 def teardown_module():
201 """Teardown the pytest environment"""
203 logger
.info("Running teardown_module to delete topology")
207 # Stop toplogy and Remove tmp files
211 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
213 logger
.info("=" * 40)
216 #####################################################
220 #####################################################
223 def prerequisite_config_for_test_suite(tgen
):
225 API to do prerequisite config for testsuite
229 * `tgen`: topogen object
232 step("Configure vxlan, bridge interface")
233 for dut
in ["e1", "d1", "d2"]:
234 step("[DUT: ]Configure vxlan")
239 "vxlan_name": VXLAN
["vxlan_name"],
240 "vxlan_id": VXLAN
["vxlan_id"],
241 "dstport": VXLAN
["dstport"],
242 "local_addr": VXLAN
["local_addr"][dut
],
243 "learning": VXLAN
["learning"],
249 result
= configure_vxlan(tgen
, vxlan_input
)
250 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
254 step("Configure bridge interface")
259 "brctl_name": BRCTL
["brctl_name"],
260 "addvxlan": BRCTL
["addvxlan"],
267 result
= configure_brctl(tgen
, topo
, brctl_input
)
268 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
272 step("Configure default routes")
273 add_default_routes(tgen
)
276 def add_default_routes(tgen
):
278 API to do prerequisite config for testsuite
282 * `tgen`: topogen object
285 step("Add default routes..")
291 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
292 "next_hop": topo
["routers"]["d1"]["links"]["e1-link1"][
297 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
298 "next_hop": topo
["routers"]["d2"]["links"]["e1-link1"][
307 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
308 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
313 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
314 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
323 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
324 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
329 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
330 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
338 result
= create_static_routes(tgen
, default_routes
)
339 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
342 def test_verify_overlay_index_p1(request
):
344 In absence of an overlay index all IP-Prefixes(RT-5)
345 are advertised with default values for below parameters:
346 --> Ethernet Tag ID = GW IP address = ESI=0
350 tc_name
= request
.node
.name
351 write_test_header(tc_name
)
352 check_router_status(tgen
)
353 reset_config_on_routers(tgen
)
354 add_default_routes(tgen
)
356 if tgen
.routers_have_failure():
357 pytest
.skip(tgen
.errors
)
359 step("Following steps are taken care in base config:")
361 "Configure BGP neighborship for both address families"
362 "(IPv4 & IPv6) between Edge-1 and VFN routers(R1 and R2)"
365 "Advertise prefixes from VNF routers R1 and R2 in associated "
366 "VRFs for both address-family."
368 step("Advertise VRF routes as in EVPN address family from Edge-1 " "router.")
370 for addr_type
in ADDR_TYPES
:
375 "network": NETWORK1_1
[addr_type
],
376 "next_hop": NEXT_HOP_IP
[addr_type
],
384 "network": NETWORK2_1
[addr_type
],
385 "next_hop": NEXT_HOP_IP
[addr_type
],
389 "network": NETWORK3_1
[addr_type
],
390 "next_hop": NEXT_HOP_IP
[addr_type
],
397 result
= create_static_routes(tgen
, input_dict_1
)
398 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
402 step("Verify: Prefixes are received in all VRFs on Edge-1 router.")
404 for addr_type
in ADDR_TYPES
:
405 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
406 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
407 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
411 for addr_type
in ADDR_TYPES
:
412 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
413 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
414 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
419 "Verify that EVPN routes, received on DCG-1 and DCG-2 do not "
420 "carry any overlay index and these indexes are set to default "
424 for addr_type
in ADDR_TYPES
:
425 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
427 result
= verify_attributes_for_evpn_routes(
428 tgen
, topo
, "d1", input_routes
, ethTag
=0
430 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
434 result
= verify_attributes_for_evpn_routes(
435 tgen
, topo
, "d2", input_routes
, ethTag
=0
437 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
441 write_test_footer(tc_name
)
444 def test_evpn_cli_json_available_p1(request
):
446 EVPN CLI output and JSON format validation.
450 tc_name
= request
.node
.name
451 write_test_header(tc_name
)
452 check_router_status(tgen
)
453 reset_config_on_routers(tgen
)
454 add_default_routes(tgen
)
456 if tgen
.routers_have_failure():
457 pytest
.skip(tgen
.errors
)
459 step("Need to verify below CLIs and associated JSON format " "outputs:")
464 "show evpn vni detail",
465 "show bgp l2vpn evpn all overlay",
466 "show bgp l2vpn evpn vni"
471 result
= verify_cli_json(tgen
, input_dict
)
472 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
474 write_test_footer(tc_name
)
477 def test_RT_verification_auto_p0(request
):
479 RT verification(auto)
483 tc_name
= request
.node
.name
484 write_test_header(tc_name
)
485 check_router_status(tgen
)
486 reset_config_on_routers(tgen
)
487 add_default_routes(tgen
)
489 if tgen
.routers_have_failure():
490 pytest
.skip(tgen
.errors
)
493 "Advertise overlapping prefixes from VNFs R1 and R2 in all VRFs "
494 "RED, GREEN and BLUE 100.1.1.1/32 and 100::100/128"
497 for addr_type
in ADDR_TYPES
:
502 "network": NETWORK4_1
[addr_type
],
503 "next_hop": NEXT_HOP_IP
[addr_type
],
511 "network": NETWORK4_1
[addr_type
],
512 "next_hop": NEXT_HOP_IP
[addr_type
],
516 "network": NETWORK4_1
[addr_type
],
517 "next_hop": NEXT_HOP_IP
[addr_type
],
524 result
= create_static_routes(tgen
, input_dict_1
)
525 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
530 "Verify that Edge-1 receives same prefixes in all 3 VRFs via "
531 "corresponding next-hop in associated VRF sh bgp vrf all"
534 for addr_type
in ADDR_TYPES
:
539 "network": NETWORK4_1
[addr_type
],
540 "next_hop": NEXT_HOP_IP
[addr_type
],
548 "network": NETWORK4_1
[addr_type
],
549 "next_hop": NEXT_HOP_IP
[addr_type
],
553 "network": NETWORK4_1
[addr_type
],
554 "next_hop": NEXT_HOP_IP
[addr_type
],
561 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
562 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
567 "Configure 4-byte local AS number on Edge-1 and establish EVPN "
568 "neighborship with DCG-1 & DCG-2."
571 topo_local
= deepcopy(topo
)
573 step("Delete BGP config for vrf RED.")
578 {"name": "RED", "no_vni": VNI_1
},
579 {"name": "BLUE", "no_vni": VNI_2
},
580 {"name": "GREEN", "no_vni": VNI_3
},
584 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
585 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
589 temp
= {dut
: {"bgp": []}}
590 input_dict_2
.update(temp
)
593 VRFS
= ["RED", "BLUE", "GREEN", None]
594 AS_NUM
= [100, 100, 100, 100]
596 for index
, vrf
, as_num
in zip(INDEX
, VRFS
, AS_NUM
):
597 topo_local
["routers"][dut
]["bgp"][index
]["local_as"] = 4294967293
599 temp
[dut
]["bgp"].append(
600 {"local_as": as_num
, "vrf": vrf
, "delete": True}
603 temp
[dut
]["bgp"].append({"local_as": as_num
, "delete": True})
605 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
606 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
608 result
= create_router_bgp(tgen
, topo_local
["routers"])
609 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
614 {"name": "RED", "vni": VNI_1
},
615 {"name": "BLUE", "vni": VNI_2
},
616 {"name": "GREEN", "vni": VNI_3
},
620 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
621 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
624 "Verify that all overlapping prefixes across different VRFs are "
625 "advertised in EVPN with unique RD value(auto derived)."
628 "Verify that FRR uses only the lower 2 bytes of ASN+VNI for auto "
632 for addr_type
in ADDR_TYPES
:
634 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
637 "r2": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "BLUE"}]}
641 "static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "GREEN"}]
645 result
= verify_attributes_for_evpn_routes(
646 tgen
, topo
, "e1", input_routes_1
, rd
="auto", rd_peer
="e1"
648 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
652 result
= verify_attributes_for_evpn_routes(
653 tgen
, topo
, "e1", input_routes_1
, rt
="auto", rt_peer
="e1"
655 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
659 result
= verify_attributes_for_evpn_routes(
660 tgen
, topo
, "e1", input_routes_2
, rd
="auto", rd_peer
="e1"
662 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
666 result
= verify_attributes_for_evpn_routes(
667 tgen
, topo
, "e1", input_routes_2
, rt
="auto", rt_peer
="e1"
669 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
673 result
= verify_attributes_for_evpn_routes(
674 tgen
, topo
, "e1", input_routes_3
, rd
="auto", rd_peer
="e1"
676 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
680 result
= verify_attributes_for_evpn_routes(
681 tgen
, topo
, "e1", input_routes_3
, rt
="auto", rt_peer
="e1"
683 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
688 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
689 " from EVPN address-family to respective VRFs."
692 "Verify if DCG-2(eBGP peer) automatically imports the prefixes "
693 "from EVPN address-family to respective VRFs or not."
696 for addr_type
in ADDR_TYPES
:
701 "network": NETWORK4_1
[addr_type
],
702 "next_hop": NEXT_HOP_IP
[addr_type
],
710 "network": NETWORK4_1
[addr_type
],
711 "next_hop": NEXT_HOP_IP
[addr_type
],
715 "network": NETWORK4_1
[addr_type
],
716 "next_hop": NEXT_HOP_IP
[addr_type
],
723 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
724 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
728 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
729 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
734 "Change the VNI number for all 3 VRFs on Edge-1 as:"
735 "RED : 75400, GREEN: 75500, BLUE: 75600"
741 {"name": "RED", "no_vni": VNI_1
},
742 {"name": "BLUE", "no_vni": VNI_2
},
743 {"name": "GREEN", "no_vni": VNI_3
},
747 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
748 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
753 {"name": "RED", "vni": 75400},
754 {"name": "BLUE", "vni": 75500},
755 {"name": "GREEN", "vni": 75600},
759 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
760 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
762 step("Delete configured vxlan")
768 "vxlan_name": VXLAN
["vxlan_name"],
769 "vxlan_id": VXLAN
["vxlan_id"],
770 "dstport": VXLAN
["dstport"],
771 "local_addr": VXLAN
["local_addr"][dut
],
772 "learning": VXLAN
["learning"],
779 result
= configure_vxlan(tgen
, vxlan_input
)
780 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
782 step("Configured vxlan")
783 VXLAN
["vxlan_id"] = [75400, 75500, 75600]
788 "vxlan_name": VXLAN
["vxlan_name"],
789 "vxlan_id": VXLAN
["vxlan_id"],
790 "dstport": VXLAN
["dstport"],
791 "local_addr": VXLAN
["local_addr"][dut
],
792 "learning": VXLAN
["learning"],
798 result
= configure_vxlan(tgen
, vxlan_input
)
799 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
801 step("Configure bridge interface")
806 "brctl_name": BRCTL
["brctl_name"],
807 "addvxlan": BRCTL
["addvxlan"],
814 result
= configure_brctl(tgen
, topo
, brctl_input
)
815 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
818 "Verify on Edge-1 that auto derived RT value has changed for "
819 "each VRF based on VNI number.."
825 {"RED": {"vni": 75400}},
826 {"BLUE": {"vni": 75500}},
827 {"GREEN": {"vni": 75600}},
832 result
= verify_vrf_vni(tgen
, input_dict
)
833 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
836 "Verify on Edge-1 that auto derived RT value has changed for "
837 "each VRF based on VNI number."
840 for addr_type
in ADDR_TYPES
:
842 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
845 result
= verify_attributes_for_evpn_routes(
846 tgen
, topo
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
848 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
853 "Verify on DCG-2 that prefixes are not imported from EVPN "
854 "address-family to VRFs as RT values are different on sending("
855 "edge-1) and receiving(DCG-2) end."
858 for addr_type
in ADDR_TYPES
:
860 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
863 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
864 assert result
is not True, "Testcase {} :Failed \n "
865 "Routes are still present: {}".format(tc_name
, result
)
866 logger
.info("Expected Behavior: {}".format(result
))
869 "Revert back to original VNI number for all 3 VRFs on Edge-1 "
870 "as: RED : 75100, GREEN: 75200, BLUE: 75300"
876 {"name": "RED", "no_vni": 75400},
877 {"name": "BLUE", "no_vni": 75500},
878 {"name": "GREEN", "no_vni": 75600},
882 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
883 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
888 {"name": "RED", "vni": VNI_1
},
889 {"name": "BLUE", "vni": VNI_2
},
890 {"name": "GREEN", "vni": VNI_3
},
894 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
895 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
897 step("Delete configured vxlan")
903 "vxlan_name": VXLAN
["vxlan_name"],
904 "vxlan_id": VXLAN
["vxlan_id"],
905 "dstport": VXLAN
["dstport"],
906 "local_addr": VXLAN
["local_addr"][dut
],
907 "learning": VXLAN
["learning"],
913 result
= configure_vxlan(tgen
, vxlan_input
)
914 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
916 step("Configured vxlan")
917 VXLAN
["vxlan_id"] = [75100, 75200, 75300]
922 "vxlan_name": VXLAN
["vxlan_name"],
923 "vxlan_id": VXLAN
["vxlan_id"],
924 "dstport": VXLAN
["dstport"],
925 "local_addr": VXLAN
["local_addr"][dut
],
926 "learning": VXLAN
["learning"],
931 result
= configure_vxlan(tgen
, vxlan_input
)
932 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
934 step("Configure bridge interface")
939 "brctl_name": BRCTL
["brctl_name"],
940 "addvxlan": BRCTL
["addvxlan"],
947 result
= configure_brctl(tgen
, topo
, brctl_input
)
948 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
951 "Verify on Edge-1 that auto derived RT value has changed for "
952 "each VRF based on VNI number."
955 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
956 " from EVPN address-family to respective VRFs."
959 for addr_type
in ADDR_TYPES
:
961 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
964 result
= verify_attributes_for_evpn_routes(
965 tgen
, topo
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
967 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
971 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
972 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
976 step("Test with smaller VNI numbers (1-75000)")
978 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": VNI_1
}]}}
979 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
980 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
982 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "vni": 111}]}}
983 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
984 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
987 "Verify that DCG-2 receives EVPN prefixes along with auto "
988 "derived RT values(based on smaller VNI numbers)"
991 for addr_type
in ADDR_TYPES
:
993 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
996 result
= verify_attributes_for_evpn_routes(
997 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
999 assert result
is not True, "Testcase {} :Failed \n "
1000 "Malfaromed Auto-RT value accepted: {}".format(tc_name
, result
)
1001 logger
.info("Expected Behavior: {}".format(result
))
1003 step("Configure VNI number more than boundary limit (16777215)")
1005 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 111}]}}
1006 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1007 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1009 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "vni": 16777215}]}}
1010 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1011 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1013 step("CLI error for malformed VNI.")
1016 "vrfs": [{"RED": {"vni": 16777215, "routerMac": "None", "state": "Down"}}]
1020 result
= verify_vrf_vni(tgen
, input_dict
)
1021 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1023 for addr_type
in ADDR_TYPES
:
1025 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
1028 result
= verify_attributes_for_evpn_routes(
1029 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
1031 assert result
is not True, "Testcase {} :Failed \n "
1032 "Malfaromed Auto-RT value accepted: {}".format(tc_name
, result
)
1033 logger
.info("Expected Behavior: {}".format(result
))
1035 step("Un-configure VNI number more than boundary limit (16777215)")
1037 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 16777215}]}}
1038 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1039 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1041 write_test_footer(tc_name
)
1044 if __name__
== "__main__":
1045 args
= ["-s"] + sys
.argv
[1:]
1046 sys
.exit(pytest
.main(args
))