Revert "make test: fix broken interfaces" 92/13192/1
authorOle Troan <ot@cisco.com>
Fri, 22 Jun 2018 20:33:41 +0000 (22:33 +0200)
committerOle Troan <ot@cisco.com>
Fri, 22 Jun 2018 20:34:56 +0000 (22:34 +0200)
This reverts commit d5c60b96a3fd93916fc4af5c8d6d25625c28242e.

Change-Id: I3632b9c3f76c615aee897f28f76d094e7031e689
Signed-off-by: Ole Troan <ot@cisco.com>
23 files changed:
test/framework.py
test/test_acl_plugin_l2l3.py
test/test_acl_plugin_macip.py
test/test_bfd.py
test/test_container.py
test/test_dvr.py
test/test_gbp.py
test/test_interface_crud.py
test/test_ip4_irb.py
test/test_ip_mcast.py
test/test_qos.py
test/test_sctp.py
test/test_session.py
test/test_tcp.py
test/test_udp.py
test/test_vcl.py
test/vpp_bond_interface.py
test/vpp_gre_interface.py
test/vpp_lo_interface.py
test/vpp_mpls_tunnel_interface.py
test/vpp_pppoe_interface.py
test/vpp_sub_interface.py
test/vpp_vhost_interface.py

index dd4774d..be8c209 100644 (file)
@@ -558,16 +558,18 @@ class VppTestCase(unittest.TestCase):
         return result
 
     @classmethod
-    def create_loopback_interfaces(cls, count):
+    def create_loopback_interfaces(cls, interfaces):
         """
         Create loopback interfaces.
 
-        :param count: number of interfaces created.
+        :param interfaces: iterable indexes of the interfaces.
         :returns: List of created interfaces.
         """
-        result = [VppLoInterface(cls) for i in range(count)]
-        for intf in result:
+        result = []
+        for i in interfaces:
+            intf = VppLoInterface(cls, i)
             setattr(cls, intf.name, intf)
+            result.append(intf)
         cls.lo_interfaces = result
         return result
 
index 26b562e..b971610 100644 (file)
@@ -60,7 +60,7 @@ class TestIpIrb(VppTestCase):
 
         # create 3 pg interfaces, 1 loopback interface
         cls.create_pg_interfaces(range(3))
-        cls.create_loopback_interfaces(1)
+        cls.create_loopback_interfaces(range(1))
 
         cls.interfaces = list(cls.pg_interfaces)
         cls.interfaces.extend(cls.lo_interfaces)
index 8bcef25..a8df833 100644 (file)
@@ -63,7 +63,7 @@ class MethodHolder(VppTestCase):
         try:
             # create 4 pg interfaces, 1 loopback interface
             cls.create_pg_interfaces(range(4))
