diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/framework.py | 10 | ||||
-rw-r--r-- | test/test_acl_plugin_l2l3.py | 2 | ||||
-rw-r--r-- | test/test_acl_plugin_macip.py | 2 | ||||
-rw-r--r-- | test/test_bfd.py | 6 | ||||
-rw-r--r-- | test/test_container.py | 2 | ||||
-rw-r--r-- | test/test_dvr.py | 12 | ||||
-rw-r--r-- | test/test_gbp.py | 8 | ||||
-rw-r--r-- | test/test_interface_crud.py | 4 | ||||
-rw-r--r-- | test/test_ip4_irb.py | 2 | ||||
-rw-r--r-- | test/test_ip_mcast.py | 4 | ||||
-rw-r--r-- | test/test_qos.py | 8 | ||||
-rw-r--r-- | test/test_sctp.py | 2 | ||||
-rw-r--r-- | test/test_session.py | 2 | ||||
-rw-r--r-- | test/test_tcp.py | 2 | ||||
-rw-r--r-- | test/test_udp.py | 8 | ||||
-rw-r--r-- | test/test_vcl.py | 8 | ||||
-rw-r--r-- | test/vpp_bond_interface.py | 5 | ||||
-rw-r--r-- | test/vpp_gre_interface.py | 10 | ||||
-rw-r--r-- | test/vpp_lo_interface.py | 8 | ||||
-rw-r--r-- | test/vpp_mpls_tunnel_interface.py | 5 | ||||
-rw-r--r-- | test/vpp_pppoe_interface.py | 7 | ||||
-rw-r--r-- | test/vpp_sub_interface.py | 25 | ||||
-rw-r--r-- | test/vpp_vhost_interface.py | 5 |
23 files changed, 86 insertions, 61 deletions
diff --git a/test/framework.py b/test/framework.py index dd4774dc72b..be8c209f4ea 100644 --- a/test/framework.py +++ b/test/framework.py @@ -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 diff --git a/test/test_acl_plugin_l2l3.py b/test/test_acl_plugin_l2l3.py index 26b562e8ad0..b971610d5d4 100644 --- a/test/test_acl_plugin_l2l3.py +++ b/test/test_acl_plugin_l2l3.py @@ -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) diff --git a/test/test_acl_plugin_macip.py b/test/test_acl_plugin_macip.py index 8bcef25c49a..a8df833cd26 100644 --- a/test/test_acl_plugin_macip.py +++ b/test/test_acl_plugin_macip.py @@ -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 = [ diff --git a/test/test_bfd.py b/test/test_bfd.py index 3afe9428025..3b36f558a7e 100644 --- a/test/test_bfd.py +++ b/test/test_bfd.py @@ -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", diff --git a/test/test_container.py b/test/test_container.py index 66357a7389a..99a527b8796 100644 --- a/test/test_container.py +++ b/test/test_container.py @@ -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() diff --git a/test/test_dvr.py b/test/test_dvr.py index 9d8675832ea..5bdc3b2312e 100644 --- a/test/test_dvr.py +++ b/test/test_dvr.py @@ -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() diff --git a/test/test_gbp.py b/test/test_gbp.py index 7ee4d76550c..fe19ae6a27f 100644 --- a/test/test_gbp.py +++ b/test/test_gbp.py @@ -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" diff --git a/test/test_interface_crud.py b/test/test_interface_crud.py index d78cb58be0b..63917047ed4 100644 --- a/test/test_interface_crud.py +++ b/test/test_interface_crud.py @@ -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() diff --git a/test/test_ip4_irb.py b/test/test_ip4_irb.py index 460cb43b726..bbec7ca709f 100644 --- a/test/test_ip4_irb.py +++ b/test/test_ip4_irb.py @@ -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) diff --git a/test/test_ip_mcast.py b/test/test_ip_mcast.py index 9c216d5657d..017f0629cd2 100644 --- a/test/test_ip_mcast.py +++ b/test/test_ip_mcast.py @@ -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 diff --git a/test/test_qos.py b/test/test_qos.py index 939cca5d8d1..a940bd3a64c 100644 --- a/test/test_qos.py +++ b/test/test_qos.py @@ -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 diff --git a/test/test_sctp.py b/test/test_sctp.py index 9396f0514f3..32068abf76e 100644 --- a/test/test_sctp.py +++ b/test/test_sctp.py @@ -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 diff --git a/test/test_session.py b/test/test_session.py index 55541b70527..047b8ca553a 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -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 diff --git a/test/test_tcp.py b/test/test_tcp.py index 4a5c9bc4ff3..3b36bdf416b 100644 --- a/test/test_tcp.py +++ b/test/test_tcp.py @@ -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 diff --git a/test/test_udp.py b/test/test_udp.py index 230335ff169..aabbbd3cdcf 100644 --- a/test/test_udp.py +++ b/test/test_udp.py @@ -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 diff --git a/test/test_vcl.py b/test/test_vcl.py index 79eb75f364f..cba8c67b5c7 100644 --- a/test/test_vcl.py +++ b/test/test_vcl.py @@ -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): diff --git a/test/vpp_bond_interface.py b/test/vpp_bond_interface.py index 153f1142c5c..4bd7cb8235c 100644 --- a/test/vpp_bond_interface.py +++ b/test/vpp_bond_interface.py @@ -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) diff --git a/test/vpp_gre_interface.py b/test/vpp_gre_interface.py index d5a40eeb03d..3de3e5c4559 100644 --- a/test/vpp_gre_interface.py +++ b/test/vpp_gre_interface.py @@ -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) diff --git a/test/vpp_lo_interface.py b/test/vpp_lo_interface.py index 36f56bed8d7..ae4111bec82 100644 --- a/test/vpp_lo_interface.py +++ b/test/vpp_lo_interface.py @@ -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) diff --git a/test/vpp_mpls_tunnel_interface.py b/test/vpp_mpls_tunnel_interface.py index 995ffb7dd54..2e0ed67ce83 100644 --- a/test/vpp_mpls_tunnel_interface.py +++ b/test/vpp_mpls_tunnel_interface.py @@ -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: diff --git a/test/vpp_pppoe_interface.py b/test/vpp_pppoe_interface.py index 507d8251442..fbb78bcc55f 100644 --- a/test/vpp_pppoe_interface.py +++ b/test/vpp_pppoe_interface.py @@ -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, diff --git a/test/vpp_sub_interface.py b/test/vpp_sub_interface.py index 3c726b29d3f..38d24041e81 100644 --- a/test/vpp_sub_interface.py +++ b/test/vpp_sub_interface.py @@ -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 diff --git a/test/vpp_vhost_interface.py b/test/vpp_vhost_interface.py index e86be5d27b5..2249b062a64 100644 --- a/test/vpp_vhost_interface.py +++ b/test/vpp_vhost_interface.py @@ -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) |