diff options
author | Neale Ranns <nranns@cisco.com> | 2018-01-08 04:41:42 -0800 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2018-01-09 12:41:23 +0000 |
commit | 52fae862646e25bac6d1cd11b9fc7ac77299bc25 (patch) | |
tree | f83888cd0ff250ca73f3983a69b2cc4fe224acc2 | |
parent | 07a45bd897c19520c6c8651f9a1b66809981c80e (diff) |
test: consolidate the multiple versions of send_and_*
Change-Id: I7fa7d0ebf73dab8264a2e5ddbd412600d78ead05
Signed-off-by: Neale Ranns <nranns@cisco.com>
-rw-r--r-- | test/framework.py | 19 | ||||
-rw-r--r-- | test/test_bier.py | 15 | ||||
-rw-r--r-- | test/test_dhcp.py | 7 | ||||
-rw-r--r-- | test/test_dvr.py | 17 | ||||
-rw-r--r-- | test/test_ip4.py | 73 | ||||
-rw-r--r-- | test/test_ip6.py | 49 | ||||
-rw-r--r-- | test/test_map.py | 7 | ||||
-rw-r--r-- | test/test_mpls.py | 23 | ||||
-rw-r--r-- | test/test_neighbor.py | 10 | ||||
-rw-r--r-- | test/test_udp.py | 18 |
10 files changed, 31 insertions, 207 deletions
diff --git a/test/framework.py b/test/framework.py index 210eadbf4c5..2e3f9781e5d 100644 --- a/test/framework.py +++ b/test/framework.py @@ -747,6 +747,25 @@ class VppTestCase(unittest.TestCase): "Finished sleep (%s) - slept %ss (wanted %ss)" % ( remark, after - before, timeout)) + def send_and_assert_no_replies(self, intf, pkts, remark=""): + self.vapi.cli("clear trace") + intf.add_stream(pkts) + self.pg_enable_capture(self.pg_interfaces) + self.pg_start() + timeout = 1 + for i in self.pg_interfaces: + i.get_capture(0, timeout=timeout) + i.assert_nothing_captured(remark=remark) + timeout = 0.1 + + def send_and_expect(self, input, pkts, output): + self.vapi.cli("clear trace") + input.add_stream(pkts) + self.pg_enable_capture(self.pg_interfaces) + self.pg_start() + rx = output.get_capture(len(pkts)) + return rx + class TestCasePrinter(object): _shared_state = {} diff --git a/test/test_bier.py b/test/test_bier.py index 514265cb5b5..e9c23febdd1 100644 --- a/test/test_bier.py +++ b/test/test_bier.py @@ -66,21 +66,6 @@ class TestBier(VppTestCase): i.admin_down() super(TestBier, self).tearDown() - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.assert_nothing_captured(remark=remark) - - def send_and_expect(self, input, pkts, output): - self.vapi.cli("trace add bier-mpls-lookup 10") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - def test_bier_midpoint(self): """BIER midpoint""" diff --git a/test/test_dhcp.py b/test/test_dhcp.py index 7ae98e8e83b..db7a7cc223c 100644 --- a/test/test_dhcp.py +++ b/test/test_dhcp.py @@ -77,13 +77,6 @@ class TestDHCP(VppTestCase): i.admin_down() super(TestDHCP, self).tearDown() - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.assert_nothing_captured(remark=remark) - def verify_dhcp_has_option(self, pkt, option, value): dhcp = pkt[DHCP] found = False diff --git a/test/test_dvr.py b/test/test_dvr.py index e8a9c04a1bb..e7b68db2ac7 100644 --- a/test/test_dvr.py +++ b/test/test_dvr.py @@ -36,23 +36,6 @@ class TestDVR(VppTestCase): super(TestDVR, self).tearDown() - def send_and_assert_no_replies(self, intf, pkts): - self.vapi.cli("clear trace") - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured() - - def send_and_expect(self, input, pkts, output): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - def assert_same_mac_addr(self, tx, rx): t_eth = tx[Ether] for p in rx: diff --git a/test/test_ip4.py b/test/test_ip4.py index 12fbced1c26..79d4a36285c 100644 --- a/test/test_ip4.py +++ b/test/test_ip4.py @@ -572,14 +572,6 @@ class TestIPDisabled(VppTestCase): i.unconfig_ip4() i.admin_down() - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_disabled(self): """ IP Disabled """ @@ -667,14 +659,6 @@ class TestIPSubNets(VppTestCase): for i in self.pg_interfaces: i.admin_down() - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_sub_nets(self): """ IP Sub Nets """ @@ -985,12 +969,6 @@ class TestIPVlan0(VppTestCase): i.admin_down() super(TestIPVlan0, self).tearDown() - def send_and_expect(self, input, pkts, output): - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - def test_ip_vlan_0(self): """ IP VLAN-0 """ @@ -1028,23 +1006,6 @@ class TestIPPunt(VppTestCase): i.unconfig_ip4() i.admin_down() - def send_and_expect(self, input, pkts, output): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - - def send_and_assert_no_replies(self, intf, pkts, remark): - self.vapi.cli("clear trace") - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_punt(self): """ IP punt police and redirect """ @@ -1138,23 +1099,6 @@ class TestIPDeag(VppTestCase): i.unconfig_ip4() i.admin_down() - def send_and_expect(self, input, pkts, output): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - - def send_and_assert_no_replies(self, intf, pkts, remark): - self.vapi.cli("clear trace") - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_deag(self): """ IP Deag Routes """ @@ -1246,23 +1190,6 @@ class TestIPInput(VppTestCase): i.unconfig_ip4() i.admin_down() - def send_and_expect(self, input, pkts, output): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - - def send_and_assert_no_replies(self, intf, pkts, remark): - self.vapi.cli("clear trace") - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_input(self): """ IP Input Exceptions """ diff --git a/test/test_ip6.py b/test/test_ip6.py index 684eff5546e..68b077c1f8f 100644 --- a/test/test_ip6.py +++ b/test/test_ip6.py @@ -136,14 +136,6 @@ class TestIPv6ND(VppTestCase): rx = rx[0] self.validate_ns(rx_intf, rx, tgt_ip) - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def verify_ip(self, rx, smac, dmac, sip, dip): ether = rx[Ether] self.assertEqual(ether.dst, dmac) @@ -1179,14 +1171,6 @@ class TestIPDisabled(VppTestCase): i.unconfig_ip4() i.admin_down() - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_disabled(self): """ IP Disabled """ @@ -1528,22 +1512,6 @@ class TestIP6Punt(VppTestCase): i.unconfig_ip6() i.admin_down() - def send_and_expect(self, input, pkts, output): - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - - def send_and_assert_no_replies(self, intf, pkts, remark): - self.vapi.cli("clear trace") - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_punt(self): """ IP6 punt police and redirect """ @@ -1641,23 +1609,6 @@ class TestIP6Input(VppTestCase): i.unconfig_ip6() i.admin_down() - def send_and_expect(self, input, pkts, output): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - - def send_and_assert_no_replies(self, intf, pkts, remark): - self.vapi.cli("clear trace") - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_ip_input(self): """ IP6 Input Exceptions """ diff --git a/test/test_map.py b/test/test_map.py index bbf4aec269f..c5e193a975f 100644 --- a/test/test_map.py +++ b/test/test_map.py @@ -38,13 +38,6 @@ class TestMAP(VppTestCase): i.unconfig_ip6() i.admin_down() - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.assert_nothing_captured(remark=remark) - def send_and_assert_encapped(self, tx, ip6_src, ip6_dst, dmac=None): if not dmac: dmac = self.pg1.remote_mac diff --git a/test/test_mpls.py b/test/test_mpls.py index 9590519e237..aa5e67439b7 100644 --- a/test/test_mpls.py +++ b/test/test_mpls.py @@ -314,13 +314,6 @@ class TestMPLS(VppTestCase): except: raise - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.assert_nothing_captured(remark=remark) - def test_swap(self): """ MPLS label swap tests """ @@ -1218,7 +1211,13 @@ class TestMPLS(VppTestCase): # tx = self.create_stream_labelled_ip6(self.pg0, [34], 255, dst_ip="ff01::1", hlim=1) - self.send_and_assert_no_replies(self.pg0, tx, "Hop Limt Expired") + self.pg0.add_stream(tx) + + self.pg_enable_capture(self.pg_interfaces) + self.pg_start() + + rx = self.pg0.get_capture(257) + self.verify_capture_ip6_icmp(self.pg0, rx, tx) # # set the RPF-ID of the enrtry to not match the input packet's @@ -1258,14 +1257,6 @@ class TestMPLSDisabled(VppTestCase): self.pg0.disable_mpls() super(TestMPLSDisabled, self).tearDown() - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - for i in self.pg_interfaces: - i.get_capture(0) - i.assert_nothing_captured(remark=remark) - def test_mpls_disabled(self): """ MPLS Disabled """ diff --git a/test/test_neighbor.py b/test/test_neighbor.py index 565a8b4442d..47e9c5bed76 100644 --- a/test/test_neighbor.py +++ b/test/test_neighbor.py @@ -132,16 +132,6 @@ class ARPTestCase(VppTestCase): self.assertEqual(ip.src, sip) self.assertEqual(ip.dst, dip) - def send_and_assert_no_replies(self, intf, pkts, remark): - intf.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - timeout = 1 - for i in self.pg_interfaces: - i.get_capture(0, timeout=timeout) - i.assert_nothing_captured(remark=remark) - timeout = 0.1 - def test_arp(self): """ ARP """ diff --git a/test/test_udp.py b/test/test_udp.py index 7853ac3b3f4..68b023c5e2f 100644 --- a/test/test_udp.py +++ b/test/test_udp.py @@ -79,14 +79,6 @@ class TestUdpEncap(VppTestCase): self.assertEqual(rx.dst, tx[IPv6].dst) self.assertEqual(rx.hlim, tx[IPv6].hlim) - def send_and_expect(self, input, output, pkts): - self.vapi.cli("clear trace") - input.add_stream(pkts) - self.pg_enable_capture(self.pg_interfaces) - self.pg_start() - rx = output.get_capture(len(pkts)) - return rx - def test_udp_encap(self): """ UDP Encap test """ @@ -159,7 +151,7 @@ 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, self.pg0, p_4o4*65) + rx = self.send_and_expect(self.pg0, p_4o4*65, self.pg0) for p in rx: self.validate_outer4(p, udp_encap_0) p = IP(p["UDP"].payload.load) @@ -173,7 +165,7 @@ 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, self.pg2, p_4o6*65) + rx = self.send_and_expect(self.pg0, p_4o6*65, self.pg2) for p in rx: self.validate_outer6(p, udp_encap_2) p = IP(p["UDP"].payload.load) @@ -187,7 +179,7 @@ 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, self.pg1, p_6o4*65) + rx = self.send_and_expect(self.pg0, p_6o4*65, self.pg1) for p in rx: self.validate_outer4(p, udp_encap_1) p = IPv6(p["UDP"].payload.load) @@ -201,7 +193,7 @@ 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, self.pg3, p_6o6*65) + rx = self.send_and_expect(self.pg0, p_6o6*65, self.pg3) for p in rx: self.validate_outer6(p, udp_encap_3) p = IPv6(p["UDP"].payload.load) @@ -224,7 +216,7 @@ 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, self.pg1, p_4omo4*65) + rx = self.send_and_expect(self.pg0, p_4omo4*65, self.pg1) for p in rx: self.validate_outer4(p, udp_encap_1) p = MPLS(p["UDP"].payload.load) |