Commit 5436af53 authored by Petr Špaček's avatar Petr Špaček

Merge branch 'detect-load' into 'master'

notify user when Deckard is running under load

See merge request !133
parents 1d84273c b2ed95d7
Pipeline #39592 failed with stage
in 1 minute and 20 seconds
......@@ -10,6 +10,7 @@ import subprocess
import tempfile
import time
import dpkt
import jinja2
from pydnstest import scenario, testserver
......@@ -21,6 +22,10 @@ INSTALLDIR = os.path.dirname(os.path.abspath(__file__))
class DeckardUnderLoadError(Exception):
class IfaceManager(object):
Network interface allocation manager
......@@ -322,6 +327,21 @@ def setup_daemons(tmpdir, prog_cfgs, template_ctx, ta_files):
return daemons
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:
ip = dpkt.ip.IP(packet)
except dpkt.dpkt.UnpackError:
ip = dpkt.ip6.IP6(packet)
if isinstance(, dpkt.icmp.ICMP) or isinstance(, dpkt.icmp6.ICMP6):
return True
return False
def run_testcase(daemons, case, root_addr, addr_family, prog_under_test_ip):
"""Run actual test and raise exception if the test failed"""
server = testserver.TestServer(case, root_addr, addr_family)
......@@ -344,4 +364,11 @@ 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():
logging.error("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)')
......@@ -13,6 +13,7 @@ import time
import dns.message
import dns.rdatatype
import dpkt
from pydnstest import scenario
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