-            cls.create_loopback_interfaces(1)
+            cls.create_loopback_interfaces(range(1))
 
             # create 2 subinterfaces
             cls.subifs = [
index 3afe942..3b36f55 100644 (file)
@@ -629,7 +629,7 @@ class BFD4TestCase(VppTestCase):
         cls.vapi.cli("set log class bfd level debug")
         try:
             cls.create_pg_interfaces([0])
-            cls.create_loopback_interfaces(1)
+            cls.create_loopback_interfaces([0])
             cls.loopback0 = cls.lo_interfaces[0]
             cls.loopback0.config_ip4()
             cls.loopback0.admin_up()
@@ -1439,7 +1439,7 @@ class BFD6TestCase(VppTestCase):
             cls.pg0.configure_ipv6_neighbors()
             cls.pg0.admin_up()
             cls.pg0.resolve_ndp()
-            cls.create_loopback_interfaces(1)
+            cls.create_loopback_interfaces([0])
             cls.loopback0 = cls.lo_interfaces[0]
             cls.loopback0.config_ip6()
             cls.loopback0.admin_up()
@@ -2557,7 +2557,7 @@ class BFDCLITestCase(VppTestCase):
 
     def test_set_del_udp_echo_source(self):
         """ set/del udp echo source """
-        self.create_loopback_interfaces(1)
+        self.create_loopback_interfaces([0])
         self.loopback0 = self.lo_interfaces[0]
         self.loopback0.admin_up()
         self.cli_verify_response("show bfd echo-source",
index 66357a7..99a527b 100644 (file)
@@ -73,7 +73,7 @@ class ContainerIntegrationTestCase(VppTestCase):
 
     def test_0050_loopback_prepare_test(self):
         """ Create loopbacks overlapping with remote addresses """
-        self.create_loopback_interfaces(2)
+        self.create_loopback_interfaces(range(2))
         for i in range(2):
             intf = self.lo_interfaces[i]
             intf.admin_up()
index 9d86758..5bdc3b2 100644 (file)
@@ -1,14 +1,18 @@
 #!/usr/bin/env python
+import random
+import socket
 import unittest
 
 from framework import VppTestCase, VppTestRunner
-from vpp_sub_interface import VppDot1QSubint
-from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_sub_interface import VppSubInterface, VppDot1QSubint
+from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto, VppIpMRoute, \
+    VppMRoutePath, MRouteEntryFlags, MRouteItfFlags
 from vpp_papi_provider import L2_VTR_OP
 
 from scapy.packet import Raw
-from scapy.layers.l2 import Ether, Dot1Q
+from scapy.layers.l2 import Ether, Dot1Q, ARP
 from scapy.layers.inet import IP, UDP
+from util import ppp
 from socket import AF_INET, inet_pton
 
 
@@ -19,7 +23,7 @@ class TestDVR(VppTestCase):
         super(TestDVR, self).setUp()
 
         self.create_pg_interfaces(range(4))
-        self.create_loopback_interfaces(1)
+        self.create_loopback_interfaces(range(1))
 
         for i in self.pg_interfaces:
             i.admin_up()
index 7ee4d76..fe19ae6 100644 (file)
@@ -1,6 +1,8 @@
 #!/usr/bin/env python
 
 import unittest
+import socket
+import struct
 
 from framework import VppTestCase, VppTestRunner
 from vpp_object import VppObject
@@ -11,12 +13,12 @@ from scapy.packet import Raw
 from scapy.layers.l2 import Ether, ARP
 from scapy.layers.inet import IP, UDP
 from scapy.layers.inet6 import IPv6, ICMPv6ND_NS,  ICMPv6NDOptSrcLLAddr, \
-    ICMPv6ND_NA
+    ICMPv6NDOptDstLLAddr, ICMPv6ND_NA
 from scapy.utils6 import in6_getnsma, in6_getnsmac
 
 from socket import AF_INET, AF_INET6
 from scapy.utils import inet_pton, inet_ntop
-from util import mactobinary
+from util import Host, mactobinary
 
 
 class VppGbpEndpoint(VppObject):
@@ -298,7 +300,7 @@ class TestGBP(VppTestCase):
         super(TestGBP, self).setUp()
 
         self.create_pg_interfaces(range(9))
-        self.create_loopback_interfaces(9)
+        self.create_loopback_interfaces(range(9))
 
         self.router_mac = "00:11:22:33:44:55"
 
index d78cb58..6391704 100644 (file)
@@ -79,7 +79,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
 
     def test_crud(self):
         # create
-        loopbacks = self.create_loopback_interfaces(20)
+        loopbacks = self.create_loopback_interfaces(range(20))
         for i in loopbacks:
             i.local_ip4_prefix_len = 32
             i.config_ip4()
@@ -121,7 +121,7 @@ class TestLoopbackInterfaceCRUD(VppTestCase):
 
     def test_down(self):
         # create
-        loopbacks = self.create_loopback_interfaces(20)
+        loopbacks = self.create_loopback_interfaces(range(20))
         for i in loopbacks:
             i.local_ip4_prefix_len = 32
             i.config_ip4()
index 460cb43..bbec7ca 100644 (file)
@@ -54,7 +54,7 @@ class TestIpIrb(VppTestCase):
 
         # create 3 pg interfaces, 1 loopback interface
         cls.create_pg_interfaces(range(3))
-        cls.create_loopback_interfaces(1)
+        cls.create_loopback_interfaces(range(1))
 
         cls.interfaces = list(cls.pg_interfaces)
         cls.interfaces.extend(cls.lo_interfaces)
index 9c216d5..017f062 100644 (file)
@@ -3,13 +3,15 @@
 import unittest
 
 from framework import VppTestCase, VppTestRunner
+from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint
 from vpp_ip_route import VppIpMRoute, VppMRoutePath, VppMFibSignal, \
     MRouteItfFlags, MRouteEntryFlags, VppIpTable, DpoProto
 
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether
-from scapy.layers.inet import IP, UDP, getmacbyip
+from scapy.layers.inet import IP, UDP, getmacbyip, ICMP
 from scapy.layers.inet6 import IPv6, getmacbyip6
+from util import ppp
 
 #
 # The number of packets sent is set to 91 so that when we replicate more than 3
index 939cca5..a940bd3 100644 (file)
@@ -1,13 +1,17 @@
 #!/usr/bin/env python
 
 import unittest
+import socket
+import struct
 
 from framework import VppTestCase, VppTestRunner
+from vpp_object import VppObject
 from vpp_papi_provider import QOS_SOURCE
-from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsRoute
+from vpp_sub_interface import VppSubInterface, VppDot1QSubint
 
 from scapy.packet import Raw
-from scapy.layers.l2 import Ether
+from scapy.layers.l2 import Ether, Dot1Q
 from scapy.layers.inet import IP, UDP
 from scapy.layers.inet6 import IPv6
 from scapy.contrib.mpls import MPLS
index 9396f05..32068ab 100644 (file)
@@ -16,7 +16,7 @@ class TestSCTP(VppTestCase):
     def setUp(self):
         super(TestSCTP, self).setUp()
         self.vapi.session_enable_disable(is_enabled=1)
-        self.create_loopback_interfaces(2)
+        self.create_loopback_interfaces(range(2))
 
         table_id = 0
 
index 55541b7..047b8ca 100644 (file)
@@ -17,7 +17,7 @@ class TestSession(VppTestCase):
         super(TestSession, self).setUp()
 
         self.vapi.session_enable_disable(is_enabled=1)
-        self.create_loopback_interfaces(2)
+        self.create_loopback_interfaces(range(2))
 
         table_id = 0
 
index 4a5c9bc..3b36bdf 100644 (file)
@@ -16,7 +16,7 @@ class TestTCP(VppTestCase):
     def setUp(self):
         super(TestTCP, self).setUp()
         self.vapi.session_enable_disable(is_enabled=1)
-        self.create_loopback_interfaces(2)
+        self.create_loopback_interfaces(range(2))
 
         table_id = 0
 
index 230335f..aabbbd3 100644 (file)
@@ -1,11 +1,11 @@
 #!/usr/bin/env python
-import unittest
+
 from framework import VppTestCase, VppTestRunner
-from vpp_udp_encap import VppUdpEncap
+from vpp_udp_encap import *
 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, VppMplsLabel
 
 from scapy.packet import Raw
-from scapy.layers.l2 import Ether
+from scapy.layers.l2 import Ether, ARP
 from scapy.layers.inet import IP, UDP
 from scapy.layers.inet6 import IPv6
 from scapy.contrib.mpls import MPLS
@@ -233,7 +233,7 @@ class TestUDP(VppTestCase):
     def setUp(self):
         super(TestUDP, self).setUp()
         self.vapi.session_enable_disable(is_enabled=1)
-        self.create_loopback_interfaces(2)
+        self.create_loopback_interfaces(range(2))
 
         table_id = 0
 
index 79eb75f..cba8c67 100644 (file)
@@ -68,12 +68,12 @@ class VCLTestCase(VppTestCase):
         worker_client.join(self.timeout)
         try:
             self.validateResults(worker_client, worker_server, self.timeout)
-        except Exception as error:
+        except Exception, error:
             self.fail("Failed with %s" % error)
 
     def thru_host_stack_setup(self):
         self.vapi.session_enable_disable(is_enabled=1)
-        self.create_loopback_interfaces(2)
+        self.create_loopback_interfaces(range(2))
 
         table_id = 1
 
@@ -117,7 +117,7 @@ class VCLTestCase(VppTestCase):
 
     def thru_host_stack_ipv6_setup(self):
         self.vapi.session_enable_disable(is_enabled=1)
-        self.create_loopback_interfaces(2)
+        self.create_loopback_interfaces(range(2))
 
         table_id = 1
 
@@ -182,7 +182,7 @@ class VCLTestCase(VppTestCase):
 
         try:
             self.validateResults(worker_client, worker_server, self.timeout)
-        except Exception as error:
+        except Exception, error:
             self.fail("Failed with %s" % error)
 
     def validateResults(self, worker_client, worker_server, timeout):
index 153f114..4bd7cb8 100644 (file)
@@ -9,7 +9,7 @@ class VppBondInterface(VppInterface):
                  use_custom_mac=0, mac_address=''):
 
         """ Create VPP Bond interface """
-        super(VppBondInterface, self).__init__(test)
+        self._test = test
         self.mode = mode
         self.lb = lb
         self.use_custom_mac = use_custom_mac
@@ -20,7 +20,8 @@ class VppBondInterface(VppInterface):
                                        self.lb,
                                        self.use_custom_mac,
                                        self.mac_address)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
