summaryrefslogtreecommitdiffstats
path: root/test/test_qos.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_qos.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_qos.py')
-rw-r--r--test/test_qos.py70
1 files changed, 36 insertions, 34 deletions
diff --git a/test/test_qos.py b/test/test_qos.py
index bdae4989014..8025bdcd40c 100644
--- a/test/test_qos.py
+++ b/test/test_qos.py
@@ -16,6 +16,8 @@ from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6
from scapy.contrib.mpls import MPLS
+NUM_PKTS = 67
+
class TestQOS(VppTestCase):
""" QOS Test Case """
@@ -130,21 +132,21 @@ class TestQOS(VppTestCase):
p_v4 = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
IP(src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4, tos=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
p_v6 = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
IPv6(src=self.pg0.remote_ip6, dst=self.pg1.remote_ip6,
tc=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
#
# Since we have not yet enabled the recording of the input QoS
# from the input iP header, the egress packet's ToS will be unchanged
#
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 1)
- rx = self.send_and_expect(self.pg0, p_v6 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IPv6].tc, 1)
@@ -159,10 +161,10 @@ class TestQOS(VppTestCase):
# send the same packets, this time expect the input TOS of 1
# to be mapped to pg1's egress value of 254
#
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 254)
- rx = self.send_and_expect(self.pg0, p_v6 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IPv6].tc, 254)
@@ -170,20 +172,20 @@ class TestQOS(VppTestCase):
# different input ToS to test the mapping
#
p_v4[IP].tos = 127
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 128)
p_v6[IPv6].tc = 127
- rx = self.send_and_expect(self.pg0, p_v6 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IPv6].tc, 128)
p_v4[IP].tos = 254
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 1)
p_v6[IPv6].tc = 254
- rx = self.send_and_expect(self.pg0, p_v6 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IPv6].tc, 1)
@@ -192,17 +194,17 @@ class TestQOS(VppTestCase):
# correctly applied
#
p_v4[IP].dst = self.pg2.remote_ip4
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg2)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg2)
for p in rx:
self.assertEqual(p[IP].tos, 2)
p_v4[IP].dst = self.pg3.remote_ip4
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg3)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg3)
for p in rx:
self.assertEqual(p[IP].tos, 3)
p_v6[IPv6].dst = self.pg3.remote_ip6
- rx = self.send_and_expect(self.pg0, p_v6 * 65, self.pg3)
+ rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg3)
for p in rx:
self.assertEqual(p[IPv6].tc, 3)
@@ -220,12 +222,12 @@ class TestQOS(VppTestCase):
self.logger.info(self.vapi.cli("sh int feat pg2"))
p_v4[IP].dst = self.pg2.remote_ip4
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg2)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg2)
for p in rx:
self.assertEqual(p[IP].tos, 254)
p_v4[IP].dst = self.pg3.remote_ip4
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg3)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg3)
for p in rx:
self.assertEqual(p[IP].tos, 254)
@@ -233,7 +235,7 @@ class TestQOS(VppTestCase):
# still mapping out of pg1
#
p_v4[IP].dst = self.pg1.remote_ip4
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 1)
@@ -247,7 +249,7 @@ class TestQOS(VppTestCase):
#
# back to an unchanged TOS value
#
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 254)
@@ -266,7 +268,7 @@ class TestQOS(VppTestCase):
#
# unchanged Tos on pg1
#
- rx = self.send_and_expect(self.pg0, p_v4 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 254)
@@ -342,13 +344,13 @@ class TestQOS(VppTestCase):
p_1 = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
IP(src=self.pg0.remote_ip4, dst="10.0.0.1", tos=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
p_3 = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
IP(src=self.pg0.remote_ip4, dst="10.0.0.3", tos=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
- rx = self.send_and_expect(self.pg0, p_1 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_1 * NUM_PKTS, self.pg1)
#
# only 3 bits of ToS value in MPLS make sure tos is correct
@@ -358,7 +360,7 @@ class TestQOS(VppTestCase):
self.assertEqual(p[MPLS].cos, from_ip)
self.assertEqual(p[MPLS].label, 32)
self.assertEqual(p[MPLS].s, 1)
- rx = self.send_and_expect(self.pg0, p_3 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_3 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[MPLS].cos, from_ip)
self.assertEqual(p[MPLS].label, 63)
@@ -397,9 +399,9 @@ class TestQOS(VppTestCase):
MPLS(label=32, cos=3, ttl=2) /
IP(src=self.pg0.remote_ip4, dst="10.0.0.1", tos=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
- rx = self.send_and_expect(self.pg0, p_m1 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_m1 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[MPLS].cos, from_mpls)
self.assertEqual(p[MPLS].label, 33)
@@ -423,9 +425,9 @@ class TestQOS(VppTestCase):
MPLS(label=33, ttl=2, cos=3) /
IP(src=self.pg0.remote_ip4, dst="10.0.0.4", tos=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
- rx = self.send_and_expect(self.pg0, p_m2 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_m2 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, from_mpls)
@@ -524,19 +526,19 @@ class TestQOS(VppTestCase):
Dot1Q(vlan=11, prio=1) /
IP(src="1.1.1.1", dst="10.0.0.2", tos=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
p_v2 = (Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac) /
IP(src="1.1.1.1", dst="10.0.0.1", tos=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
- rx = self.send_and_expect(self.pg1, p_v2 * 65, self.pg0)
+ rx = self.send_and_expect(self.pg1, p_v2 * NUM_PKTS, self.pg0)
for p in rx:
self.assertEqual(p[Dot1Q].prio, 6)
- rx = self.send_and_expect(self.pg0, p_v1 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v1 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IP].tos, 254)
@@ -545,19 +547,19 @@ class TestQOS(VppTestCase):
Dot1Q(vlan=11, prio=2) /
IPv6(src="2001::1", dst="2001::2", tc=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
p_v2 = (Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac) /
IPv6(src="3001::1", dst="2001::1", tc=1) /
UDP(sport=1234, dport=1234) /
- Raw(scapy.compat.chb(100) * 65))
+ Raw(scapy.compat.chb(100) * NUM_PKTS))
- rx = self.send_and_expect(self.pg1, p_v2 * 65, self.pg0)
+ rx = self.send_and_expect(self.pg1, p_v2 * NUM_PKTS, self.pg0)
for p in rx:
self.assertEqual(p[Dot1Q].prio, 6)
- rx = self.send_and_expect(self.pg0, p_v1 * 65, self.pg1)
+ rx = self.send_and_expect(self.pg0, p_v1 * NUM_PKTS, self.pg1)
for p in rx:
self.assertEqual(p[IPv6].tc, 253)