summaryrefslogtreecommitdiffstats
path: root/test/test_udp.py
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-05-14 13:25:49 -0400
committerPaul Vinciguerra <pvinci@vinciconsulting.com>2019-05-16 20:32:41 -0400
commit4271c971919bb8defa3ca54f4a362676cd57bfb2 (patch)
tree12fbe708b49f04dc5c088a2deefba0c451d95b64 /test/test_udp.py
parentba65ca496af5766932a762bb99a758dbfcb580ec (diff)
tests: refactor. Replace literal constant w/ named constant.
* change literal packet count vlaues from 65 to a named constant of 67. (This value was recommended to exercise single, dual, and quad loops) Change-Id: Ieb1738dddacb8b6ea7fa25883032ac01a98399e1 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test/test_udp.py')
-rw-r--r--test/test_udp.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/test/test_udp.py b/test/test_udp.py
index d69052bc939..c714f25e27f 100644
--- a/test/test_udp.py
+++ b/test/test_udp.py
@@ -10,6 +10,8 @@ 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 """
@@ -164,12 +166,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
@@ -179,12 +181,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
@@ -194,12 +196,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
@@ -209,12 +211,12 @@ 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
@@ -233,12 +235,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):