+        super(VppBondInterface, self).__init__(self._test)
 
     def remove_vpp_config(self):
         self.test.vapi.bond_delete(self.sw_if_index)
index d5a40ee..3de3e5c 100644 (file)
@@ -11,7 +11,7 @@ class VppGreInterface(VppInterface):
     def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
                  session=0):
         """ Create VPP GRE interface """
-        super(VppGreInterface, self).__init__(test)
+        self._test = test
         self.t_src = src_ip
         self.t_dst = dst_ip
         self.t_outer_fib = outer_fib_id
@@ -25,9 +25,10 @@ class VppGreInterface(VppInterface):
                                               outer_fib_id=self.t_outer_fib,
                                               tunnel_type=self.t_type,
                                               session_id=self.t_session)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
         self.generate_remote_hosts()
         self.test.registry.register(self, self.test.logger)
+        super(VppGreInterface, self).__init__(self.test)
 
     def remove_vpp_config(self):
         s = socket.inet_pton(socket.AF_INET, self.t_src)
@@ -54,7 +55,7 @@ class VppGre6Interface(VppInterface):
     def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
                  session=0):
         """ Create VPP GRE interface """
-        super(VppGre6Interface, self).__init__(test)
+        self._test = test
         self.t_src = src_ip
         self.t_dst = dst_ip
         self.t_outer_fib = outer_fib_id
