diff options
-rw-r--r-- | test/test_abf.py | 20 | ||||
-rw-r--r-- | test/test_bier.py | 6 | ||||
-rw-r--r-- | test/test_dvr.py | 27 | ||||
-rw-r--r-- | test/test_gbp.py | 96 | ||||
-rw-r--r-- | test/test_ip4.py | 40 | ||||
-rw-r--r-- | test/test_ip6.py | 9 | ||||
-rw-r--r-- | test/test_l2_flood.py | 48 | ||||
-rw-r--r-- | test/test_mpls.py | 10 | ||||
-rw-r--r-- | test/test_neighbor.py | 19 | ||||
-rw-r--r-- | test/test_pipe.py | 36 | ||||
-rw-r--r-- | test/test_punt.py | 36 | ||||
-rw-r--r-- | test/test_qos.py | 70 | ||||
-rw-r--r-- | test/test_svs.py | 34 | ||||
-rw-r--r-- | test/test_udp.py | 22 |
14 files changed, 257 insertions, 216 deletions
diff --git a/test/test_abf.py b/test/test_abf.py index 1de36c92221..350af0dce07 100644 --- a/test/test_abf.py +++ b/test/test_abf.py @@ -14,6 +14,8 @@ from scapy.layers.inet6 import IPv6 from vpp_object import VppObject +NUM_PKTS = 67 + def find_abf_policy(test, id): policies = test.vapi.abf_policy_dump() @@ -216,7 +218,7 @@ class TestAbf(VppTestCase): IP(src="1.1.1.1", dst="1.1.1.2") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg0, p_1*65, self.pg1) + self.send_and_expect(self.pg0, p_1*NUM_PKTS, self.pg1) # # Attach a 'better' priority policy to the same interface @@ -228,7 +230,7 @@ class TestAbf(VppTestCase): attach_2 = VppAbfAttach(self, 11, self.pg0.sw_if_index, 40) attach_2.add_vpp_config() - self.send_and_expect(self.pg0, p_1*65, self.pg2) + self.send_and_expect(self.pg0, p_1*NUM_PKTS, self.pg2) # # Attach a policy with priority in the middle @@ -240,13 +242,13 @@ class TestAbf(VppTestCase): attach_3 = VppAbfAttach(self, 12, self.pg0.sw_if_index, 45) attach_3.add_vpp_config() - self.send_and_expect(self.pg0, p_1*65, self.pg2) + self.send_and_expect(self.pg0, p_1*NUM_PKTS, self.pg2) # # remove the best priority # attach_2.remove_vpp_config() - self.send_and_expect(self.pg0, p_1*65, self.pg3) + self.send_and_expect(self.pg0, p_1*NUM_PKTS, self.pg3) # # Attach one of the same policies to Pg1 @@ -259,14 +261,14 @@ class TestAbf(VppTestCase): IP(src="1.1.1.1", dst="1.1.1.2") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg1, p_2 * 65, self.pg3) + self.send_and_expect(self.pg1, p_2 * NUM_PKTS, self.pg3) # # detach the policy from PG1, now expect traffic to be dropped # attach_4.remove_vpp_config() - self.send_and_assert_no_replies(self.pg1, p_2 * 65, "Detached") + self.send_and_assert_no_replies(self.pg1, p_2 * NUM_PKTS, "Detached") # # Swap to route via a next-hop in the non-default table @@ -287,7 +289,7 @@ class TestAbf(VppTestCase): attach_5 = VppAbfAttach(self, 13, self.pg0.sw_if_index, 30) attach_5.add_vpp_config() - self.send_and_expect(self.pg0, p_1*65, self.pg4) + self.send_and_expect(self.pg0, p_1*NUM_PKTS, self.pg4) self.pg4.unconfig_ip4() self.pg4.set_table_ip4(0) @@ -343,7 +345,7 @@ class TestAbf(VppTestCase): # packets are dropped because there is no route to the policy's # next hop # - self.send_and_assert_no_replies(self.pg1, p * 65, "no route") + self.send_and_assert_no_replies(self.pg1, p * NUM_PKTS, "no route") # # add a route resolving the next-hop @@ -358,7 +360,7 @@ class TestAbf(VppTestCase): # # now expect packets forwarded. # - self.send_and_expect(self.pg0, p * 65, self.pg1) + self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) if __name__ == '__main__': diff --git a/test/test_bier.py b/test/test_bier.py index cd2d4c03af9..b8130ce93f2 100644 --- a/test/test_bier.py +++ b/test/test_bier.py @@ -20,6 +20,8 @@ from scapy.layers.inet6 import IPv6 from scapy.contrib.mpls import MPLS from scapy.contrib.bier import BIER, BIERLength, BIFT +NUM_PKTS = 67 + class TestBFIB(VppTestCase): """ BIER FIB Test Case """ @@ -642,7 +644,7 @@ class TestBier(VppTestCase): UDP(sport=1234, dport=1234) / Raw(scapy.compat.chb(5) * 32)) - rx = self.send_and_expect(self.pg0, p*65, self.pg1) + rx = self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1) self.assertEqual(rx[0][IP].src, "1.1.1.1") self.assertEqual(rx[0][IP].dst, "232.1.1.1") @@ -653,7 +655,7 @@ class TestBier(VppTestCase): UDP(sport=1234, dport=1234) / Raw(scapy.compat.chb(5) * 512)) - rx = self.send_and_expect(self.pg0, p*65, self.pg1) + rx = self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1) self.assertEqual(rx[0][IP].src, "1.1.1.1") self.assertEqual(rx[0][IP].dst, "232.1.1.2") diff --git a/test/test_dvr.py b/test/test_dvr.py index f6ce8e80720..ae7864cc3e6 100644 --- a/test/test_dvr.py +++ b/test/test_dvr.py @@ -11,6 +11,8 @@ from scapy.layers.l2 import Ether, Dot1Q from scapy.layers.inet import IP, UDP from socket import AF_INET, inet_pton +NUM_PKTS = 67 + class TestDVR(VppTestCase): """ Distributed Virtual Router """ @@ -125,7 +127,7 @@ class TestDVR(VppTestCase): # Inject the packet that arrives and leaves on a non-tagged interface # Since it's 'bridged' expect that the MAC headed is unchanged. # - rx = self.send_and_expect(self.pg0, pkt_no_tag * 65, self.pg1) + rx = self.send_and_expect(self.pg0, pkt_no_tag * NUM_PKTS, self.pg1) self.assert_same_mac_addr(pkt_no_tag, rx) self.assert_has_no_tag(rx) @@ -143,7 +145,7 @@ class TestDVR(VppTestCase): # Inject the packet that arrives non-tag and leaves on a tagged # interface # - rx = self.send_and_expect(self.pg0, pkt_tag * 65, self.pg3) + rx = self.send_and_expect(self.pg0, pkt_tag * NUM_PKTS, self.pg3) self.assert_same_mac_addr(pkt_tag, rx) self.assert_has_vlan_tag(93, rx) @@ -158,7 +160,9 @@ class TestDVR(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg2, pkt_tag_to_tag * 65, self.pg3) + rx = self.send_and_expect(self.pg2, + pkt_tag_to_tag * NUM_PKTS, + self.pg3) self.assert_same_mac_addr(pkt_tag_to_tag, rx) self.assert_has_vlan_tag(93, rx) @@ -173,7 +177,9 @@ class TestDVR(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg2, pkt_tag_to_non_tag * 65, self.pg1) + rx = self.send_and_expect(self.pg2, + pkt_tag_to_non_tag * NUM_PKTS, + self.pg1) self.assert_same_mac_addr(pkt_tag_to_tag, rx) self.assert_has_no_tag(rx) @@ -204,7 +210,8 @@ class TestDVR(VppTestCase): # # Send packet's that should match the ACL and be dropped # - rx = self.send_and_assert_no_replies(self.pg2, pkt_tag_to_non_tag * 65) + rx = self.send_and_assert_no_replies(self.pg2, + pkt_tag_to_non_tag * NUM_PKTS) # # cleanup @@ -352,19 +359,21 @@ class TestDVR(VppTestCase): # # now we expect the packet forward according to the DVR route # - rx = self.send_and_expect(self.pg0, pkt_no_tag * 65, self.pg1) + rx = self.send_and_expect(self.pg0, pkt_no_tag * NUM_PKTS, self.pg1) self.assert_same_mac_addr(pkt_no_tag, rx) self.assert_has_no_tag(rx) - rx = self.send_and_expect(self.pg0, pkt_to_tag * 65, self.pg2) + rx = self.send_and_expect(self.pg0, pkt_to_tag * NUM_PKTS, self.pg2) self.assert_same_mac_addr(pkt_to_tag, rx) self.assert_has_vlan_tag(92, rx) - rx = self.send_and_expect(self.pg3, pkt_from_tag * 65, self.pg1) + rx = self.send_and_expect(self.pg3, pkt_from_tag * NUM_PKTS, self.pg1) self.assert_same_mac_addr(pkt_from_tag, rx) self.assert_has_no_tag(rx) - rx = self.send_and_expect(self.pg3, pkt_from_to_tag * 65, self.pg2) + rx = self.send_and_expect(self.pg3, + pkt_from_to_tag * NUM_PKTS, + self.pg2) self.assert_same_mac_addr(pkt_from_tag, rx) self.assert_has_vlan_tag(92, rx) diff --git a/test/test_gbp.py b/test/test_gbp.py index 2e6dca5b2b1..e9b5f5dc56b 100644 --- a/test/test_gbp.py +++ b/test/test_gbp.py @@ -27,6 +27,8 @@ from vpp_vxlan_gbp_tunnel import find_vxlan_gbp_tunnel, INDEX_INVALID, \ VppVxlanGbpTunnel from vpp_neighbor import VppNeighbor +NUM_PKTS = 67 + def find_gbp_endpoint(test, sw_if_index=None, ip=None, mac=None): if ip: @@ -992,7 +994,8 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_assert_no_replies(self.pg0, pkt_intra_epg_220_ip4 * 65) + self.send_and_assert_no_replies(self.pg0, + pkt_intra_epg_220_ip4 * NUM_PKTS) pkt_inter_epg_222_ip6 = (Ether(src=self.pg0.remote_mac, dst=str(self.router_mac)) / @@ -1000,7 +1003,8 @@ class TestGBP(VppTestCase): dst="2001:10::99") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_assert_no_replies(self.pg0, pkt_inter_epg_222_ip6 * 65) + self.send_and_assert_no_replies(self.pg0, + pkt_inter_epg_222_ip6 * NUM_PKTS) # # Add the subnet routes @@ -1031,13 +1035,13 @@ class TestGBP(VppTestCase): s63.add_vpp_config() self.send_and_expect_bridged(eps[0].itf, - pkt_intra_epg_220_ip4 * 65, + pkt_intra_epg_220_ip4 * NUM_PKTS, eps[0].epg.uplink) self.send_and_expect_bridged(eps[0].itf, - pkt_inter_epg_222_ip4 * 65, + pkt_inter_epg_222_ip4 * NUM_PKTS, eps[0].epg.uplink) self.send_and_expect_bridged6(eps[0].itf, - pkt_inter_epg_222_ip6 * 65, + pkt_inter_epg_222_ip6 * NUM_PKTS, eps[0].epg.uplink) self.logger.info(self.vapi.cli("sh ip fib 11.0.0.2")) @@ -1062,7 +1066,7 @@ class TestGBP(VppTestCase): Raw('\xa5' * 100)) self.send_and_expect_bridged(eps[0].itf, - pkt_intra_epg_220_to_uplink * 65, + pkt_intra_epg_220_to_uplink * NUM_PKTS, eps[0].epg.uplink) # ... and nowhere else self.pg1.get_capture(0, timeout=0.1) @@ -1076,7 +1080,7 @@ class TestGBP(VppTestCase): Raw('\xa5' * 100)) self.send_and_expect_bridged(eps[2].itf, - pkt_intra_epg_221_to_uplink * 65, + pkt_intra_epg_221_to_uplink * NUM_PKTS, eps[2].epg.uplink) # @@ -1090,7 +1094,7 @@ class TestGBP(VppTestCase): Raw('\xa5' * 100)) self.send_and_expect_bridged(self.pg4, - pkt_intra_epg_220_from_uplink * 65, + pkt_intra_epg_220_from_uplink * NUM_PKTS, self.pg0) # @@ -1104,7 +1108,9 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect_bridged(self.pg0, pkt_intra_epg * 65, self.pg1) + self.send_and_expect_bridged(self.pg0, + pkt_intra_epg * NUM_PKTS, + self.pg1) # # in the absence of policy, endpoints in the different EPG @@ -1130,9 +1136,9 @@ class TestGBP(VppTestCase): Raw('\xa5' * 100)) self.send_and_assert_no_replies(eps[0].itf, - pkt_inter_epg_220_to_221 * 65) + pkt_inter_epg_220_to_221 * NUM_PKTS) self.send_and_assert_no_replies(eps[0].itf, - pkt_inter_epg_220_to_222 * 65) + pkt_inter_epg_220_to_222 * NUM_PKTS) # # A uni-directional contract from EPG 220 -> 221 @@ -1153,10 +1159,10 @@ class TestGBP(VppTestCase): c1.add_vpp_config() self.send_and_expect_bridged(eps[0].itf, - pkt_inter_epg_220_to_221 * 65, + pkt_inter_epg_220_to_221 * NUM_PKTS, eps[2].itf) self.send_and_assert_no_replies(eps[0].itf, - pkt_inter_epg_220_to_222 * 65) + pkt_inter_epg_220_to_222 * NUM_PKTS) # # contract for the return direction @@ -1173,16 +1179,16 @@ class TestGBP(VppTestCase): c2.add_vpp_config() self.send_and_expect_bridged(eps[0].itf, - pkt_inter_epg_220_to_221 * 65, + pkt_inter_epg_220_to_221 * NUM_PKTS, eps[2].itf) self.send_and_expect_bridged(eps[2].itf, - pkt_inter_epg_221_to_220 * 65, + pkt_inter_epg_221_to_220 * NUM_PKTS, eps[0].itf) ds = c2.get_drop_stats() self.assertEqual(ds['packets'], 0) ps = c2.get_permit_stats() - self.assertEqual(ps['packets'], 65) + self.assertEqual(ps['packets'], NUM_PKTS) # # the contract does not allow non-IP @@ -1198,7 +1204,7 @@ class TestGBP(VppTestCase): # not in the contract. # self.send_and_assert_no_replies(eps[0].itf, - pkt_inter_epg_220_to_222 * 65) + pkt_inter_epg_220_to_222 * NUM_PKTS) # # A uni-directional contract from EPG 220 -> 222 'L3 routed' @@ -1217,7 +1223,7 @@ class TestGBP(VppTestCase): self.logger.info(self.vapi.cli("sh gbp contract")) self.send_and_expect_routed(eps[0].itf, - pkt_inter_epg_220_to_222 * 65, + pkt_inter_epg_220_to_222 * NUM_PKTS, eps[3].itf, str(self.router_mac)) @@ -1230,11 +1236,11 @@ class TestGBP(VppTestCase): acl.remove_vpp_config() self.send_and_assert_no_replies(eps[2].itf, - pkt_inter_epg_221_to_220 * 65) + pkt_inter_epg_221_to_220 * NUM_PKTS) self.send_and_assert_no_replies(eps[0].itf, - pkt_inter_epg_220_to_221 * 65) + pkt_inter_epg_220_to_221 * NUM_PKTS) self.send_and_expect_bridged(eps[0].itf, - pkt_intra_epg * 65, + pkt_intra_epg * NUM_PKTS, eps[1].itf) # @@ -1298,7 +1304,7 @@ class TestGBP(VppTestCase): # no policy yet self.send_and_assert_no_replies(eps[0].itf, - pkt_inter_epg_220_to_global * 65) + pkt_inter_epg_220_to_global * NUM_PKTS) acl2 = VppGbpAcl(self) rule = acl2.create_rule(permit_deny=1, proto=17, sport_from=1234, @@ -1320,7 +1326,7 @@ class TestGBP(VppTestCase): c4.add_vpp_config() self.send_and_expect_natted(eps[0].itf, - pkt_inter_epg_220_to_global * 65, + pkt_inter_epg_220_to_global * NUM_PKTS, self.pg7, eps[0].fip4.address) @@ -1332,7 +1338,7 @@ class TestGBP(VppTestCase): Raw('\xa5' * 100)) self.send_and_expect_natted6(self.pg0, - pkt_inter_epg_220_to_global * 65, + pkt_inter_epg_220_to_global * NUM_PKTS, self.pg7, eps[0].fip6.address) @@ -1346,8 +1352,8 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_assert_no_replies(self.pg7, - pkt_inter_epg_220_from_global * 65) + self.send_and_assert_no_replies( + self.pg7, pkt_inter_epg_220_from_global * NUM_PKTS) c5 = VppGbpContract( self, epgs[3].sclass, epgs[0].sclass, acl_index2, @@ -1361,7 +1367,7 @@ class TestGBP(VppTestCase): c5.add_vpp_config() self.send_and_expect_unnatted(self.pg7, - pkt_inter_epg_220_from_global * 65, + pkt_inter_epg_220_from_global * NUM_PKTS, eps[0].itf, eps[0].ip4.address) @@ -1372,10 +1378,11 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect_unnatted6(self.pg7, - pkt_inter_epg_220_from_global * 65, - eps[0].itf, - eps[0].ip6.address) + self.send_and_expect_unnatted6( + self.pg7, + pkt_inter_epg_220_from_global * NUM_PKTS, + eps[0].itf, + eps[0].ip6.address) # # From a local VM to another local VM using resp. public addresses: @@ -1389,7 +1396,7 @@ class TestGBP(VppTestCase): Raw('\xa5' * 100)) self.send_and_expect_double_natted(eps[0].itf, - pkt_intra_epg_220_global * 65, + pkt_intra_epg_220_global * NUM_PKTS, eps[1].itf, eps[0].fip4.address, eps[1].ip4.address) @@ -1401,11 +1408,12 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect_double_natted6(eps[0].itf, - pkt_intra_epg_220_global * 65, - eps[1].itf, - eps[0].fip6.address, - eps[1].ip6.address) + self.send_and_expect_double_natted6( + eps[0].itf, + pkt_intra_epg_220_global * NUM_PKTS, + eps[1].itf, + eps[0].fip6.address, + eps[1].ip6.address) # # cleanup @@ -1743,7 +1751,7 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg2, p * 65, self.pg0) + rx = self.send_and_expect(self.pg2, p * NUM_PKTS, self.pg0) for l in learnt: self.assertFalse(find_gbp_endpoint(self, @@ -1766,7 +1774,7 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg2, p * 65, self.pg0) + rx = self.send_and_expect(self.pg2, p * NUM_PKTS, self.pg0) self.assertTrue(find_gbp_endpoint(self, vx_tun_l2_1.sw_if_index, @@ -1818,7 +1826,7 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg2, p * 65, self.pg0) + rx = self.send_and_expect(self.pg2, p * NUM_PKTS, self.pg0) self.assertTrue(find_gbp_endpoint(self, vx_tun_l2_1.sw_if_index, @@ -1851,7 +1859,7 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg2, p * 65, self.pg0) + rx = self.send_and_expect(self.pg2, p * NUM_PKTS, self.pg0) self.assertTrue(find_gbp_endpoint(self, vx_tun_l2_1.sw_if_index, @@ -1930,7 +1938,7 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg2, p * 65, self.pg0) + rx = self.send_and_expect(self.pg2, p * NUM_PKTS, self.pg0) self.assertTrue(find_gbp_endpoint(self, vx_tun_l2_1.sw_if_index, @@ -2423,7 +2431,7 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rxs = self.send_and_expect(self.pg0, p * 65, self.pg2) + rxs = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg2) for rx in rxs: self.assertEqual(rx[IP].src, self.pg2.local_ip4) @@ -2562,7 +2570,7 @@ class TestGBP(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rxs = self.send_and_expect(self.pg0, p * 65, self.pg2) + rxs = self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg2) for rx in rxs: self.assertEqual(rx[IP].src, self.pg2.local_ip4) 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): diff --git a/test/test_ip6.py b/test/test_ip6.py index 6c959a2712c..7c9df465707 100644 --- a/test/test_ip6.py +++ b/test/test_ip6.py @@ -36,6 +36,8 @@ try: except NameError: text_type = str +NUM_PKTS = 67 + class TestIPv6ND(VppTestCase): def validate_ra(self, intf, rx, dst_ip=None): @@ -1308,6 +1310,7 @@ class TestIPv6RDControlPlane(TestIPv6ND): # check FIB still contains the SLAAC address addresses = set(self.get_interface_addresses(fib, self.pg0)) new_addresses = addresses.difference(initial_addresses) + self.assertEqual(len(new_addresses), 1) prefix = list(new_addresses)[0][:8] + '\0\0\0\0\0\0\0\0' self.assertEqual(inet_ntop(AF_INET6, prefix), '1::') @@ -1760,7 +1763,7 @@ class TestIP6LoadBalance(VppTestCase): src_ip_pkts = [] src_mpls_pkts = [] - for ii in range(65): + for ii in range(NUM_PKTS): port_ip_hdr = ( IPv6(dst="3000::1", src="3000:1::1") / inet6.UDP(sport=1234, dport=1234 + ii) / @@ -2267,7 +2270,7 @@ class TestIP6Input(VppTestCase): inet6.UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - rx = self.send_and_expect(self.pg0, p_version * 65, self.pg0) + rx = self.send_and_expect(self.pg0, p_version * NUM_PKTS, self.pg0) rx = rx[0] icmp = rx[ICMPv6TimeExceeded] @@ -2306,7 +2309,7 @@ class TestIP6Input(VppTestCase): l4 / Raw('\xa5' * 100)) - self.send_and_assert_no_replies(self.pg0, p_version * 65, + self.send_and_assert_no_replies(self.pg0, p_version * NUM_PKTS, remark=msg or "", timeout=timeout) diff --git a/test/test_l2_flood.py b/test/test_l2_flood.py index a5c6e192434..8ff0bc2b090 100644 --- a/test/test_l2_flood.py +++ b/test/test_l2_flood.py @@ -11,6 +11,8 @@ from scapy.packet import Raw from scapy.layers.l2 import Ether from scapy.layers.inet import IP, UDP +NUM_PKTS = 67 + class TestL2Flood(VppTestCase): """ L2-flood """ @@ -85,25 +87,25 @@ class TestL2Flood(VppTestCase): # this is in SHG=0 so its flooded to all, expect the pg0 since that's # the ingress link # - self.pg0.add_stream(p*65) + self.pg0.add_stream(p*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[1:12]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) # # input on pg4 (SHG=1) expect copies on pg0->3 (SHG=0) # and pg8->11 (SHG=2) # - self.pg4.add_stream(p*65) + self.pg4.add_stream(p*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[:4]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) for i in self.pg_interfaces[8:12]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) for i in self.pg_interfaces[4:8]: i.assert_nothing_captured(remark="Different SH group") @@ -122,25 +124,25 @@ class TestL2Flood(VppTestCase): # this is in SHG=0 so its flooded to all, expect the pg0 since that's # the ingress link # - self.pg0.add_stream(p*65) + self.pg0.add_stream(p*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[1:]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) # # input on pg4 (SHG=1) expect copies on pg0->3 (SHG=0) # and pg8->12 (SHG=2) # - self.pg4.add_stream(p*65) + self.pg4.add_stream(p*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[:4]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) for i in self.pg_interfaces[8:13]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) for i in self.pg_interfaces[4:8]: i.assert_nothing_captured(remark="Different SH group") @@ -183,7 +185,7 @@ class TestL2Flood(VppTestCase): # # input on pg0 expect copies on pg1 # - self.send_and_expect(self.pg0, p*65, self.pg1) + self.send_and_expect(self.pg0, p*NUM_PKTS, self.pg1) # # cleanup @@ -225,19 +227,19 @@ class TestL2Flood(VppTestCase): # # input on pg0, expected copies on pg1->4 # - self.pg0.add_stream(p_uu*65) + self.pg0.add_stream(p_uu*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[1:4]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) - self.pg0.add_stream(p_bm*65) + self.pg0.add_stream(p_bm*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[1:4]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) # # use pg8 as the uu-fwd interface @@ -249,21 +251,21 @@ class TestL2Flood(VppTestCase): # # expect the UU packet on the uu-fwd interface and not be flooded # - self.pg0.add_stream(p_uu*65) + self.pg0.add_stream(p_uu*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - rx0 = self.pg8.get_capture(65, timeout=1) + rx0 = self.pg8.get_capture(NUM_PKTS, timeout=1) for i in self.pg_interfaces[0:4]: i.assert_nothing_captured(remark="UU not flooded") - self.pg0.add_stream(p_bm*65) + self.pg0.add_stream(p_bm*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[1:4]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) # # remove the uu-fwd interface and expect UU to be flooded again @@ -272,12 +274,12 @@ class TestL2Flood(VppTestCase): rx_sw_if_index=self.pg8.sw_if_index, bd_id=1, shg=0, port_type=L2_PORT_TYPE.UU_FWD, enable=0) - self.pg0.add_stream(p_uu*65) + self.pg0.add_stream(p_uu*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() for i in self.pg_interfaces[1:4]: - rx0 = i.get_capture(65, timeout=1) + rx0 = i.get_capture(NUM_PKTS, timeout=1) # # change the BD config to not support UU-flood @@ -294,11 +296,11 @@ class TestL2Flood(VppTestCase): port_type=L2_PORT_TYPE.UU_FWD) self.logger.info(self.vapi.cli("sh bridge 1 detail")) - self.pg0.add_stream(p_uu*65) + self.pg0.add_stream(p_uu*NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - rx0 = self.pg8.get_capture(65, timeout=1) + rx0 = self.pg8.get_capture(NUM_PKTS, timeout=1) for i in self.pg_interfaces[0:4]: i.assert_nothing_captured(remark="UU not flooded") diff --git a/test/test_mpls.py b/test/test_mpls.py index 2e0b71f3328..79f3204c53e 100644 --- a/test/test_mpls.py +++ b/test/test_mpls.py @@ -2014,7 +2014,7 @@ class TestMPLSL2(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - tx0 = pcore * 65 + tx0 = pcore * NUM_PKTS rx0 = self.send_and_expect(self.pg0, tx0, self.pg1) payload = pcore[MPLS].payload @@ -2024,7 +2024,7 @@ class TestMPLSL2(VppTestCase): # # Inject a packet from the customer/L2 side # - tx1 = pcore[MPLS].payload * 65 + tx1 = pcore[MPLS].payload * NUM_PKTS rx1 = self.send_and_expect(self.pg1, tx1, self.pg0) self.verify_capture_tunneled_ethernet(rx1, tx1, [VppMplsLabel(42)]) @@ -2100,13 +2100,13 @@ class TestMPLSL2(VppTestCase): # # now a stream in each direction # - self.pg1.add_stream(p_cust * 65) + self.pg1.add_stream(p_cust * NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - rx0 = self.pg0.get_capture(65) + rx0 = self.pg0.get_capture(NUM_PKTS) - self.verify_capture_tunneled_ethernet(rx0, p_cust*65, + self.verify_capture_tunneled_ethernet(rx0, p_cust*NUM_PKTS, [VppMplsLabel(42)]) # diff --git a/test/test_neighbor.py b/test/test_neighbor.py index c6d9fc61815..6f781ff54c2 100644 --- a/test/test_neighbor.py +++ b/test/test_neighbor.py @@ -17,6 +17,9 @@ from scapy.layers.inet6 import IPv6 from scapy.contrib.mpls import MPLS from scapy.layers.inet6 import IPv6 + +NUM_PKTS = 67 + # not exported by scapy, so redefined here arp_opts = {"who-has": 1, "is-at": 2} @@ -1480,14 +1483,14 @@ class NeighborStatsTestCase(VppTestCase): UDP(sport=1234, dport=1234) / Raw()) - rx = self.send_and_expect(self.pg0, p1 * 65, self.pg1) - rx = self.send_and_expect(self.pg0, p2 * 65, self.pg1) + rx = self.send_and_expect(self.pg0, p1 * NUM_PKTS, self.pg1) + rx = self.send_and_expect(self.pg0, p2 * NUM_PKTS, self.pg1) - self.assertEqual(65, arp1.get_stats()['packets']) - self.assertEqual(65, arp2.get_stats()['packets']) + self.assertEqual(NUM_PKTS, arp1.get_stats()['packets']) + self.assertEqual(NUM_PKTS, arp2.get_stats()['packets']) - rx = self.send_and_expect(self.pg0, p1 * 65, self.pg1) - self.assertEqual(130, arp1.get_stats()['packets']) + rx = self.send_and_expect(self.pg0, p1 * NUM_PKTS, self.pg1) + self.assertEqual(NUM_PKTS*2, arp1.get_stats()['packets']) def test_nd_stats(self): """ ND Counters """ @@ -1525,8 +1528,8 @@ class NeighborStatsTestCase(VppTestCase): self.assertEqual(16, nd1.get_stats()['packets']) self.assertEqual(16, nd2.get_stats()['packets']) - rx = self.send_and_expect(self.pg1, p1 * 65, self.pg0) - self.assertEqual(81, nd1.get_stats()['packets']) + rx = self.send_and_expect(self.pg1, p1 * NUM_PKTS, self.pg0) + self.assertEqual(NUM_PKTS+16, nd1.get_stats()['packets']) if __name__ == '__main__': diff --git a/test/test_pipe.py b/test/test_pipe.py index 6a0b4a0d093..20e6d2a4e1f 100644 --- a/test/test_pipe.py +++ b/test/test_pipe.py @@ -10,6 +10,8 @@ from framework import VppTestCase, VppTestRunner from vpp_interface import VppInterface from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath +NUM_PKTS = 67 + class VppPipe(VppInterface): """ @@ -114,8 +116,8 @@ class TestPipe(VppTestCase): UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg0, p * 65, self.pg1) - self.send_and_expect(self.pg1, p * 65, self.pg0) + self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) + self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg0) # # Attach ACL to ensure features are run on the pipe @@ -138,8 +140,8 @@ class TestPipe(VppTestCase): self.vapi.acl_interface_set_acl_list(pipes[0].east, 0, [acl.acl_index]) - self.send_and_assert_no_replies(self.pg0, p * 65) - self.send_and_expect(self.pg1, p * 65, self.pg0) + self.send_and_assert_no_replies(self.pg0, p * NUM_PKTS) + self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg0) # remove from output and apply on input self.vapi.acl_interface_set_acl_list(pipes[0].east, @@ -148,13 +150,13 @@ class TestPipe(VppTestCase): self.vapi.acl_interface_set_acl_list(pipes[0].west, 1, [acl.acl_index]) - self.send_and_assert_no_replies(self.pg0, p * 65) - self.send_and_expect(self.pg1, p * 65, self.pg0) + self.send_and_assert_no_replies(self.pg0, p * NUM_PKTS) + self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg0) self.vapi.acl_interface_set_acl_list(pipes[0].west, 0, []) - self.send_and_expect(self.pg0, p * 65, self.pg1) - self.send_and_expect(self.pg1, p * 65, self.pg0) + self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg1) + self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg0) # # L3 routes in two separate tables so a pipe can be used to L3 @@ -205,13 +207,13 @@ class TestPipe(VppTestCase): self.vapi.sw_interface_set_table(pipes[1].east, 0, 1) # IP is not enabled on the pipes at this point - self.send_and_assert_no_replies(self.pg2, p_east * 65) + self.send_and_assert_no_replies(self.pg2, p_east * NUM_PKTS) # IP enable the Pipes by making them unnumbered pipes[0].set_unnumbered(self.pg2.sw_if_index) pipes[1].set_unnumbered(self.pg3.sw_if_index) - self.send_and_expect(self.pg2, p_east * 65, self.pg3) + self.send_and_expect(self.pg2, p_east * NUM_PKTS, self.pg3) # and the return path p_west = (Ether(src=self.pg3.remote_mac, @@ -220,7 +222,7 @@ class TestPipe(VppTestCase): dst="1.1.1.2") / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg3, p_west * 65, self.pg2) + self.send_and_expect(self.pg3, p_west * NUM_PKTS, self.pg2) # # Use ACLs to test features run on the Pipes @@ -228,8 +230,8 @@ class TestPipe(VppTestCase): self.vapi.acl_interface_set_acl_list(pipes[1].east, 0, [acl.acl_index]) - self.send_and_assert_no_replies(self.pg2, p_east * 65) - self.send_and_expect(self.pg3, p_west * 65, self.pg2) + self.send_and_assert_no_replies(self.pg2, p_east * NUM_PKTS) + self.send_and_expect(self.pg3, p_west * NUM_PKTS, self.pg2) # remove from output and apply on input self.vapi.acl_interface_set_acl_list(pipes[1].east, @@ -238,13 +240,13 @@ class TestPipe(VppTestCase): self.vapi.acl_interface_set_acl_list(pipes[1].west, 1, [acl.acl_index]) - self.send_and_assert_no_replies(self.pg2, p_east * 65) - self.send_and_expect(self.pg3, p_west * 65, self.pg2) + self.send_and_assert_no_replies(self.pg2, p_east * NUM_PKTS) + self.send_and_expect(self.pg3, p_west * NUM_PKTS, self.pg2) self.vapi.acl_interface_set_acl_list(pipes[1].west, 0, []) - self.send_and_expect(self.pg2, p_east * 65, self.pg3) - self.send_and_expect(self.pg3, p_west * 65, self.pg2) + self.send_and_expect(self.pg2, p_east * NUM_PKTS, self.pg3) + self.send_and_expect(self.pg3, p_west * NUM_PKTS, self.pg2) # cleanup (so the tables delete) self.pg2.unconfig_ip4() diff --git a/test/test_punt.py b/test/test_punt.py index cb9d40de4c4..5dec066a8a0 100644 --- a/test/test_punt.py +++ b/test/test_punt.py @@ -26,6 +26,8 @@ from framework import VppTestCase, VppTestRunner from vpp_ip import DpoProto from vpp_ip_route import VppIpRoute, VppRoutePath +NUM_PKTS = 67 + # Format MAC Address def get_mac_addr(bytes_addr): @@ -746,8 +748,8 @@ class TestPunt(VppTestCase): # # pkts now dropped # - self.send_and_assert_no_replies(self.pg2, p4*65) - self.send_and_assert_no_replies(self.pg2, p6*65) + self.send_and_assert_no_replies(self.pg2, p4*NUM_PKTS) + self.send_and_assert_no_replies(self.pg2, p6*NUM_PKTS) # # Check state: @@ -757,11 +759,11 @@ class TestPunt(VppTestCase): # stats = self.statistics.get_counter( "/err/punt-dispatch/No registrations") - self.assertEqual(stats, 130) + self.assertEqual(stats, 2*NUM_PKTS) stats = self.statistics.get_counter("/net/punt") - self.assertEqual(stats[0][7]['packets'], 65) - self.assertEqual(stats[0][8]['packets'], 65) + self.assertEqual(stats[0][7]['packets'], NUM_PKTS) + self.assertEqual(stats[0][8]['packets'], NUM_PKTS) # # use the test CLI to test a client that punts exception @@ -770,8 +772,8 @@ class TestPunt(VppTestCase): self.vapi.cli("test punt pg0 %s" % self.pg0.remote_ip4) self.vapi.cli("test punt pg0 %s" % self.pg0.remote_ip6) - rx4s = self.send_and_expect(self.pg2, p4*65, self.pg0) - rx6s = self.send_and_expect(self.pg2, p6*65, self.pg0) + rx4s = self.send_and_expect(self.pg2, p4*NUM_PKTS, self.pg0) + rx6s = self.send_and_expect(self.pg2, p6*NUM_PKTS, self.pg0) # # check the packets come out IP unmodified but destined to pg0 host @@ -788,8 +790,8 @@ class TestPunt(VppTestCase): self.assertEqual(p6[IPv6].hlim, rx[IPv6].hlim) stats = self.statistics.get_counter("/net/punt") - self.assertEqual(stats[0][7]['packets'], 2*65) - self.assertEqual(stats[0][8]['packets'], 2*65) + self.assertEqual(stats[0][7]['packets'], 2*NUM_PKTS) + self.assertEqual(stats[0][8]['packets'], 2*NUM_PKTS) # # add another registration for the same reason to send packets @@ -799,17 +801,17 @@ class TestPunt(VppTestCase): self.vapi.cli("test punt pg1 %s" % self.pg1.remote_ip6) self.vapi.cli("clear trace") - self.pg2.add_stream(p4 * 65) + self.pg2.add_stream(p4 * NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - rxd = self.pg0.get_capture(65) + rxd = self.pg0.get_capture(NUM_PKTS) for rx in rxd: self.assertEqual(rx[Ether].dst, self.pg0.remote_mac) self.assertEqual(rx[Ether].src, self.pg0.local_mac) self.assertEqual(p4[IP].dst, rx[IP].dst) self.assertEqual(p4[IP].ttl, rx[IP].ttl) - rxd = self.pg1.get_capture(65) + rxd = self.pg1.get_capture(NUM_PKTS) for rx in rxd: self.assertEqual(rx[Ether].dst, self.pg1.remote_mac) self.assertEqual(rx[Ether].src, self.pg1.local_mac) @@ -817,17 +819,17 @@ class TestPunt(VppTestCase): self.assertEqual(p4[IP].ttl, rx[IP].ttl) self.vapi.cli("clear trace") - self.pg2.add_stream(p6 * 65) + self.pg2.add_stream(p6 * NUM_PKTS) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - rxd = self.pg0.get_capture(65) + rxd = self.pg0.get_capture(NUM_PKTS) for rx in rxd: self.assertEqual(rx[Ether].dst, self.pg0.remote_mac) self.assertEqual(rx[Ether].src, self.pg0.local_mac) self.assertEqual(p6[IPv6].dst, rx[IPv6].dst) self.assertEqual(p6[IPv6].hlim, rx[IPv6].hlim) - rxd = self.pg1.get_capture(65) + rxd = self.pg1.get_capture(NUM_PKTS) for rx in rxd: self.assertEqual(rx[Ether].dst, self.pg1.remote_mac) self.assertEqual(rx[Ether].src, self.pg1.local_mac) @@ -835,8 +837,8 @@ class TestPunt(VppTestCase): self.assertEqual(p6[IPv6].hlim, rx[IPv6].hlim) stats = self.statistics.get_counter("/net/punt") - self.assertEqual(stats[0][7]['packets'], 3*65) - self.assertEqual(stats[0][8]['packets'], 3*65) + self.assertEqual(stats[0][7]['packets'], 3*NUM_PKTS) + self.assertEqual(stats[0][8]['packets'], 3*NUM_PKTS) self.logger.info(self.vapi.cli("show vlib graph punt-dispatch")) self.logger.info(self.vapi.cli("show punt client")) 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) diff --git a/test/test_svs.py b/test/test_svs.py index b4e6722baa8..9a9ac57016b 100644 --- a/test/test_svs.py +++ b/test/test_svs.py @@ -12,6 +12,8 @@ from scapy.layers.inet6 import IPv6 from vpp_papi import VppEnum +NUM_PKTS = 67 + class TestSVS(VppTestCase): """ SVS Test Case """ @@ -127,12 +129,12 @@ class TestSVS(VppTestCase): # # now all the packets should be delivered out the respective interface # - self.send_and_expect(self.pg0, pkts_0[0] * 65, self.pg1) - self.send_and_expect(self.pg0, pkts_0[1] * 65, self.pg2) - self.send_and_expect(self.pg0, pkts_0[2] * 65, self.pg3) - self.send_and_expect(self.pg1, pkts_1[0] * 65, self.pg1) - self.send_and_expect(self.pg1, pkts_1[1] * 65, self.pg2) - self.send_and_expect(self.pg1, pkts_1[2] * 65, self.pg3) + self.send_and_expect(self.pg0, pkts_0[0] * NUM_PKTS, self.pg1) + self.send_and_expect(self.pg0, pkts_0[1] * NUM_PKTS, self.pg2) + self.send_and_expect(self.pg0, pkts_0[2] * NUM_PKTS, self.pg3) + self.send_and_expect(self.pg1, pkts_1[0] * NUM_PKTS, self.pg1) + self.send_and_expect(self.pg1, pkts_1[1] * NUM_PKTS, self.pg2) + self.send_and_expect(self.pg1, pkts_1[2] * NUM_PKTS, self.pg3) # # check that if the SVS lookup does not match a route the packet @@ -142,13 +144,13 @@ class TestSVS(VppTestCase): IP(src=self.pg0.remote_ip4, dst=self.pg0.remote_ip4) / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg0, p * 65, self.pg0) + self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg0) p = (Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) / IP(src=self.pg1.remote_ip4, dst=self.pg1.remote_ip4) / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg1, p * 65, self.pg1) + self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg1) # # dump the SVS configs @@ -257,12 +259,12 @@ class TestSVS(VppTestCase): # # now all the packets should be delivered out the respective interface # - self.send_and_expect(self.pg0, pkts_0[0] * 65, self.pg1) - self.send_and_expect(self.pg0, pkts_0[1] * 65, self.pg2) - self.send_and_expect(self.pg0, pkts_0[2] * 65, self.pg3) - self.send_and_expect(self.pg1, pkts_1[0] * 65, self.pg1) - self.send_and_expect(self.pg1, pkts_1[1] * 65, self.pg2) - self.send_and_expect(self.pg1, pkts_1[2] * 65, self.pg3) + self.send_and_expect(self.pg0, pkts_0[0] * NUM_PKTS, self.pg1) + self.send_and_expect(self.pg0, pkts_0[1] * NUM_PKTS, self.pg2) + self.send_and_expect(self.pg0, pkts_0[2] * NUM_PKTS, self.pg3) + self.send_and_expect(self.pg1, pkts_1[0] * NUM_PKTS, self.pg1) + self.send_and_expect(self.pg1, pkts_1[1] * NUM_PKTS, self.pg2) + self.send_and_expect(self.pg1, pkts_1[2] * NUM_PKTS, self.pg3) # # check that if the SVS lookup does not match a route the packet @@ -272,13 +274,13 @@ class TestSVS(VppTestCase): IPv6(src=self.pg0.remote_ip6, dst=self.pg0.remote_ip6) / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg0, p * 65, self.pg0) + self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg0) p = (Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) / IPv6(src=self.pg1.remote_ip6, dst=self.pg1.remote_ip6) / UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)) - self.send_and_expect(self.pg1, p * 65, self.pg1) + self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg1) # # dump the SVS configs 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): |