diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-05-14 13:25:49 -0400 |
---|---|---|
committer | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-05-16 20:32:41 -0400 |
commit | 4271c971919bb8defa3ca54f4a362676cd57bfb2 (patch) | |
tree | 12fbe708b49f04dc5c088a2deefba0c451d95b64 /test/test_ip4.py | |
parent | ba65ca496af5766932a762bb99a758dbfcb580ec (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_ip4.py')
-rw-r--r-- | test/test_ip4.py | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/test/test_ip4.py b/test/test_ip4.py index ed7a5659322..346904ab981 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -18,6 +18,8 @@ from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpMRoute, \ VppMplsTable, VppIpTable from vpp_sub_interface import VppSubInterface, VppDot1QSubint, VppDot1ADSubint +NUM_PKTS = 67 + class TestIPv4(VppTestCase): """ IPv4 Test Case """ @@ -687,7 +689,7 @@ class TestIPNull(VppTestCase): self.pg1.sw_if_index)]) r1.add_vpp_config() - rx = self.send_and_expect(self.pg0, p * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) # # insert a more specific as a drop @@ -695,9 +697,9 @@ class TestIPNull(VppTestCase): r2 = VppIpRoute(self, "1.1.1.1", 32, [], is_drop=1) r2.add_vpp_config() - self.send_and_assert_no_replies(self.pg0, p * 65, "Drop Route") + self.send_and_assert_no_replies(self.pg0, p * NUM_PKTS, "Drop Route") r2.remove_vpp_config() - rx = self.send_and_expect(self.pg0, p * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) class TestIPDisabled(VppTestCase): @@ -981,7 +983,7 @@ class TestIPLoadBalance(VppTestCase): src_ip_pkts = [] src_mpls_pkts = [] - for ii in range(65): + for ii in range(NUM_PKTS): port_ip_hdr = (IP(dst="10.0.0.1", src="20.0.0.1") / UDP(sport=1234, dport=1234 + ii) / Raw('\xa5' * 100)) @@ -1240,7 +1242,7 @@ class TestIPVlan0(VppTestCase): IP(dst=self.pg1.remote_ip4, src=self.pg0.remote_ip4) / UDP(sport=1234, dport=1234) / - Raw('\xa5' * 100)) * 65 + Raw('\xa5' * 100)) * NUM_PKTS # # Expect that packets sent on VLAN-0 are forwarded on the @@ -1544,7 +1546,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_short * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p_short * NUM_PKTS, self.pg1) # # Packet too long - this is dropped @@ -1557,7 +1559,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_long * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_long * NUM_PKTS, "too long") # @@ -1571,7 +1573,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_chksum * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_chksum * NUM_PKTS, "bad checksum") # @@ -1585,7 +1587,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_ver * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_ver * NUM_PKTS, "funky version") # @@ -1599,7 +1601,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_assert_no_replies(self.pg0, p_frag * 65, + rx = self.send_and_assert_no_replies(self.pg0, p_frag * NUM_PKTS, "frag offset") # @@ -1613,7 +1615,7 @@ class TestIPInput(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_ttl * 65, self.pg0) + rx = self.send_and_expect(self.pg0, p_ttl * NUM_PKTS, self.pg0) rx = rx[0] icmp = rx[ICMP] @@ -1637,7 +1639,7 @@ class TestIPInput(VppTestCase): self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [1500, 0, 0, 0]) - rx = self.send_and_expect(self.pg0, p_mtu * 65, self.pg0) + rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg0) rx = rx[0] icmp = rx[ICMP] @@ -1648,7 +1650,7 @@ class TestIPInput(VppTestCase): self.assertEqual(icmp.dst, self.pg1.remote_ip4) self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [2500, 0, 0, 0]) - rx = self.send_and_expect(self.pg0, p_mtu * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p_mtu * NUM_PKTS, self.pg1) # Reset MTU for subsequent tests self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, [9000, 0, 0, 0]) @@ -1727,10 +1729,10 @@ class TestIPDirectedBroadcast(VppTestCase): # # test packet is L2 broadcast # - rx = self.send_and_expect(self.pg1, p0 * 65, self.pg0) + rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0) self.assertTrue(rx[0][Ether].dst, "ff:ff:ff:ff:ff:ff") - self.send_and_assert_no_replies(self.pg0, p1 * 65, + self.send_and_assert_no_replies(self.pg0, p1 * NUM_PKTS, "directed broadcast disabled") # @@ -1738,12 +1740,12 @@ class TestIPDirectedBroadcast(VppTestCase): # self.vapi.sw_interface_set_ip_directed_broadcast( self.pg0.sw_if_index, 0) - self.send_and_assert_no_replies(self.pg1, p0 * 65, + self.send_and_assert_no_replies(self.pg1, p0 * NUM_PKTS, "directed broadcast disabled") self.vapi.sw_interface_set_ip_directed_broadcast( self.pg0.sw_if_index, 1) - rx = self.send_and_expect(self.pg1, p0 * 65, self.pg0) + rx = self.send_and_expect(self.pg1, p0 * NUM_PKTS, self.pg0) self.pg0.unconfig_ip4() self.pg1.unconfig_ip4() @@ -1802,8 +1804,8 @@ class TestIPLPM(VppTestCase): Raw('\xa5' * 2000)) self.logger.info(self.vapi.cli("sh ip fib mtrie")) - rx = self.send_and_expect(self.pg0, p_8 * 65, self.pg2) - rx = self.send_and_expect(self.pg0, p_24 * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p_8 * NUM_PKTS, self.pg2) + rx = self.send_and_expect(self.pg0, p_24 * NUM_PKTS, self.pg1) class TestIPv4Frag(VppTestCase): |