X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_abf.py;h=1de36c922217ecc50d544ec25118b51f43923e16;hb=1b582b8e9264ca2514a5118ca0de0a3a5b8f5ba4;hp=fb30fc3018ceb412062c89eddbf5d49cac18f356;hpb=c0a93143412b4be7bba087bf633855aeeaee7c56;p=vpp.git diff --git a/test/test_abf.py b/test/test_abf.py index fb30fc3018c..1de36c92221 100644 --- a/test/test_abf.py +++ b/test/test_abf.py @@ -1,18 +1,18 @@ #!/usr/bin/env python +from socket import inet_pton, inet_ntop, AF_INET, AF_INET6 +import unittest + from framework import VppTestCase, VppTestRunner -from vpp_udp_encap import * from vpp_ip import DpoProto -from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable +from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsLabel, VppIpTable from scapy.packet import Raw -from scapy.layers.l2 import Ether, ARP +from scapy.layers.l2 import Ether from scapy.layers.inet import IP, UDP from scapy.layers.inet6 import IPv6 -from scapy.contrib.mpls import MPLS -from vpp_object import * -from socket import inet_pton, inet_ntop, AF_INET, AF_INET6 +from vpp_object import VppObject def find_abf_policy(test, id): @@ -88,9 +88,6 @@ class VppAbfPolicy(VppObject): def query_vpp_config(self): return find_abf_policy(self._test, self.policy_id) - def __str__(self): - return self.object_id() - def object_id(self): return ("abf-policy-%d" % self.policy_id) @@ -131,9 +128,6 @@ class VppAbfAttach(VppObject): self.policy_id, self.sw_if_index) - def __str__(self): - return self.object_id() - def object_id(self): return ("abf-attach-%d-%d" % (self.policy_id, self.sw_if_index)) @@ -141,12 +135,20 @@ class VppAbfAttach(VppObject): class TestAbf(VppTestCase): """ ABF Test Case """ + @classmethod + def setUpClass(cls): + super(TestAbf, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestAbf, cls).tearDownClass() + def setUp(self): super(TestAbf, self).setUp() - self.create_pg_interfaces(range(4)) + self.create_pg_interfaces(range(5)) - for i in self.pg_interfaces: + for i in self.pg_interfaces[:4]: i.admin_up() i.config_ip4() i.resolve_arp() @@ -171,7 +173,7 @@ class TestAbf(VppTestCase): # the application of ACLs to a forwarding path to achieve # ABF # So we construct just a few ACLs to ensure the ABF policies - # are correclty constructed and used. And a few path types + # are correctly constructed and used. And a few path types # to test the API path decoding. # @@ -266,6 +268,30 @@ class TestAbf(VppTestCase): self.send_and_assert_no_replies(self.pg1, p_2 * 65, "Detached") + # + # Swap to route via a next-hop in the non-default table + # + table_20 = VppIpTable(self, 20) + table_20.add_vpp_config() + + self.pg4.set_table_ip4(table_20.table_id) + self.pg4.admin_up() + self.pg4.config_ip4() + self.pg4.resolve_arp() + + abf_13 = VppAbfPolicy(self, 13, acl_1, + [VppRoutePath(self.pg4.remote_ip4, + 0xffffffff, + nh_table_id=table_20.table_id)]) + abf_13.add_vpp_config() + attach_5 = VppAbfAttach(self, 13, self.pg0.sw_if_index, 30) + attach_5.add_vpp_config() + + self.send_and_expect(self.pg0, p_1*65, self.pg4) + + self.pg4.unconfig_ip4() + self.pg4.set_table_ip4(0) + def test_abf6(self): """ IPv6 ACL Based Forwarding """