aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_lb.py
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2016-12-21 08:50:14 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2016-12-23 17:38:33 +0000
commitdab231a11ec96e829b22ff80c612333edc5a93e6 (patch)
treee3440df2b4bc1af7a0e4973c0bfa839572d87c4d /test/test_lb.py
parentfc262a0cf77e3c14ff1d6c006e7eac70999b926f (diff)
make test: improve handling of packet captures
Perform accounting of expected packets based on created packet infos. Use this accounting info to automatically expect (and verify) the correct number of packets to be captured. Automatically retry the read of the capture file if scapy raises an exception while doing so to handle rare cases when capture file is read while only partially written during busy wait. Don't fail assert_nothing_captured if only junk packets arrived. Change-Id: I16ec2e9410ef510d313ec16b7e13c57d0b2a63f5 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/test_lb.py')
-rw-r--r--test/test_lb.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/test/test_lb.py b/test/test_lb.py
index 9b5baaea..e5802d99 100644
--- a/test/test_lb.py
+++ b/test/test_lb.py
@@ -69,10 +69,10 @@ class TestLB(VppTestCase):
UDP(sport=10000 + id, dport=20000 + id))
def generatePackets(self, src_if, isv4):
- self.packet_infos = {}
+ self.reset_packet_infos()
pkts = []
for pktid in self.packets:
- info = self.create_packet_info(src_if.sw_if_index, pktid)
+ info = self.create_packet_info(src_if, self.pg1)
payload = self.info_to_payload(info)
ip = self.getIPv4Flow(pktid) if isv4 else self.getIPv6Flow(pktid)
packet = (Ether(dst=src_if.local_mac, src=src_if.remote_mac) /
@@ -90,14 +90,13 @@ class TestLB(VppTestCase):
self.assertEqual(gre.version, 0)
inner = IPver(str(gre.payload))
payload_info = self.payload_to_info(str(inner[Raw]))
- self.info = self.get_next_packet_info_for_interface2(
- self.pg0.sw_if_index, payload_info.dst, self.info)
+ self.info = self.packet_infos[payload_info.index]
+ self.assertEqual(payload_info.src, self.pg0.sw_if_index)
self.assertEqual(str(inner), str(self.info.data[IPver]))
def checkCapture(self, gre4, isv4):
self.pg0.assert_nothing_captured()
- out = self.pg1.get_capture()
- self.assertEqual(len(out), len(self.packets))
+ out = self.pg1.get_capture(len(self.packets))
load = [0] * len(self.ass)
self.info = None