make test: improve robustness and performance
Introduce an API which asserts empty capture for interface. Throw exception in old API if the capture does not exist, thus making it clear if the test expects packets to arrive or not. Improve performance by not doing sleeps after starting the packet generator, rather lazily deleting captures when needed. Fix wrong usage of packet.show() in various tests. Change-Id: I456cb23316eef99b3f35f80344fe595c4db9a21c Signed-off-by: Klement Sekera <ksekera@cisco.com>
This commit is contained in:
committed by
Ole Trøan
parent
cc53285baf
commit
9225dee965
@@ -1,7 +1,7 @@
|
||||
import socket
|
||||
|
||||
from scapy.layers.inet import IP, UDP
|
||||
from scapy.layers.inet6 import IPv6
|
||||
from scapy.layers.inet6 import ICMPv6ND_RA, IPv6
|
||||
from scapy.layers.l2 import Ether, GRE
|
||||
from scapy.packet import Raw
|
||||
|
||||
@@ -95,10 +95,16 @@ class TestLB(VppTestCase):
|
||||
self.assertEqual(str(inner), str(self.info.data[IPver]))
|
||||
|
||||
def checkCapture(self, gre4, isv4):
|
||||
out = self.pg0.get_capture()
|
||||
# This check is edited because RA appears in output, maybe disable RA?
|
||||
# self.assertEqual(len(out), 0)
|
||||
self.assertLess(len(out), 20)
|
||||
# RA might appear in capture
|
||||
try:
|
||||
out = self.pg0.get_capture()
|
||||
# filter out any IPv6 RAs from the capture
|
||||
for p in out:
|
||||
if (p.haslayer(ICMPv6ND_RA)):
|
||||
out.remove(p)
|
||||
self.assertEqual(len(out), 0)
|
||||
except:
|
||||
pass
|
||||
out = self.pg1.get_capture()
|
||||
self.assertEqual(len(out), len(self.packets))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user