X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_udp.py;h=fc77434184c2e3eadeceb239d4d394847fd77efd;hb=097fa66b9;hp=d0ad23fb230e8737ae462456e7a4bcd9ac62319d;hpb=9a6dafd569db0d0b5dc9d7b5b34b17e3f411a9ee;p=vpp.git diff --git a/test/test_udp.py b/test/test_udp.py index d0ad23fb230..fc77434184c 100644 --- a/test/test_udp.py +++ b/test/test_udp.py @@ -1,8 +1,10 @@ #!/usr/bin/env python import unittest from framework import VppTestCase, VppTestRunner + from vpp_udp_encap import find_udp_encap, VppUdpEncap -from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, VppMplsLabel +from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, VppMplsLabel, \ + FibPathType from scapy.packet import Raw from scapy.layers.l2 import Ether @@ -10,10 +12,20 @@ from scapy.layers.inet import IP, UDP from scapy.layers.inet6 import IPv6 from scapy.contrib.mpls import MPLS +NUM_PKTS = 67 + class TestUdpEncap(VppTestCase): """ UDP Encap Test Case """ + @classmethod + def setUpClass(cls): + super(TestUdpEncap, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestUdpEncap, cls).tearDownClass() + def setUp(self): super(TestUdpEncap, self).setUp() @@ -85,7 +97,7 @@ class TestUdpEncap(VppTestCase): # # construct a UDP encap object through each of the peers - # v4 through the first two peears, v6 through the second. + # v4 through the first two peers, v6 through the second. # udp_encap_0 = VppUdpEncap(self, self.pg0.local_ip4, @@ -121,32 +133,34 @@ class TestUdpEncap(VppTestCase): # # Routes via each UDP encap object - all combinations of v4 and v6. # - route_4o4 = VppIpRoute(self, "1.1.0.1", 32, - [VppRoutePath("0.0.0.0", - 0xFFFFFFFF, - is_udp_encap=1, - next_hop_id=udp_encap_0.id)]) - route_4o6 = VppIpRoute(self, "1.1.2.1", 32, - [VppRoutePath("0.0.0.0", - 0xFFFFFFFF, - is_udp_encap=1, - next_hop_id=udp_encap_2.id)]) - route_6o4 = VppIpRoute(self, "2001::1", 128, - [VppRoutePath("0.0.0.0", - 0xFFFFFFFF, - is_udp_encap=1, - next_hop_id=udp_encap_1.id)], - is_ip6=1) - route_6o6 = VppIpRoute(self, "2001::3", 128, - [VppRoutePath("0.0.0.0", - 0xFFFFFFFF, - is_udp_encap=1, - next_hop_id=udp_encap_3.id)], - is_ip6=1) - route_4o4.add_vpp_config() + route_4o4 = VppIpRoute( + self, "1.1.0.1", 32, + [VppRoutePath("0.0.0.0", + 0xFFFFFFFF, + type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP, + next_hop_id=udp_encap_0.id)]) + route_4o6 = VppIpRoute( + self, "1.1.2.1", 32, + [VppRoutePath("0.0.0.0", + 0xFFFFFFFF, + type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP, + next_hop_id=udp_encap_2.id)]) + route_6o4 = VppIpRoute( + self, "2001::1", 128, + [VppRoutePath("0.0.0.0", + 0xFFFFFFFF, + type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP, + next_hop_id=udp_encap_1.id)]) + route_6o6 = VppIpRoute( + self, "2001::3", 128, + [VppRoutePath("0.0.0.0", + 0xFFFFFFFF, + type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP, + next_hop_id=udp_encap_3.id)]) route_4o6.add_vpp_config() route_6o6.add_vpp_config() route_6o4.add_vpp_config() + route_4o4.add_vpp_config() # # 4o4 encap @@ -156,12 +170,12 @@ class TestUdpEncap(VppTestCase): IP(src="2.2.2.2", dst="1.1.0.1") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_4o4*65, self.pg0) + rx = self.send_and_expect(self.pg0, p_4o4*NUM_PKTS, self.pg0) for p in rx: self.validate_outer4(p, udp_encap_0) p = IP(p["UDP"].payload.load) self.validate_inner4(p, p_4o4) - self.assertEqual(udp_encap_0.get_stats()['packets'], 65) + self.assertEqual(udp_encap_0.get_stats()['packets'], NUM_PKTS) # # 4o6 encap @@ -171,12 +185,12 @@ class TestUdpEncap(VppTestCase): IP(src="2.2.2.2", dst="1.1.2.1") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_4o6*65, self.pg2) + rx = self.send_and_expect(self.pg0, p_4o6*NUM_PKTS, self.pg2) for p in rx: self.validate_outer6(p, udp_encap_2) p = IP(p["UDP"].payload.load) self.validate_inner4(p, p_4o6) - self.assertEqual(udp_encap_2.get_stats()['packets'], 65) + self.assertEqual(udp_encap_2.get_stats()['packets'], NUM_PKTS) # # 6o4 encap @@ -186,12 +200,12 @@ class TestUdpEncap(VppTestCase): IPv6(src="2001::100", dst="2001::1") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_6o4*65, self.pg1) + rx = self.send_and_expect(self.pg0, p_6o4*NUM_PKTS, self.pg1) for p in rx: self.validate_outer4(p, udp_encap_1) p = IPv6(p["UDP"].payload.load) self.validate_inner6(p, p_6o4) - self.assertEqual(udp_encap_1.get_stats()['packets'], 65) + self.assertEqual(udp_encap_1.get_stats()['packets'], NUM_PKTS) # # 6o6 encap @@ -201,23 +215,24 @@ class TestUdpEncap(VppTestCase): IPv6(src="2001::100", dst="2001::3") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_6o6*65, self.pg3) + rx = self.send_and_expect(self.pg0, p_6o6*NUM_PKTS, self.pg3) for p in rx: self.validate_outer6(p, udp_encap_3) p = IPv6(p["UDP"].payload.load) self.validate_inner6(p, p_6o6) - self.assertEqual(udp_encap_3.get_stats()['packets'], 65) + self.assertEqual(udp_encap_3.get_stats()['packets'], NUM_PKTS) # # A route with an output label # the TTL of the inner packet is decremented on LSP ingress # - route_4oMPLSo4 = VppIpRoute(self, "1.1.2.22", 32, - [VppRoutePath("0.0.0.0", - 0xFFFFFFFF, - is_udp_encap=1, - next_hop_id=1, - labels=[VppMplsLabel(66)])]) + route_4oMPLSo4 = VppIpRoute( + self, "1.1.2.22", 32, + [VppRoutePath("0.0.0.0", + 0xFFFFFFFF, + type=FibPathType.FIB_PATH_TYPE_UDP_ENCAP, + next_hop_id=1, + labels=[VppMplsLabel(66)])]) route_4oMPLSo4.add_vpp_config() p_4omo4 = (Ether(src=self.pg0.remote_mac, @@ -225,12 +240,12 @@ class TestUdpEncap(VppTestCase): IP(src="2.2.2.2", dst="1.1.2.22") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_4omo4*65, self.pg1) + rx = self.send_and_expect(self.pg0, p_4omo4*NUM_PKTS, self.pg1) for p in rx: self.validate_outer4(p, udp_encap_1) p = MPLS(p["UDP"].payload.load) self.validate_inner4(p, p_4omo4, ttl=63) - self.assertEqual(udp_encap_1.get_stats()['packets'], 130) + self.assertEqual(udp_encap_1.get_stats()['packets'], 2*NUM_PKTS) class TestUDP(VppTestCase): @@ -240,6 +255,10 @@ class TestUDP(VppTestCase): def setUpClass(cls): super(TestUDP, cls).setUpClass() + @classmethod + def tearDownClass(cls): + super(TestUDP, cls).tearDownClass() + def setUp(self): super(TestUDP, self).setUp() self.vapi.session_enable_disable(is_enabled=1)