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. In absence of an overlay index all IP-Prefixes(RT-5)
27 are advertised with default values for below parameters:
28 --> Ethernet Tag ID = GW IP address = ESI=0
29 2. EVPN CLI output and JSON format validation.
30 3. RT verification(auto)
40 from copy
import deepcopy
41 from time
import sleep
44 # Save the Current Working Directory to find configuration files.
45 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
46 sys
.path
.append(os
.path
.join(CWD
, "../"))
47 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
49 # Required to instantiate the topology builder class.
51 # pylint: disable=C0413
52 # Import topogen and topotest helpers
53 from lib
.topotest
import version_cmp
54 from lib
.topogen
import Topogen
, get_topogen
55 from mininet
.topo
import Topo
57 from lib
.common_config
import (
62 reset_config_on_routers
,
70 create_interface_in_kernel
,
79 from lib
.topolog
import logger
81 verify_bgp_convergence
,
84 verify_best_path_as_per_bgp_attribute
,
85 verify_attributes_for_evpn_routes
,
88 from lib
.topojson
import build_topo_from_json
, build_config_from_json
90 # Reading the data from JSON File for topology creation
91 jsonFile
= "{}/evpn_type5_chaos_topo1.json".format(CWD
)
93 with
open(jsonFile
, "r") as topoJson
:
94 topo
= json
.load(topoJson
)
96 assert False, "Could not read file {}".format(jsonFile
)
98 # Reading the data from JSON File for topology creation
100 TCPDUMP_FILE
= "evpn_log.txt"
101 LOGDIR
= "/tmp/topotests/"
102 NETWORK1_1
= {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
103 NETWORK1_2
= {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"}
104 NETWORK1_3
= {"ipv4": "40.1.1.2/32", "ipv6": "40::2/128"}
105 NETWORK1_4
= {"ipv4": "40.1.1.3/32", "ipv6": "40::3/128"}
106 NETWORK2_1
= {"ipv4": "20.1.1.1/32", "ipv6": "20::1/128"}
107 NETWORK3_1
= {"ipv4": "30.1.1.1/32", "ipv6": "30::1/128"}
108 NETWORK4_1
= {"ipv4": "100.1.1.1/32 ", "ipv6": "100::100/128"}
109 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
113 MAC_1
= "00:80:48:ba:d1:00"
114 MAC_2
= "00:80:48:ba:d1:01"
115 MAC_3
= "00:80:48:ba:d1:02"
119 VXLAN_1
= "vxlan75100"
120 VXLAN_2
= "vxlan75200"
121 VXLAN_3
= "vxlan75300"
122 BRIDGE_INTF1
= "120.0.0.1"
123 BRIDGE_INTF2
= "120.0.0.2"
124 BRIDGE_INTF3
= "120.0.0.3"
125 MULTICAST_MAC1
= "01:00:5e:00:52:02"
128 "vxlan_name": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
129 "vxlan_id": [75100, 75200, 75300],
131 "local_addr": {"e1": BRIDGE_INTF1
, "d1": BRIDGE_INTF2
, "d2": BRIDGE_INTF3
},
135 "brctl_name": [BRCTL_1
, BRCTL_2
, BRCTL_3
],
136 "addvxlan": [VXLAN_1
, VXLAN_2
, VXLAN_3
],
137 "vrf": ["RED", "BLUE", "GREEN"],
142 class CreateTopo(Topo
):
144 Test BasicTopo - topology 1
146 * `Topo`: Topology object
149 def build(self
, *_args
, **_opts
):
151 tgen
= get_topogen(self
)
153 # Building topology from json file
154 build_topo_from_json(tgen
, topo
)
157 def setup_module(mod
):
159 Sets up the pytest environment
165 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
166 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
167 logger
.info("=" * 40)
169 logger
.info("Running setup_module to create topology")
171 # This function initiates the topology build with Topogen...
172 tgen
= Topogen(CreateTopo
, mod
.__name
__)
173 # ... and here it calls Mininet initialization functions.
175 # Starting topology, create tmp files which are loaded to routers
176 # to start deamons and then start routers
179 # Creating configuration from JSON
180 build_config_from_json(tgen
, topo
)
182 if version_cmp(platform
.release(), '4.19') < 0:
183 error_msg
= ('EVPN tests will not run (have kernel "{}", '
184 'but it requires >= 4.19)'.format(platform
.release()))
185 pytest
.skip(error_msg
)
187 global BGP_CONVERGENCE
189 ADDR_TYPES
= check_address_types()
191 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
192 assert BGP_CONVERGENCE
is True, "setup_module :Failed \n Error: {}".format(
196 logger
.info("Pre-requisite config for testsuite")
197 prerequisite_config_for_test_suite(tgen
)
199 logger
.info("Running setup_module() done")
202 def teardown_module():
203 """Teardown the pytest environment"""
205 logger
.info("Running teardown_module to delete topology")
209 # Stop toplogy and Remove tmp files
213 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
215 logger
.info("=" * 40)
218 #####################################################
222 #####################################################
225 def prerequisite_config_for_test_suite(tgen
):
227 API to do prerequisite config for testsuite
231 * `tgen`: topogen object
234 step("Configure vxlan, bridge interface")
235 for dut
in ["e1", "d1", "d2"]:
236 step("[DUT: ]Configure vxlan")
241 "vxlan_name": VXLAN
["vxlan_name"],
242 "vxlan_id": VXLAN
["vxlan_id"],
243 "dstport": VXLAN
["dstport"],
244 "local_addr": VXLAN
["local_addr"][dut
],
245 "learning": VXLAN
["learning"],
251 result
= configure_vxlan(tgen
, vxlan_input
)
252 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
256 step("Configure bridge interface")
261 "brctl_name": BRCTL
["brctl_name"],
262 "addvxlan": BRCTL
["addvxlan"],
269 result
= configure_brctl(tgen
, topo
, brctl_input
)
270 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
274 step("Configure default routes")
275 add_default_routes(tgen
)
278 def add_default_routes(tgen
):
280 API to do prerequisite config for testsuite
284 * `tgen`: topogen object
287 step("Add default routes..")
293 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
294 "next_hop": topo
["routers"]["d1"]["links"]["e1-link1"][
299 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
300 "next_hop": topo
["routers"]["d2"]["links"]["e1-link1"][
309 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
310 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
315 "network": "{}/32".format(VXLAN
["local_addr"]["d2"]),
316 "next_hop": topo
["routers"]["e1"]["links"]["d1-link1"][
325 "network": "{}/32".format(VXLAN
["local_addr"]["d1"]),
326 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
331 "network": "{}/32".format(VXLAN
["local_addr"]["e1"]),
332 "next_hop": topo
["routers"]["e1"]["links"]["d2-link1"][
340 result
= create_static_routes(tgen
, default_routes
)
341 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
344 def test_verify_overlay_index_p1(request
):
346 In absence of an overlay index all IP-Prefixes(RT-5)
347 are advertised with default values for below parameters:
348 --> Ethernet Tag ID = GW IP address = ESI=0
352 tc_name
= request
.node
.name
353 write_test_header(tc_name
)
354 check_router_status(tgen
)
355 reset_config_on_routers(tgen
)
356 add_default_routes(tgen
)
358 if tgen
.routers_have_failure():
359 pytest
.skip(tgen
.errors
)
361 step("Following steps are taken care in base config:")
363 "Configure BGP neighborship for both address families"
364 "(IPv4 & IPv6) between Edge-1 and VFN routers(R1 and R2)"
367 "Advertise prefixes from VNF routers R1 and R2 in associated "
368 "VRFs for both address-family."
370 step("Advertise VRF routes as in EVPN address family from Edge-1 " "router.")
372 for addr_type
in ADDR_TYPES
:
377 "network": NETWORK1_1
[addr_type
],
378 "next_hop": NEXT_HOP_IP
[addr_type
],
386 "network": NETWORK2_1
[addr_type
],
387 "next_hop": NEXT_HOP_IP
[addr_type
],
391 "network": NETWORK3_1
[addr_type
],
392 "next_hop": NEXT_HOP_IP
[addr_type
],
399 result
= create_static_routes(tgen
, input_dict_1
)
400 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
404 step("Verify: Prefixes are received in all VRFs on Edge-1 router.")
406 for addr_type
in ADDR_TYPES
:
407 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
408 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
409 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
413 for addr_type
in ADDR_TYPES
:
414 input_routes
= {key
: topo
["routers"][key
] for key
in ["r2"]}
415 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
416 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
421 "Verify that EVPN routes, received on DCG-1 and DCG-2 do not "
422 "carry any overlay index and these indexes are set to default "
426 for addr_type
in ADDR_TYPES
:
427 input_routes
= {key
: topo
["routers"][key
] for key
in ["r1"]}
429 result
= verify_attributes_for_evpn_routes(
430 tgen
, topo
, "d1", input_routes
, ethTag
=0
432 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
436 result
= verify_attributes_for_evpn_routes(
437 tgen
, topo
, "d2", input_routes
, ethTag
=0
439 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
443 write_test_footer(tc_name
)
446 def test_evpn_cli_json_available_p1(request
):
448 EVPN CLI output and JSON format validation.
452 tc_name
= request
.node
.name
453 write_test_header(tc_name
)
454 check_router_status(tgen
)
455 reset_config_on_routers(tgen
)
456 add_default_routes(tgen
)
458 if tgen
.routers_have_failure():
459 pytest
.skip(tgen
.errors
)
461 step("Need to verify below CLIs and associated JSON format " "outputs:")
466 "show evpn vni detail",
467 "show bgp l2vpn evpn all overlay",
468 "show bgp l2vpn evpn vni"
473 result
= verify_cli_json(tgen
, input_dict
)
474 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
476 write_test_footer(tc_name
)
479 def test_RT_verification_auto_p0(request
):
481 RT verification(auto)
485 tc_name
= request
.node
.name
486 write_test_header(tc_name
)
487 check_router_status(tgen
)
488 reset_config_on_routers(tgen
)
489 add_default_routes(tgen
)
491 if tgen
.routers_have_failure():
492 pytest
.skip(tgen
.errors
)
495 "Advertise overlapping prefixes from VNFs R1 and R2 in all VRFs "
496 "RED, GREEN and BLUE 100.1.1.1/32 and 100::100/128"
499 for addr_type
in ADDR_TYPES
:
504 "network": NETWORK4_1
[addr_type
],
505 "next_hop": NEXT_HOP_IP
[addr_type
],
513 "network": NETWORK4_1
[addr_type
],
514 "next_hop": NEXT_HOP_IP
[addr_type
],
518 "network": NETWORK4_1
[addr_type
],
519 "next_hop": NEXT_HOP_IP
[addr_type
],
526 result
= create_static_routes(tgen
, input_dict_1
)
527 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
532 "Verify that Edge-1 receives same prefixes in all 3 VRFs via "
533 "corresponding next-hop in associated VRF sh bgp vrf all"
536 for addr_type
in ADDR_TYPES
:
541 "network": NETWORK4_1
[addr_type
],
542 "next_hop": NEXT_HOP_IP
[addr_type
],
550 "network": NETWORK4_1
[addr_type
],
551 "next_hop": NEXT_HOP_IP
[addr_type
],
555 "network": NETWORK4_1
[addr_type
],
556 "next_hop": NEXT_HOP_IP
[addr_type
],
563 result
= verify_rib(tgen
, addr_type
, "e1", input_routes
)
564 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
569 "Configure 4-byte local AS number on Edge-1 and establish EVPN "
570 "neighborship with DCG-1 & DCG-2."
573 topo_local
= deepcopy(topo
)
575 step("Delete BGP config for vrf RED.")
580 {"name": "RED", "no_vni": VNI_1
},
581 {"name": "BLUE", "no_vni": VNI_2
},
582 {"name": "GREEN", "no_vni": VNI_3
},
586 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
587 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
591 temp
= {dut
: {"bgp": []}}
592 input_dict_2
.update(temp
)
595 VRFS
= ["RED", "BLUE", "GREEN", None]
596 AS_NUM
= [100, 100, 100, 100]
598 for index
, vrf
, as_num
in zip(INDEX
, VRFS
, AS_NUM
):
599 topo_local
["routers"][dut
]["bgp"][index
]["local_as"] = 4294967293
601 temp
[dut
]["bgp"].append(
602 {"local_as": as_num
, "vrf": vrf
, "delete": True}
605 temp
[dut
]["bgp"].append({"local_as": as_num
, "delete": True})
607 result
= create_router_bgp(tgen
, topo
, input_dict_2
)
608 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
610 result
= create_router_bgp(tgen
, topo_local
["routers"])
611 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
616 {"name": "RED", "vni": VNI_1
},
617 {"name": "BLUE", "vni": VNI_2
},
618 {"name": "GREEN", "vni": VNI_3
},
622 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
623 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
626 "Verify that all overlapping prefixes across different VRFs are "
627 "advertised in EVPN with unique RD value(auto derived)."
630 "Verify that FRR uses only the lower 2 bytes of ASN+VNI for auto "
634 for addr_type
in ADDR_TYPES
:
636 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
639 "r2": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "BLUE"}]}
643 "static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "GREEN"}]
647 result
= verify_attributes_for_evpn_routes(
648 tgen
, topo
, "e1", input_routes_1
, rd
="auto", rd_peer
="e1"
650 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
654 result
= verify_attributes_for_evpn_routes(
655 tgen
, topo
, "e1", input_routes_1
, rt
="auto", rt_peer
="e1"
657 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
661 result
= verify_attributes_for_evpn_routes(
662 tgen
, topo
, "e1", input_routes_2
, rd
="auto", rd_peer
="e1"
664 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
668 result
= verify_attributes_for_evpn_routes(
669 tgen
, topo
, "e1", input_routes_2
, rt
="auto", rt_peer
="e1"
671 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
675 result
= verify_attributes_for_evpn_routes(
676 tgen
, topo
, "e1", input_routes_3
, rd
="auto", rd_peer
="e1"
678 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
682 result
= verify_attributes_for_evpn_routes(
683 tgen
, topo
, "e1", input_routes_3
, rt
="auto", rt_peer
="e1"
685 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
690 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
691 " from EVPN address-family to respective VRFs."
694 "Verify if DCG-2(eBGP peer) automatically imports the prefixes "
695 "from EVPN address-family to respective VRFs or not."
698 for addr_type
in ADDR_TYPES
:
703 "network": NETWORK4_1
[addr_type
],
704 "next_hop": NEXT_HOP_IP
[addr_type
],
712 "network": NETWORK4_1
[addr_type
],
713 "next_hop": NEXT_HOP_IP
[addr_type
],
717 "network": NETWORK4_1
[addr_type
],
718 "next_hop": NEXT_HOP_IP
[addr_type
],
725 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
726 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
730 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
)
731 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
736 "Change the VNI number for all 3 VRFs on Edge-1 as:"
737 "RED : 75400, GREEN: 75500, BLUE: 75600"
743 {"name": "RED", "no_vni": VNI_1
},
744 {"name": "BLUE", "no_vni": VNI_2
},
745 {"name": "GREEN", "no_vni": VNI_3
},
749 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
750 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
755 {"name": "RED", "vni": 75400},
756 {"name": "BLUE", "vni": 75500},
757 {"name": "GREEN", "vni": 75600},
761 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
762 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
764 step("Delete configured vxlan")
770 "vxlan_name": VXLAN
["vxlan_name"],
771 "vxlan_id": VXLAN
["vxlan_id"],
772 "dstport": VXLAN
["dstport"],
773 "local_addr": VXLAN
["local_addr"][dut
],
774 "learning": VXLAN
["learning"],
781 result
= configure_vxlan(tgen
, vxlan_input
)
782 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
784 step("Configured vxlan")
785 VXLAN
["vxlan_id"] = [75400, 75500, 75600]
790 "vxlan_name": VXLAN
["vxlan_name"],
791 "vxlan_id": VXLAN
["vxlan_id"],
792 "dstport": VXLAN
["dstport"],
793 "local_addr": VXLAN
["local_addr"][dut
],
794 "learning": VXLAN
["learning"],
800 result
= configure_vxlan(tgen
, vxlan_input
)
801 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
803 step("Configure bridge interface")
808 "brctl_name": BRCTL
["brctl_name"],
809 "addvxlan": BRCTL
["addvxlan"],
816 result
= configure_brctl(tgen
, topo
, brctl_input
)
817 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
820 "Verify on Edge-1 that auto derived RT value has changed for "
821 "each VRF based on VNI number.."
827 {"RED": {"vni": 75400}},
828 {"BLUE": {"vni": 75500}},
829 {"GREEN": {"vni": 75600}},
834 result
= verify_vrf_vni(tgen
, input_dict
)
835 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
838 "Verify on Edge-1 that auto derived RT value has changed for "
839 "each VRF based on VNI number."
842 for addr_type
in ADDR_TYPES
:
844 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
847 result
= verify_attributes_for_evpn_routes(
848 tgen
, topo
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
850 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
855 "Verify on DCG-2 that prefixes are not imported from EVPN "
856 "address-family to VRFs as RT values are different on sending("
857 "edge-1) and receiving(DCG-2) end."
860 for addr_type
in ADDR_TYPES
:
862 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
865 result
= verify_rib(tgen
, addr_type
, "d2", input_routes
, expected
=False)
866 assert result
is not True, "Testcase {} :Failed \n "
867 "Routes are still present: {}".format(tc_name
, result
)
868 logger
.info("Expected Behavior: {}".format(result
))
871 "Revert back to original VNI number for all 3 VRFs on Edge-1 "
872 "as: RED : 75100, GREEN: 75200, BLUE: 75300"
878 {"name": "RED", "no_vni": 75400},
879 {"name": "BLUE", "no_vni": 75500},
880 {"name": "GREEN", "no_vni": 75600},
884 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
885 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
890 {"name": "RED", "vni": VNI_1
},
891 {"name": "BLUE", "vni": VNI_2
},
892 {"name": "GREEN", "vni": VNI_3
},
896 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
897 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
899 step("Delete configured vxlan")
905 "vxlan_name": VXLAN
["vxlan_name"],
906 "vxlan_id": VXLAN
["vxlan_id"],
907 "dstport": VXLAN
["dstport"],
908 "local_addr": VXLAN
["local_addr"][dut
],
909 "learning": VXLAN
["learning"],
915 result
= configure_vxlan(tgen
, vxlan_input
)
916 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
918 step("Configured vxlan")
919 VXLAN
["vxlan_id"] = [75100, 75200, 75300]
924 "vxlan_name": VXLAN
["vxlan_name"],
925 "vxlan_id": VXLAN
["vxlan_id"],
926 "dstport": VXLAN
["dstport"],
927 "local_addr": VXLAN
["local_addr"][dut
],
928 "learning": VXLAN
["learning"],
933 result
= configure_vxlan(tgen
, vxlan_input
)
934 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
936 step("Configure bridge interface")
941 "brctl_name": BRCTL
["brctl_name"],
942 "addvxlan": BRCTL
["addvxlan"],
949 result
= configure_brctl(tgen
, topo
, brctl_input
)
950 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
953 "Verify on Edge-1 that auto derived RT value has changed for "
954 "each VRF based on VNI number."
957 "Verify that DCG-1(iBGP peer) automatically imports the prefixes"
958 " from EVPN address-family to respective VRFs."
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
, "e1", input_routes
, rt
="auto", rt_peer
="e1"
969 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
973 result
= verify_rib(tgen
, addr_type
, "d1", input_routes
)
974 assert result
is True, "Testcase {} :Failed \n Error: {}".format(
978 step("Test with smaller VNI numbers (1-75000)")
980 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": VNI_1
}]}}
981 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
982 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
984 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "vni": 111}]}}
985 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
986 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
989 "Verify that DCG-2 receives EVPN prefixes along with auto "
990 "derived RT values(based on smaller VNI numbers)"
993 for addr_type
in ADDR_TYPES
:
995 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
998 result
= verify_attributes_for_evpn_routes(
999 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
1001 assert result
is not True, "Testcase {} :Failed \n "
1002 "Malfaromed Auto-RT value accepted: {}".format(tc_name
, result
)
1003 logger
.info("Expected Behavior: {}".format(result
))
1005 step("Configure VNI number more than boundary limit (16777215)")
1007 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 111}]}}
1008 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1009 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1011 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "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 step("CLI error for malformed VNI.")
1018 "vrfs": [{"RED": {"vni": 16777215, "routerMac": "None", "state": "Down"}}]
1022 result
= verify_vrf_vni(tgen
, input_dict
)
1023 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1025 for addr_type
in ADDR_TYPES
:
1027 "r1": {"static_routes": [{"network": NETWORK4_1
[addr_type
], "vrf": "RED"}]}
1030 result
= verify_attributes_for_evpn_routes(
1031 tgen
, topo
, "d2", input_routes_1
, rt
="auto", rt_peer
="e1", expected
=False
1033 assert result
is not True, "Testcase {} :Failed \n "
1034 "Malfaromed Auto-RT value accepted: {}".format(tc_name
, result
)
1035 logger
.info("Expected Behavior: {}".format(result
))
1037 step("Un-configure VNI number more than boundary limit (16777215)")
1039 input_dict_vni
= {"e1": {"vrfs": [{"name": "RED", "no_vni": 16777215}]}}
1040 result
= create_vrf_cfg(tgen
, topo
, input_dict
=input_dict_vni
)
1041 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1043 write_test_footer(tc_name
)
1046 if __name__
== "__main__":
1047 args
= ["-s"] + sys
.argv
[1:]
1048 sys
.exit(pytest
.main(args
))