Commit 1893341e authored by Petr Špaček's avatar Petr Špaček

Deckard: get rid of double negative in NO_MINIMIZE in favor of QMIN

The double negative was driving me crazy so when I was changing the code
parameter processing code path I changed replaced boolean NO_MINIMIZE
with QMIN.
parent 9d48afa5
......@@ -43,7 +43,7 @@ then the DNSSEC tests won't work properly).
- ``ROOT_ADDR`` - root server hint. Port is not set and assumed to be equal to 53.
- ``SELF_ADDR`` - assigned address for the tested binary. Port is not set and assumed to be equal to 53.
- ``NO_MINIMIZE`` - ``'true'`` or ``'false'``, disables or enables query minimization respectively. (Default: disabled)
- ``QMIN`` - ``'true'`` or ``'false'``, enables or disables query minimization respectively. (Default: enabled)
- ``WORKING_DIR`` - working directory, equivalent to the value of a ``SOCKET_WRAPPER_DIR``
environment variable.
- ``INSTALL_DIR`` - Deckard home directory
......
......@@ -97,7 +97,7 @@ def write_timestamp_file(path, tst):
time_file.close()
def setup_env(scenario, child_env, config, config_name_list, j2template_list):
def setup_env(scenario, child_env, config, args):
""" Set up test environment and config """
# Clear test directory
del_files(TMPDIR, False)
......@@ -113,7 +113,7 @@ def setup_env(scenario, child_env, config, config_name_list, j2template_list):
# do not pass SOCKET_WRAPPER_PCAP_FILE into child to avoid duplicate packets in pcap
if "SOCKET_WRAPPER_PCAP_FILE" in child_env:
del child_env["SOCKET_WRAPPER_PCAP_FILE"]
no_minimize = os.environ.get("NO_MINIMIZE", "true")
qmin = args.qmin
trust_anchor_list = []
stub_addr = ""
features = {}
......@@ -122,8 +122,8 @@ def setup_env(scenario, child_env, config, config_name_list, j2template_list):
selfaddr = testserver.get_local_addr_str(socket.AF_INET, DEFAULT_IFACE)
for k, v in config:
# Enable selectively for some tests
if k == 'query-minimization' and str2bool(v):
no_minimize = "false"
if k == 'query-minimization':
qmin = str2bool(v)
elif k == 'trust-anchor':
trust_anchor_list.append(v.strip('"\''))
elif k == 'val-override-timestamp':
......@@ -192,13 +192,13 @@ def setup_env(scenario, child_env, config, config_name_list, j2template_list):
j2template_ctx = {
"ROOT_ADDR": selfaddr,
"SELF_ADDR": childaddr,
"NO_MINIMIZE": no_minimize,
"QMIN": str(qmin).lower(),
"TRUST_ANCHORS": trust_anchor_list,
"WORKING_DIR": TMPDIR,
"INSTALL_DIR": INSTALLDIR,
"FEATURES": features
}
for template_name, config_name in zip(j2template_list, config_name_list):
for template_name, config_name in zip(args.templates, args.configs):
j2template = j2template_env.get_template(template_name)
cfg_rendered = j2template.render(j2template_ctx)
f = open(os.path.join(TMPDIR, config_name), 'w')
......@@ -214,7 +214,7 @@ def play_object(path, args):
# Setup daemon environment
daemon_env = os.environ.copy()
setup_env(case, daemon_env, config, args.configs, args.templates)
setup_env(case, daemon_env, config, args)
server = testserver.TestServer(case, config, DEFAULT_IFACE)
server.start()
......@@ -299,7 +299,21 @@ if __name__ == '__main__':
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, values.split(':'))
class EnvDefault(argparse.Action): # pylint: disable=too-few-public-methods
"""Get default value for parameter from environment variable."""
def __init__(self, envvar, required=True, default=None, **kwargs):
if envvar and envvar in os.environ:
default = os.environ[envvar]
if required and default is not None:
required = False
super(EnvDefault, self).__init__(default=default, required=required, **kwargs)
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, values)
argparser = argparse.ArgumentParser()
argparser.add_argument('--qmin', help='query minimization (default: enabled)', default=True,
action=EnvDefault, envvar='QMIN', type=str2bool)
argparser.add_argument('scenario', help='path to test scenario')
argparser.add_argument('binary', help='executable to test')
argparser.add_argument('templates', help='colon-separated list of jinja2 template files', action=ColonSplitter)
......
......@@ -17,8 +17,8 @@ export TESTS DAEMON TEMPLATE CONFIG
MAKEDIR="$(dirname "$(readlink -f "$0")")"
echo '=== Testing WITHOUT query minimization ==='
export NO_MINIMIZE="true"
export QMIN="false"
make -C "${MAKEDIR}"
echo '=== Testing WITH query minimization ==='
export NO_MINIMIZE="false"
export QMIN="true"
make -C "${MAKEDIR}"
......@@ -2,7 +2,11 @@ net = { '{{SELF_ADDR}}' }
modules = {'stats', 'policy', 'hints'}
cache.size = 2*MB
hints.root({['k.root-servers.net'] = '{{ROOT_ADDR}}'})
option('NO_MINIMIZE', {{NO_MINIMIZE}})
{% if QMIN == "false" %}
option('NO_MINIMIZE', true)
{% else %}
option('NO_MINIMIZE', false)
{% endif %}
-- Run tests in permissive mode
option('PERMISSIVE', true)
-- Always retry failing resolver
......
......@@ -364,7 +364,7 @@ server:
# Sent minimum amount of information to upstream servers to enhance
# privacy. Only sent minimum required labels of the QNAME and set QTYPE
# to NS when possible.
{% if NO_MINIMIZE == "true" %}
{% if QMIN == "false" %}
qname-minimisation: no
{% else %}
qname-minimisation: yes
......
......@@ -21,8 +21,8 @@ export TESTS DAEMON TEMPLATE CONFIG ADDITIONAL
MAKEDIR="$(dirname "$(readlink -f "$0")")"
echo '=== Testing WITHOUT query minimization ==='
export NO_MINIMIZE="true"
export QMIN="false"
make -C "${MAKEDIR}"
echo '=== Testing WITH query minimization ==='
export NO_MINIMIZE="false"
export QMIN="true"
make -C "${MAKEDIR}"
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