summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_bier.py6
-rw-r--r--test/test_udp.py21
-rw-r--r--test/vpp_papi_provider.py3
-rw-r--r--test/vpp_udp_encap.py10
4 files changed, 22 insertions, 18 deletions
diff --git a/test/test_bier.py b/test/test_bier.py
index 9a1967cc459..b719f0cfbf6 100644
--- a/test/test_bier.py
+++ b/test/test_bier.py
@@ -666,7 +666,7 @@ class TestBier(VppTestCase):
labels=[VppMplsLabel(2001)])])
ip_route.add_vpp_config()
- udp_encap = VppUdpEncap(self, 4,
+ udp_encap = VppUdpEncap(self,
self.pg0.local_ip4,
nh1,
330, 8138)
@@ -677,7 +677,7 @@ class TestBier(VppTestCase):
[VppRoutePath("0.0.0.0",
0xFFFFFFFF,
is_udp_encap=1,
- next_hop_id=4)])
+ next_hop_id=udp_encap.id)])
bier_route.add_vpp_config()
#
@@ -727,7 +727,7 @@ class TestBier(VppTestCase):
self.assertEqual(rx[0][IP].dst, nh1)
self.assertEqual(rx[0][UDP].sport, 330)
self.assertEqual(rx[0][UDP].dport, 8138)
- self.assertEqual(rx[0][BIFT].bsl, 2)
+ self.assertEqual(rx[0][BIFT].bsl, BIERLength.BIER_LEN_256)
self.assertEqual(rx[0][BIFT].sd, 1)
self.assertEqual(rx[0][BIFT].set, 0)
self.assertEqual(rx[0][BIFT].ttl, 64)
diff --git a/test/test_udp.py b/test/test_udp.py
index b0c6ee9c46a..e04d7beaf06 100644
--- a/test/test_udp.py
+++ b/test/test_udp.py
@@ -87,21 +87,21 @@ class TestUdpEncap(VppTestCase):
# construct a UDP encap object through each of the peers
# v4 through the first two peears, v6 through the second.
#
- udp_encap_0 = VppUdpEncap(self, 0,
+ udp_encap_0 = VppUdpEncap(self,
self.pg0.local_ip4,
self.pg0.remote_ip4,
330, 440)
- udp_encap_1 = VppUdpEncap(self, 1,
+ udp_encap_1 = VppUdpEncap(self,
self.pg1.local_ip4,
self.pg1.remote_ip4,
331, 441,
table_id=1)
- udp_encap_2 = VppUdpEncap(self, 2,
+ udp_encap_2 = VppUdpEncap(self,
self.pg2.local_ip6,
self.pg2.remote_ip6,
332, 442,
table_id=2)
- udp_encap_3 = VppUdpEncap(self, 3,
+ udp_encap_3 = VppUdpEncap(self,
self.pg3.local_ip6,
self.pg3.remote_ip6,
333, 443,
@@ -125,23 +125,23 @@ class TestUdpEncap(VppTestCase):
[VppRoutePath("0.0.0.0",
0xFFFFFFFF,
is_udp_encap=1,
- next_hop_id=0)])
+ 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=2)])
+ 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=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=3)],
+ next_hop_id=udp_encap_3.id)],
is_ip6=1)
route_4o4.add_vpp_config()
route_4o6.add_vpp_config()
@@ -161,6 +161,7 @@ class TestUdpEncap(VppTestCase):
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)
#
# 4o6 encap
@@ -175,6 +176,7 @@ class TestUdpEncap(VppTestCase):
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)
#
# 6o4 encap
@@ -189,6 +191,7 @@ class TestUdpEncap(VppTestCase):
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)
#
# 6o6 encap
@@ -203,6 +206,7 @@ class TestUdpEncap(VppTestCase):
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)
#
# A route with an output label
@@ -226,6 +230,7 @@ class TestUdpEncap(VppTestCase):
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)
class TestUDP(VppTestCase):
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py
index e926c46f550..92173ef9a64 100644
--- a/test/vpp_papi_provider.py
+++ b/test/vpp_papi_provider.py
@@ -1150,14 +1150,12 @@ class VppPapiProvider(object):
)
def udp_encap_add(self,
- id,
src_ip,
dst_ip,
src_port,
dst_port,
table_id=0):
""" Add a GRE tunnel
- :param id: user provided ID
:param src_ip:
:param dst_ip:
:param src_port:
@@ -1169,7 +1167,6 @@ class VppPapiProvider(object):
self.papi.udp_encap_add,
{
'udp_encap': {
- 'id': id,
'src_ip': src_ip,
'dst_ip': dst_ip,
'src_port': src_port,
diff --git a/test/vpp_udp_encap.py b/test/vpp_udp_encap.py
index 826378b4de8..209115f2c3f 100644
--- a/test/vpp_udp_encap.py
+++ b/test/vpp_udp_encap.py
@@ -25,14 +25,12 @@ class VppUdpEncap(VppObject):
def __init__(self,
test,
- id,
src_ip,
dst_ip,
src_port,
dst_port,
table_id=0):
self._test = test
- self.id = id
self.table_id = table_id
self.src_ip_s = src_ip
self.dst_ip_s = dst_ip
@@ -42,13 +40,13 @@ class VppUdpEncap(VppObject):
self.dst_port = dst_port
def add_vpp_config(self):
- self._test.vapi.udp_encap_add(
- self.id,
+ r = self._test.vapi.udp_encap_add(
self.src_ip.encode(),
self.dst_ip.encode(),
self.src_port,
self.dst_port,
self.table_id)
+ self.id = r.id
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
@@ -62,3 +60,7 @@ class VppUdpEncap(VppObject):
def object_id(self):
return ("udp-encap-%d" % self.id)
+
+ def get_stats(self):
+ c = self._test.statistics.get_counter("/net/udp-encap")
+ return c[0][self.id]