Verified Commit 5369f011 authored by Štěpán Balážik's avatar Štěpán Balážik Committed by Petr Špaček

change when we check if Deckard was under load

Some cases where falling through.
parent 5373adcb
......@@ -332,18 +332,28 @@ def setup_daemons(tmpdir, prog_cfgs, template_ctx, ta_files):
def check_for_icmp():
""" Checks Deckards's PCAP for ICMP packets """
path = os.environ["SOCKET_WRAPPER_PCAP_FILE"]
with open(path, "rb") as f:
pcap = dpkt.pcap.Reader(f)
for _, packet in pcap:
try:
ip = dpkt.ip.IP(packet)
except dpkt.dpkt.UnpackError:
ip = dpkt.ip6.IP6(packet)
if isinstance(ip.data, (dpkt.icmp.ICMP, dpkt.icmp6.ICMP6)):
return True
return False
""" Checks Deckards's PCAP for ICMP packets """
# Deckard's responses to resolvers might be delayed due to load which
# leads the resolver to close the port and to the test failing in the
# end. We partially detect these by checking the PCAP for ICMP packets.
path = os.environ["SOCKET_WRAPPER_PCAP_FILE"]
udp_seen = False
with open(path, "rb") as f:
pcap = dpkt.pcap.Reader(f)
for _, packet in pcap:
try:
ip = dpkt.ip.IP(packet)
except dpkt.dpkt.UnpackError:
ip = dpkt.ip6.IP6(packet)
if isinstance(ip.data, dpkt.udp.UDP):
udp_seen = True
if udp_seen:
if isinstance(ip.data, dpkt.icmp.ICMP) or isinstance(ip.data, dpkt.icmp6.ICMP6):
raise DeckardUnderLoadError("Deckard is under load. "
"Other errors might be false negatives. "
"Consider retrying the job later.")
return False
def run_testcase(daemons, case, root_addr, addr_family, prog_under_test_ip):
......@@ -353,6 +363,9 @@ def run_testcase(daemons, case, root_addr, addr_family, prog_under_test_ip):
try:
server.play(prog_under_test_ip)
except ValueError as e:
if not check_for_icmp():
raise e
finally:
server.stop()
for daemon in daemons:
......@@ -368,11 +381,5 @@ def run_testcase(daemons, case, root_addr, addr_family, prog_under_test_ip):
% (daemon['cfg']['name'], daemon['proc'].returncode))
# Do not clear files if the server crashed (for analysis)
if server.undefined_answers > 0:
# Deckard's responses to resolvers might be delayed due to load which
# leads the resolver to close the port and to the test failing in the
# end. We partially detect these by checking the PCAP for ICMP packets.
if check_for_icmp():
raise DeckardUnderLoadError("Deckard is under load.\
Other errors might be false negatives.\
Consider retrying the job later.")
raise ValueError('the scenario does not define all necessary answers (see error log)')
if not check_for_icmp():
raise ValueError('the scenario does not define all necessary answers (see error log)')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment