vpp_papi_provider: Remove more wrapper functions.
[vpp.git] / test / test_acl_plugin_l2l3.py
index 8e6b9e3..05c043e 100644 (file)
@@ -28,6 +28,7 @@ from socket import inet_pton, AF_INET, AF_INET6
 from random import choice, shuffle
 from pprint import pprint
 
+import scapy.compat
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether
 from scapy.layers.inet import IP, UDP, ICMP, TCP
@@ -40,8 +41,8 @@ from vpp_papi_provider import L2_PORT_TYPE
 import time
 
 
-class TestAclIpIrb(VppTestCase):
-    """IRB Test Case"""
+class TestACLpluginL2L3(VppTestCase):
+    """TestACLpluginL2L3 Test Case"""
 
     @classmethod
     def setUpClass(cls):
@@ -53,7 +54,7 @@ class TestAclIpIrb(VppTestCase):
         #. Loopback BVI interface has remote hosts, one half of hosts are
            behind pg0 second behind pg1.
         """
-        super(TestAclIpIrb, cls).setUpClass()
+        super(TestACLpluginL2L3, cls).setUpClass()
 
         cls.pg_if_packet_sizes = [64, 512, 1518, 9018]  # packet sizes
         cls.bd_id = 10
@@ -71,12 +72,12 @@ class TestAclIpIrb(VppTestCase):
 
         # Create BD with MAC learning enabled and put interfaces to this BD
         cls.vapi.sw_interface_set_l2_bridge(
-            cls.loop0.sw_if_index, bd_id=cls.bd_id,
+            rx_sw_if_index=cls.loop0.sw_if_index, bd_id=cls.bd_id,
             port_type=L2_PORT_TYPE.BVI)
-        cls.vapi.sw_interface_set_l2_bridge(
-            cls.pg0.sw_if_index, bd_id=cls.bd_id)
-        cls.vapi.sw_interface_set_l2_bridge(
-            cls.pg1.sw_if_index, bd_id=cls.bd_id)
+        cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=cls.pg0.sw_if_index,
+                                            bd_id=cls.bd_id)
+        cls.vapi.sw_interface_set_l2_bridge(rx_sw_if_index=cls.pg1.sw_if_index,
+                                            bd_id=cls.bd_id)
 
         # Configure IPv4 addresses on loopback interface and routed interface
         cls.loop0.config_ip4()
@@ -108,7 +109,7 @@ class TestAclIpIrb(VppTestCase):
         ``show l2fib verbose``,``show bridge-domain <bd_id> detail``,
         ``show ip arp``.
         """
-        super(TestAclIpIrb, self).tearDown()
+        super(TestACLpluginL2L3, self).tearDown()
         if not self.vpp_dead:
             self.logger.info(self.vapi.cli("show l2patch"))
             self.logger.info(self.vapi.cli("show classify tables"))
@@ -308,12 +309,14 @@ class TestAclIpIrb(VppTestCase):
             # Scapy IPv6 stuff is too smart for its own good.
             # So we do this and coerce the ICMP into unknown type
             if packet.haslayer(UDP):
-                data = str(packet[UDP][Raw])
+                data = scapy.compat.raw(packet[UDP][Raw])
             else:
                 if l3 == IP:
-                    data = str(ICMP(str(packet[l3].payload))[Raw])
+                    data = scapy.compat.raw(ICMP(
+                        scapy.compat.raw(packet[l3].payload))[Raw])
                 else:
-                    data = str(ICMPv6Unknown(str(packet[l3].payload)).msgbody)
+                    data = scapy.compat.raw(ICMPv6Unknown(
+                        scapy.compat.raw(packet[l3].payload)).msgbody)
             udp_or_icmp = packet[l3].payload
             payload_info = self.payload_to_info(data)
             packet_index = payload_info.index
@@ -369,17 +372,17 @@ class TestAclIpIrb(VppTestCase):
         shuffle(all_rules)
         reply = self.vapi.acl_add_replace(acl_index=4294967295,
                                           r=all_rules[::2],
-                                          tag="shuffle 1. acl")
+                                          tag=b"shuffle 1. acl")
         shuffle_acl_1 = reply.acl_index
         shuffle(all_rules)
         reply = self.vapi.acl_add_replace(acl_index=4294967295,
                                           r=all_rules[::3],
-                                          tag="shuffle 2. acl")
+                                          tag=b"shuffle 2. acl")
         shuffle_acl_2 = reply.acl_index
         shuffle(all_rules)
         reply = self.vapi.acl_add_replace(acl_index=4294967295,
                                           r=all_rules[::2],
-                                          tag="shuffle 3. acl")
+                                          tag=b"shuffle 3. acl")
         shuffle_acl_3 = reply.acl_index
 
         # apply the shuffle ACLs in front
@@ -404,15 +407,15 @@ class TestAclIpIrb(VppTestCase):
             shuffle(all_rules)
             reply = self.vapi.acl_add_replace(acl_index=shuffle_acl_1,
                                               r=all_rules[::1+(i % 2)],
-                                              tag="shuffle 1. acl")
+                                              tag=b"shuffle 1. acl")
             shuffle(all_rules)
             reply = self.vapi.acl_add_replace(acl_index=shuffle_acl_2,
                                               r=all_rules[::1+(i % 3)],
-                                              tag="shuffle 2. acl")
+                                              tag=b"shuffle 2. acl")
             shuffle(all_rules)
             reply = self.vapi.acl_add_replace(acl_index=shuffle_acl_2,
                                               r=all_rules[::1+(i % 5)],
-                                              tag="shuffle 3. acl")
+                                              tag=b"shuffle 3. acl")
 
         # restore to how it was before and clean up
         self.vapi.acl_interface_set_acl_list(sw_if_index=sw_if_index,
@@ -429,10 +432,10 @@ class TestAclIpIrb(VppTestCase):
         r_permit_reflect = stream_dict['permit_and_reflect_rules']
         r_action = r_permit_reflect if is_reflect else r
         reply = self.vapi.acl_add_replace(acl_index=4294967295, r=r_action,
-                                          tag="act. acl")
+                                          tag=b"act. acl")
         action_acl_index = reply.acl_index
         reply = self.vapi.acl_add_replace(acl_index=4294967295, r=r_permit,
-                                          tag="perm. acl")
+                                          tag=b"perm. acl")
         permit_acl_index = reply.acl_index
         return {'L2': action_acl_index if test_l2_action else permit_acl_index,
                 'L3': permit_acl_index if test_l2_action else action_acl_index,