@@ -69,9 +70,10 @@ class VppGre6Interface(VppInterface):
                                               tunnel_type=self.t_type,
                                               session_id=self.t_session,
                                               is_ip6=1)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
         self.generate_remote_hosts()
         self.test.registry.register(self, self.test.logger)
+        super(VppGre6Interface, self).__init__(self.test)
 
     def remove_vpp_config(self):
         s = socket.inet_pton(socket.AF_INET6, self.t_src)
index 36f56be..ae4111b 100644 (file)
@@ -5,14 +5,16 @@ from vpp_interface import VppInterface
 class VppLoInterface(VppInterface, VppObject):
     """VPP loopback interface."""
 
-    def __init__(self, test):
+    def __init__(self, test, lo_index):
         """ Create VPP loopback interface """
-        super(VppLoInterface, self).__init__(test)
+        self._test = test
         self.add_vpp_config()
+        super(VppLoInterface, self).__init__(test)
+        self._lo_index = lo_index
 
     def add_vpp_config(self):
         r = self.test.vapi.create_loopback()
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
 
     def remove_vpp_config(self):
         self.test.vapi.delete_loopback(self.sw_if_index)
index 995ffb7..2e0ed67 100644 (file)
@@ -9,7 +9,7 @@ class VppMPLSTunnelInterface(VppInterface):
 
     def __init__(self, test, paths, is_multicast=0, is_l2=0):
         """ Create MPLS Tunnel interface """
-        super(VppMPLSTunnelInterface, self).__init__(test)
+        self._test = test
         self.t_paths = paths
         self.is_multicast = is_multicast
         self.is_l2 = is_l2
@@ -31,7 +31,8 @@ class VppMPLSTunnelInterface(VppInterface):
                 is_multicast=self.is_multicast,
                 l2_only=self.is_l2)
             sw_if_index = reply.sw_if_index
-        self.set_sw_if_index(sw_if_index)
+        self._sw_if_index = sw_if_index
+        super(VppMPLSTunnelInterface, self).__init__(self.test)
 
     def remove_vpp_config(self):
         for path in self.t_paths:
index 507d825..fbb78bc 100644 (file)
@@ -12,7 +12,7 @@ class VppPppoeInterface(VppInterface):
     def __init__(self, test, client_ip, client_mac,
                  session_id, decap_vrf_id=0):
         """ Create VPP PPPoE4 interface """
-        super(VppPppoeInterface, self).__init__(test)
+        self._test = test
         self.client_ip = client_ip
         self.client_mac = client_mac
         self.session_id = session_id
@@ -25,14 +25,15 @@ class VppPppoeInterface(VppInterface):
                 cip, cmac,
                 session_id=self.session_id,
                 decap_vrf_id=self.decap_vrf_id)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
+        super(VppPppoeInterface, self).__init__(self._test)
         self.generate_remote_hosts()
 
     def remove_vpp_config(self):
         cip = socket.inet_pton(socket.AF_INET, self.client_ip)
         cmac = mactobinary(self.client_mac)
         self.unconfig()
