summaryrefslogtreecommitdiffstats
path: root/test/test_l2bd_multi_instance.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_l2bd_multi_instance.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_l2bd_multi_instance.py')
-rw-r--r--test/test_l2bd_multi_instance.py15
1 files changed, 2 insertions, 13 deletions
diff --git a/test/test_l2bd_multi_instance.py b/test/test_l2bd_multi_instance.py
index 1272d7656a2..a12262224d0 100644
--- a/test/test_l2bd_multi_instance.py
+++ b/test/test_l2bd_multi_instance.py
@@ -138,7 +138,6 @@ class TestL2bdMultiInst(VppTestCase):
Clear trace and packet infos before running each test.
"""
super(TestL2bdMultiInst, self).setUp()
- self.packet_infos = {}
def tearDown(self):
"""
@@ -243,8 +242,7 @@ class TestL2bdMultiInst(VppTestCase):
for i in range(0, n_int):
dst_host = dst_hosts[i]
src_host = random.choice(src_hosts)
- pkt_info = self.create_packet_info(
- src_if.sw_if_index, dst_if.sw_if_index)
+ pkt_info = self.create_packet_info(src_if, dst_if)
payload = self.info_to_payload(pkt_info)
p = (Ether(dst=dst_host.mac, src=src_host.mac) /
IP(src=src_host.ip4, dst=dst_host.ip4) /
@@ -393,17 +391,8 @@ class TestL2bdMultiInst(VppTestCase):
for pg_if in self.pg_interfaces:
capture = pg_if.get_capture()
if pg_if in self.pg_in_bd:
- if len(capture) == 0:
- raise RuntimeError("Interface %s is in BD but the capture "
- "is empty!" % pg_if.name)
self.verify_capture(pg_if, capture)
- elif pg_if in self.pg_not_in_bd:
- try:
- self.assertEqual(len(capture), 0)
- except AssertionError:
- raise RuntimeError("Interface %s is not in BD but "
- "the capture is not empty!" % pg_if.name)
- else:
+ elif pg_if not in self.pg_not_in_bd:
self.logger.error("Unknown interface: %s" % pg_if.name)
def test_l2bd_inst_01(self):