summaryrefslogtreecommitdiffstats
path: root/test/test_vxlan.py
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2020-03-02 13:55:31 +0100
committerJakub Grajciar <jgrajcia@cisco.com>2020-03-16 09:18:46 +0000
commit7c0eb56f40b3ccf8acd8f04e208aa50231aebeba (patch)
tree3df2939bf739d46eb6cb42767e5c402c3e0eac86 /test/test_vxlan.py
parentcd5a4a035c0c7a7ca9f915bee83abde085c05ad7 (diff)
vxlan: vxlan/vxlan.api API cleanup
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I7f6f37ec6eed780322e2488d6eb0f5681945ba09 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'test/test_vxlan.py')
-rw-r--r--test/test_vxlan.py118
1 files changed, 66 insertions, 52 deletions
diff --git a/test/test_vxlan.py b/test/test_vxlan.py
index 7613054882a..910611c63cc 100644
--- a/test/test_vxlan.py
+++ b/test/test_vxlan.py
@@ -12,6 +12,7 @@ from scapy.layers.inet import IP, UDP
from scapy.layers.vxlan import VXLAN
from scapy.utils import atol
from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_vxlan_tunnel import VppVxlanTunnel
from vpp_ip import INVALID_INDEX
@@ -98,8 +99,9 @@ class TestVxlan(BridgeDomain, VppTestCase):
rip.add_vpp_config()
dest_ip4n = socket.inet_pton(socket.AF_INET, dest_ip4)
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=dest_ip4n, vni=vni)
+ r = VppVxlanTunnel(cls, src=cls.pg0.local_ip4,
+ dst=dest_ip4, vni=vni)
+ r.add_vpp_config()
cls.vapi.sw_interface_set_l2_bridge(r.sw_if_index, bd_id=vni)
@classmethod
@@ -112,12 +114,14 @@ class TestVxlan(BridgeDomain, VppTestCase):
vni_start = 10000
vni_end = vni_start + n_shared_dst_tunnels
for vni in range(vni_start, vni_end):
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=cls.mcast_ip4n,
- mcast_sw_if_index=1,
- is_add=is_add, vni=vni)
- if r.sw_if_index == 0xffffffff:
- raise ValueError("bad sw_if_index: ~0")
+ r = VppVxlanTunnel(cls, src=cls.pg0.local_ip4,
+ dst=cls.mcast_ip4, mcast_sw_if_index=1, vni=vni)
+ if is_add:
+ r.add_vpp_config()
+ if r.sw_if_index == 0xffffffff:
+ raise ValueError("bad sw_if_index: ~0")
+ else:
+ r.remove_vpp_config()
@classmethod
def add_shared_mcast_dst_load(cls):
@@ -135,13 +139,15 @@ class TestVxlan(BridgeDomain, VppTestCase):
n_distinct_dst_tunnels = 200
ip_range_start = 10
ip_range_end = ip_range_start + n_distinct_dst_tunnels
- for dest_ip4n in ip4n_range(cls.mcast_ip4n, ip_range_start,
- ip_range_end):
- vni = bytearray(dest_ip4n)[3]
- cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=dest_ip4n,
- mcast_sw_if_index=1, is_add=is_add,
- vni=vni)
+ for dest_ip4 in ip4_range(cls.mcast_ip4, ip_range_start,
+ ip_range_end):
+ vni = bytearray(socket.inet_pton(socket.AF_INET, dest_ip4))[3]
+ r = VppVxlanTunnel(cls, src=cls.pg0.local_ip4,
+ dst=dest_ip4, mcast_sw_if_index=1, vni=vni)
+ if is_add:
+ r.add_vpp_config()
+ else:
+ r.remove_vpp_config()
@classmethod
def add_mcast_tunnels_load(cls):
@@ -182,43 +188,6 @@ class TestVxlan(BridgeDomain, VppTestCase):
cls.mcast_mac = "01:00:5e:%02x:%02x:%02x" % (
(iplong >> 16) & 0x7F, (iplong >> 8) & 0xFF, iplong & 0xFF)
- # Create VXLAN VTEP on VPP pg0, and put vxlan_tunnel0 and pg1
- # into BD.
- cls.single_tunnel_bd = 1
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=cls.pg0.remote_ip4n,
- vni=cls.single_tunnel_bd)
- cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
- bd_id=cls.single_tunnel_bd)
- cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg1.sw_if_index, bd_id=cls.single_tunnel_bd)
-
- # Setup vni 2 to test multicast flooding
- cls.n_ucast_tunnels = 10
- cls.mcast_flood_bd = 2
- cls.create_vxlan_flood_test_bd(cls.mcast_flood_bd,
- cls.n_ucast_tunnels)
- r = cls.vapi.vxlan_add_del_tunnel(src_address=cls.pg0.local_ip4n,
- dst_address=cls.mcast_ip4n,
- mcast_sw_if_index=1,
- vni=cls.mcast_flood_bd)
- cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
- bd_id=cls.mcast_flood_bd)
- cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg2.sw_if_index, bd_id=cls.mcast_flood_bd)
-
- # Add and delete mcast tunnels to check stability
- cls.add_shared_mcast_dst_load()
- cls.add_mcast_tunnels_load()
- cls.del_shared_mcast_dst_load()
- cls.del_mcast_tunnels_load()
-
- # Setup vni 3 to test unicast flooding
- cls.ucast_flood_bd = 3
- cls.create_vxlan_flood_test_bd(cls.ucast_flood_bd,
- cls.n_ucast_tunnels)
- cls.vapi.sw_interface_set_l2_bridge(
- rx_sw_if_index=cls.pg3.sw_if_index, bd_id=cls.ucast_flood_bd)
except Exception:
super(TestVxlan, cls).tearDownClass()
raise
@@ -227,6 +196,51 @@ class TestVxlan(BridgeDomain, VppTestCase):
def tearDownClass(cls):
super(TestVxlan, cls).tearDownClass()
+ def setUp(self):
+ super(TestVxlan, self).setUp()
+ # Create VXLAN VTEP on VPP pg0, and put vxlan_tunnel0 and pg1
+ # into BD.
+ self.single_tunnel_bd = 1
+ r = VppVxlanTunnel(self, src=self.pg0.local_ip4,
+ dst=self.pg0.remote_ip4, vni=self.single_tunnel_bd)
+ r.add_vpp_config()
+ self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
+ bd_id=self.single_tunnel_bd)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg1.sw_if_index, bd_id=self.single_tunnel_bd)
+
+ # Setup vni 2 to test multicast flooding
+ self.n_ucast_tunnels = 10
+ self.mcast_flood_bd = 2
+ self.create_vxlan_flood_test_bd(self.mcast_flood_bd,
+ self.n_ucast_tunnels)
+ r = VppVxlanTunnel(self, src=self.pg0.local_ip4, dst=self.mcast_ip4,
+ mcast_sw_if_index=1, vni=self.mcast_flood_bd)
+ r.add_vpp_config()
+ self.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=r.sw_if_index,
+ bd_id=self.mcast_flood_bd)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg2.sw_if_index, bd_id=self.mcast_flood_bd)
+
+ # Add and delete mcast tunnels to check stability
+ self.add_shared_mcast_dst_load()
+ self.add_mcast_tunnels_load()
+ self.del_shared_mcast_dst_load()
+ self.del_mcast_tunnels_load()
+
+ # Setup vni 3 to test unicast flooding
+ self.ucast_flood_bd = 3
+ self.create_vxlan_flood_test_bd(self.ucast_flood_bd,
+ self.n_ucast_tunnels)
+ self.vapi.sw_interface_set_l2_bridge(
+ rx_sw_if_index=self.pg3.sw_if_index, bd_id=self.ucast_flood_bd)
+
+ def test_decap(self):
+ """ Decapsulation test
+ from BridgeDoman
+ """
+ super(TestVxlan, self).test_decap()
+
def test_encap_big_packet(self):
""" Encapsulation test send big frame from pg1
Verify receipt of encapsulated frames on pg0