-        self.test.vapi.pppoe_add_del_session(
+        r = self.test.vapi.pppoe_add_del_session(
                 cip, cmac,
                 session_id=self.session_id,
                 decap_vrf_id=self.decap_vrf_id,
index 3c726b2..38d2404 100644 (file)
@@ -35,13 +35,10 @@ class VppSubInterface(VppPGInterface):
         self._parent = parent
         self._parent.add_sub_if(self)
         self._sub_id = sub_id
+        self.set_vtr(L2_VTR_OP.L2_DISABLED)
         self.DOT1AD_TYPE = 0x88A8
         self.DOT1Q_TYPE = 0x8100
 
-    def set_sw_if_index(self, sw_if_index):
-        super(VppSubInterface, self).set_sw_if_index(sw_if_index)
-        self.set_vtr(L2_VTR_OP.L2_DISABLED)
-
     @abstractmethod
     def create_arp_req(self):
         pass
@@ -50,12 +47,18 @@ class VppSubInterface(VppPGInterface):
     def create_ndp_req(self):
         pass
 
+    def resolve_arp(self):
+        super(VppSubInterface, self).resolve_arp(self.parent)
+
+    def resolve_ndp(self):
+        super(VppSubInterface, self).resolve_ndp(self.parent)
+
     @abstractmethod
     def add_dot1_layer(self, pkt):
         pass
 
     def remove_vpp_config(self):
-        self.test.vapi.delete_subif(self.sw_if_index)
+        self.test.vapi.delete_subif(self._sw_if_index)
 
     def _add_tag(self, packet, vlan, tag_type):
         payload = packet.payload
@@ -126,12 +129,12 @@ class VppDot1QSubint(VppSubInterface):
         return self._vlan
 
     def __init__(self, test, parent, sub_id, vlan=None):
-        super(VppDot1QSubint, self).__init__(test, parent, sub_id)
         if vlan is None:
             vlan = sub_id
         self._vlan = vlan
         r = test.vapi.create_vlan_subif(parent.sw_if_index, vlan)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
+        super(VppDot1QSubint, self).__init__(test, parent, sub_id)
 
     def create_arp_req(self):
         packet = VppPGInterface.create_arp_req(self)
@@ -163,13 +166,13 @@ class VppDot1ADSubint(VppSubInterface):
         return self._inner_vlan
 
     def __init__(self, test, parent, sub_id, outer_vlan, inner_vlan):
-        super(VppDot1ADSubint, self).__init__(test, parent, sub_id)
         r = test.vapi.create_subif(parent.sw_if_index, sub_id, outer_vlan,
                                    inner_vlan, dot1ad=1, two_tags=1,
                                    exact_match=1)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
         self._outer_vlan = outer_vlan
         self._inner_vlan = inner_vlan
+        super(VppDot1ADSubint, self).__init__(test, parent, sub_id)
 
     def create_arp_req(self):
         packet = VppPGInterface.create_arp_req(self)
@@ -190,12 +193,12 @@ class VppDot1ADSubint(VppSubInterface):
 class VppP2PSubint(VppSubInterface):
 
     def __init__(self, test, parent, sub_id, remote_mac):
-        super(VppP2PSubint, self).__init__(test, parent, sub_id)
         r = test.vapi.create_p2pethernet_subif(parent.sw_if_index,
                                                remote_mac, sub_id)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
         self.parent_sw_if_index = parent.sw_if_index
         self.p2p_remote_mac = remote_mac
+        super(VppP2PSubint, self).__init__(test, parent, sub_id)
 
     def add_dot1_layer(self, packet):
         return packet
index e86be5d..2249b06 100644 (file)
@@ -9,7 +9,7 @@ class VppVhostInterface(VppInterface):
                  tag=''):
 
         """ Create VPP Vhost interface """
-        super(VppVhostInterface, self).__init__(test)
+        self._test = test
         self.is_server = is_server
         self.sock_filename = sock_filename
         self.renumber = renumber
@@ -26,7 +26,8 @@ class VppVhostInterface(VppInterface):
                                                 self.use_custom_mac,
                                                 self.mac_address,
                                                 self.tag)
-        self.set_sw_if_index(r.sw_if_index)
+        self._sw_if_index = r.sw_if_index
+        super(VppVhostInterface, self).__init__(self._test)
 
     def remove_vpp_config(self):
         self.test.vapi.delete_vhost_user_if(self.sw_if_index)