summaryrefslogtreecommitdiffstats
path: root/bin/tests/system/statschannel
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:41:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:41:29 +0000
commite2fc8e037ea6bb5de92b25ec9c12a624737ac5ca (patch)
tree65e6bbf5e12c3fe09b43e577f8d1786d06bcd559 /bin/tests/system/statschannel
parentReleasing progress-linux version 1:9.18.19-1~deb12u1progress7u1. (diff)
downloadbind9-e2fc8e037ea6bb5de92b25ec9c12a624737ac5ca.tar.xz
bind9-e2fc8e037ea6bb5de92b25ec9c12a624737ac5ca.zip
Merging upstream version 1:9.18.24.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bin/tests/system/statschannel')
-rw-r--r--bin/tests/system/statschannel/conftest.py14
-rw-r--r--bin/tests/system/statschannel/generic.py147
-rw-r--r--bin/tests/system/statschannel/generic_dnspython.py128
-rw-r--r--bin/tests/system/statschannel/ns2/sign.sh20
-rw-r--r--bin/tests/system/statschannel/prereq.sh26
-rw-r--r--bin/tests/system/statschannel/setup.sh2
-rw-r--r--bin/tests/system/statschannel/tests.sh583
-rwxr-xr-xbin/tests/system/statschannel/tests_json.py11
-rwxr-xr-xbin/tests/system/statschannel/tests_xml.py11
9 files changed, 472 insertions, 470 deletions
diff --git a/bin/tests/system/statschannel/conftest.py b/bin/tests/system/statschannel/conftest.py
index 363dd7a..c26935b 100644
--- a/bin/tests/system/statschannel/conftest.py
+++ b/bin/tests/system/statschannel/conftest.py
@@ -9,17 +9,9 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import os
import pytest
-@pytest.fixture
-def statsport(request):
- # pylint: disable=unused-argument
- env_port = os.getenv("EXTRAPORT1")
- if env_port is None:
- env_port = 5301
- else:
- env_port = int(env_port)
-
- return env_port
+@pytest.fixture(scope="module")
+def statsport(ports):
+ return ports["EXTRAPORT1"]
diff --git a/bin/tests/system/statschannel/generic.py b/bin/tests/system/statschannel/generic.py
index bf4b038..f4b3d85 100644
--- a/bin/tests/system/statschannel/generic.py
+++ b/bin/tests/system/statschannel/generic.py
@@ -10,8 +10,16 @@
# information regarding copyright ownership.
from datetime import datetime, timedelta
+from collections import defaultdict
+from time import sleep
import os
+import dns.message
+import dns.query
+import dns.rcode
+
+import isctest
+
# ISO datetime format without msec
fmt = "%Y-%m-%dT%H:%M:%SZ"
@@ -19,9 +27,11 @@ fmt = "%Y-%m-%dT%H:%M:%SZ"
# The constants were taken from BIND 9 source code (lib/dns/zone.c)
max_refresh = timedelta(seconds=2419200) # 4 weeks
max_expires = timedelta(seconds=14515200) # 24 weeks
-now = datetime.utcnow().replace(microsecond=0)
dayzero = datetime.utcfromtimestamp(0).replace(microsecond=0)
+# Wait for the secondary zone files to appear to extract their mtime
+max_secondary_zone_waittime_sec = 5
+
# Generic helper functions
def check_expires(expires, min_time, max_time):
@@ -34,21 +44,20 @@ def check_refresh(refresh, min_time, max_time):
assert refresh <= max_time
-def check_loaded(loaded, expected): # pylint: disable=unused-argument
+def check_loaded(loaded, expected, now):
# Sanity check the zone timers values
- # NOTE This check has been disabled due to GL #3983
- # assert loaded == expected
- # assert loaded < now
- pass
+ assert (loaded - expected).total_seconds() < max_secondary_zone_waittime_sec
+ assert loaded <= now
def check_zone_timers(loaded, expires, refresh, loaded_exp):
+ now = datetime.utcnow().replace(microsecond=0)
# Sanity checks the zone timers values
if expires is not None:
check_expires(expires, now, now + max_expires)
if refresh is not None:
check_refresh(refresh, now, now + max_refresh)
- check_loaded(loaded, loaded_exp)
+ check_loaded(loaded, loaded_exp, now)
#
@@ -88,12 +97,26 @@ def test_zone_timers_secondary(fetch_zones, load_timers, **kwargs):
statsport = kwargs["statsport"]
zonedir = kwargs["zonedir"]
- zones = fetch_zones(statsip, statsport)
-
- for zone in zones:
- (name, loaded, expires, refresh) = load_timers(zone, False)
- mtime = zone_mtime(zonedir, name)
- check_zone_timers(loaded, expires, refresh, mtime)
+ # If any one of the zone files isn't ready, then retry until timeout.
+ tries = max_secondary_zone_waittime_sec
+ while tries >= 0:
+ zones = fetch_zones(statsip, statsport)
+ again = False
+ for zone in zones:
+ (name, loaded, expires, refresh) = load_timers(zone, False)
+ mtime = zone_mtime(zonedir, name)
+ if (mtime != dayzero) or (tries == 0):
+ # mtime was either retrieved successfully or no tries were
+ # left, run the check anyway.
+ check_zone_timers(loaded, expires, refresh, mtime)
+ else:
+ tries = tries - 1
+ again = True
+ break
+ if again:
+ sleep(1)
+ else:
+ break
def test_zone_with_many_keys(fetch_zones, load_zone, **kwargs):
@@ -106,3 +129,101 @@ def test_zone_with_many_keys(fetch_zones, load_zone, **kwargs):
name = load_zone(zone)
if name == "manykeys":
check_manykeys(name)
+
+
+def create_msg(qname, qtype):
+ msg = dns.message.make_query(
+ qname, qtype, want_dnssec=True, use_edns=0, payload=4096
+ )
+
+ return msg
+
+
+def create_expected(data):
+ expected = {
+ "dns-tcp-requests-sizes-received-ipv4": defaultdict(int),
+ "dns-tcp-responses-sizes-sent-ipv4": defaultdict(int),
+ "dns-tcp-requests-sizes-received-ipv6": defaultdict(int),
+ "dns-tcp-responses-sizes-sent-ipv6": defaultdict(int),
+ "dns-udp-requests-sizes-received-ipv4": defaultdict(int),
+ "dns-udp-requests-sizes-received-ipv6": defaultdict(int),
+ "dns-udp-responses-sizes-sent-ipv4": defaultdict(int),
+ "dns-udp-responses-sizes-sent-ipv6": defaultdict(int),
+ }
+
+ for k, v in data.items():
+ for kk, vv in v.items():
+ expected[k][kk] += vv
+
+ return expected
+
+
+def update_expected(expected, key, msg):
+ msg_len = len(msg.to_wire())
+ bucket_num = (msg_len // 16) * 16
+ bucket = "{}-{}".format(bucket_num, bucket_num + 15)
+
+ expected[key][bucket] += 1
+
+
+def check_traffic(data, expected):
+ def ordered(obj):
+ if isinstance(obj, dict):
+ return sorted((k, ordered(v)) for k, v in obj.items())
+ if isinstance(obj, list):
+ return sorted(ordered(x) for x in obj)
+ return obj
+
+ ordered_data = ordered(data)
+ ordered_expected = ordered(expected)
+
+ assert len(ordered_data) == 8
+ assert len(ordered_expected) == 8
+ assert len(data) == len(ordered_data)
+ assert len(expected) == len(ordered_expected)
+
+ assert ordered_data == ordered_expected
+
+
+def test_traffic(fetch_traffic, **kwargs):
+ statsip = kwargs["statsip"]
+ statsport = kwargs["statsport"]
+
+ data = fetch_traffic(statsip, statsport)
+ exp = create_expected(data)
+
+ msg = create_msg("short.example.", "TXT")
+ update_expected(exp, "dns-udp-requests-sizes-received-ipv4", msg)
+ ans = isctest.query.udp(msg, statsip)
+ isctest.check.noerror(ans)
+ update_expected(exp, "dns-udp-responses-sizes-sent-ipv4", ans)
+ data = fetch_traffic(statsip, statsport)
+
+ check_traffic(data, exp)
+
+ msg = create_msg("long.example.", "TXT")
+ update_expected(exp, "dns-udp-requests-sizes-received-ipv4", msg)
+ ans = isctest.query.udp(msg, statsip)
+ isctest.check.noerror(ans)
+ update_expected(exp, "dns-udp-responses-sizes-sent-ipv4", ans)
+ data = fetch_traffic(statsip, statsport)
+
+ check_traffic(data, exp)
+
+ msg = create_msg("short.example.", "TXT")
+ update_expected(exp, "dns-tcp-requests-sizes-received-ipv4", msg)
+ ans = isctest.query.tcp(msg, statsip)
+ isctest.check.noerror(ans)
+ update_expected(exp, "dns-tcp-responses-sizes-sent-ipv4", ans)
+ data = fetch_traffic(statsip, statsport)
+
+ check_traffic(data, exp)
+
+ msg = create_msg("long.example.", "TXT")
+ update_expected(exp, "dns-tcp-requests-sizes-received-ipv4", msg)
+ ans = isctest.query.tcp(msg, statsip)
+ isctest.check.noerror(ans)
+ update_expected(exp, "dns-tcp-responses-sizes-sent-ipv4", ans)
+ data = fetch_traffic(statsip, statsport)
+
+ check_traffic(data, exp)
diff --git a/bin/tests/system/statschannel/generic_dnspython.py b/bin/tests/system/statschannel/generic_dnspython.py
deleted file mode 100644
index 34a0398..0000000
--- a/bin/tests/system/statschannel/generic_dnspython.py
+++ /dev/null
@@ -1,128 +0,0 @@
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# SPDX-License-Identifier: MPL-2.0
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-from collections import defaultdict
-
-import dns.message
-import dns.query
-import dns.rcode
-
-
-TIMEOUT = 10
-
-
-def create_msg(qname, qtype):
- msg = dns.message.make_query(
- qname, qtype, want_dnssec=True, use_edns=0, payload=4096
- )
-
- return msg
-
-
-def udp_query(ip, port, msg):
- ans = dns.query.udp(msg, ip, TIMEOUT, port=port)
- assert ans.rcode() == dns.rcode.NOERROR
-
- return ans
-
-
-def tcp_query(ip, port, msg):
- ans = dns.query.tcp(msg, ip, TIMEOUT, port=port)
- assert ans.rcode() == dns.rcode.NOERROR
-
- return ans
-
-
-def create_expected(data):
- expected = {
- "dns-tcp-requests-sizes-received-ipv4": defaultdict(int),
- "dns-tcp-responses-sizes-sent-ipv4": defaultdict(int),
- "dns-tcp-requests-sizes-received-ipv6": defaultdict(int),
- "dns-tcp-responses-sizes-sent-ipv6": defaultdict(int),
- "dns-udp-requests-sizes-received-ipv4": defaultdict(int),
- "dns-udp-requests-sizes-received-ipv6": defaultdict(int),
- "dns-udp-responses-sizes-sent-ipv4": defaultdict(int),
- "dns-udp-responses-sizes-sent-ipv6": defaultdict(int),
- }
-
- for k, v in data.items():
- for kk, vv in v.items():
- expected[k][kk] += vv
-
- return expected
-
-
-def update_expected(expected, key, msg):
- msg_len = len(msg.to_wire())
- bucket_num = (msg_len // 16) * 16
- bucket = "{}-{}".format(bucket_num, bucket_num + 15)
-
- expected[key][bucket] += 1
-
-
-def check_traffic(data, expected):
- def ordered(obj):
- if isinstance(obj, dict):
- return sorted((k, ordered(v)) for k, v in obj.items())
- if isinstance(obj, list):
- return sorted(ordered(x) for x in obj)
- return obj
-
- ordered_data = ordered(data)
- ordered_expected = ordered(expected)
-
- assert len(ordered_data) == 8
- assert len(ordered_expected) == 8
- assert len(data) == len(ordered_data)
- assert len(expected) == len(ordered_expected)
-
- assert ordered_data == ordered_expected
-
-
-def test_traffic(fetch_traffic, **kwargs):
- statsip = kwargs["statsip"]
- statsport = kwargs["statsport"]
- port = kwargs["port"]
-
- data = fetch_traffic(statsip, statsport)
- exp = create_expected(data)
-
- msg = create_msg("short.example.", "TXT")
- update_expected(exp, "dns-udp-requests-sizes-received-ipv4", msg)
- ans = udp_query(statsip, port, msg)
- update_expected(exp, "dns-udp-responses-sizes-sent-ipv4", ans)
- data = fetch_traffic(statsip, statsport)
-
- check_traffic(data, exp)
-
- msg = create_msg("long.example.", "TXT")
- update_expected(exp, "dns-udp-requests-sizes-received-ipv4", msg)
- ans = udp_query(statsip, port, msg)
- update_expected(exp, "dns-udp-responses-sizes-sent-ipv4", ans)
- data = fetch_traffic(statsip, statsport)
-
- check_traffic(data, exp)
-
- msg = create_msg("short.example.", "TXT")
- update_expected(exp, "dns-tcp-requests-sizes-received-ipv4", msg)
- ans = tcp_query(statsip, port, msg)
- update_expected(exp, "dns-tcp-responses-sizes-sent-ipv4", ans)
- data = fetch_traffic(statsip, statsport)
-
- check_traffic(data, exp)
-
- msg = create_msg("long.example.", "TXT")
- update_expected(exp, "dns-tcp-requests-sizes-received-ipv4", msg)
- ans = tcp_query(statsip, port, msg)
- update_expected(exp, "dns-tcp-responses-sizes-sent-ipv4", ans)
- data = fetch_traffic(statsip, statsport)
-
- check_traffic(data, exp)
diff --git a/bin/tests/system/statschannel/ns2/sign.sh b/bin/tests/system/statschannel/ns2/sign.sh
index f9429ca..5a507da 100644
--- a/bin/tests/system/statschannel/ns2/sign.sh
+++ b/bin/tests/system/statschannel/ns2/sign.sh
@@ -22,9 +22,9 @@ zonefile=dnssec.db.signed
ksk=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" -f KSK "$zone")
zsk=$("$KEYGEN" -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" "$zone")
# Sign deliberately with a very short expiration date.
-"$SIGNER" -P -S -x -O full -e "now"+1s -o "$zone" -f "$zonefile" "$infile" > "signzone.out.$zone" 2>&1
-keyfile_to_key_id "$ksk" > dnssec.ksk.id
-keyfile_to_key_id "$zsk" > dnssec.zsk.id
+"$SIGNER" -P -S -x -O full -e "now"+1s -o "$zone" -f "$zonefile" "$infile" >"signzone.out.$zone" 2>&1
+keyfile_to_key_id "$ksk" >dnssec.ksk.id
+keyfile_to_key_id "$zsk" >dnssec.zsk.id
zone=manykeys.
infile=manykeys.db.in
@@ -36,10 +36,10 @@ zsk13=$("$KEYGEN" -q -a ECDSAP256SHA256 -b 256 "$zone")
ksk14=$("$KEYGEN" -q -a ECDSAP384SHA384 -b 384 -f KSK "$zone")
zsk14=$("$KEYGEN" -q -a ECDSAP384SHA384 -b 384 "$zone")
# Sign deliberately with a very short expiration date.
-"$SIGNER" -S -x -O full -e "now"+1s -o "$zone" -f "$zonefile" "$infile" > "signzone.out.$zone" 2>&1
-keyfile_to_key_id "$ksk8" > manykeys.ksk8.id
-keyfile_to_key_id "$zsk8" > manykeys.zsk8.id
-keyfile_to_key_id "$ksk13" > manykeys.ksk13.id
-keyfile_to_key_id "$zsk13" > manykeys.zsk13.id
-keyfile_to_key_id "$ksk14" > manykeys.ksk14.id
-keyfile_to_key_id "$zsk14" > manykeys.zsk14.id
+"$SIGNER" -S -x -O full -e "now"+1s -o "$zone" -f "$zonefile" "$infile" >"signzone.out.$zone" 2>&1
+keyfile_to_key_id "$ksk8" >manykeys.ksk8.id
+keyfile_to_key_id "$zsk8" >manykeys.zsk8.id
+keyfile_to_key_id "$ksk13" >manykeys.ksk13.id
+keyfile_to_key_id "$zsk13" >manykeys.zsk13.id
+keyfile_to_key_id "$ksk14" >manykeys.ksk14.id
+keyfile_to_key_id "$zsk14" >manykeys.zsk14.id
diff --git a/bin/tests/system/statschannel/prereq.sh b/bin/tests/system/statschannel/prereq.sh
new file mode 100644
index 0000000..a0ad7a9
--- /dev/null
+++ b/bin/tests/system/statschannel/prereq.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+. ../conf.sh
+
+if ! ${PERL} -MNet::DNS -e ''; then
+ echo_i "perl Net::DNS module is required"
+ exit 1
+fi
+
+if ! ${PERL} -MFile::Fetch -e ''; then
+ echo_i "perl File::Fetch module is required"
+ exit 1
+fi
+
+exit 0
diff --git a/bin/tests/system/statschannel/setup.sh b/bin/tests/system/statschannel/setup.sh
index f5ef3ee..f304fdf 100644
--- a/bin/tests/system/statschannel/setup.sh
+++ b/bin/tests/system/statschannel/setup.sh
@@ -15,7 +15,7 @@
. ../conf.sh
for conf in ns*/named.conf.in; do
- copy_setports "$conf" "$(dirname "$conf")/$(basename "$conf" .in)"
+ copy_setports "$conf" "$(dirname "$conf")/$(basename "$conf" .in)"
done
(cd ns2 && $SHELL sign.sh)
diff --git a/bin/tests/system/statschannel/tests.sh b/bin/tests/system/statschannel/tests.sh
index f06cad4..dad9f34 100644
--- a/bin/tests/system/statschannel/tests.sh
+++ b/bin/tests/system/statschannel/tests.sh
@@ -17,71 +17,69 @@ set -e
. ../conf.sh
DIGCMD="$DIG @10.53.0.2 -p ${PORT}"
-RNDCCMD="$RNDC -c ../common/rndc.conf -p ${CONTROLPORT} -s"
-
-if ! $FEATURETEST --have-json-c
-then
- unset PERL_JSON
- echo_i "JSON was not configured; skipping" >&2
-elif $PERL -e 'use JSON;' 2>/dev/null
-then
- PERL_JSON=1
+RNDCCMD="$RNDC -c ../_common/rndc.conf -p ${CONTROLPORT} -s"
+
+if ! $FEATURETEST --have-json-c; then
+ unset PERL_JSON
+ echo_i "JSON was not configured; skipping" >&2
+elif $PERL -e 'use JSON;' 2>/dev/null; then
+ PERL_JSON=1
else
- unset PERL_JSON
- echo_i "JSON tests require JSON library; skipping" >&2
+ unset PERL_JSON
+ echo_i "JSON tests require JSON library; skipping" >&2
fi
-if ! $FEATURETEST --have-libxml2
-then
- unset PERL_XML
- echo_i "XML was not configured; skipping" >&2
-elif $PERL -e 'use XML::Simple;' 2>/dev/null
-then
- PERL_XML=1
+if ! $FEATURETEST --have-libxml2; then
+ unset PERL_XML
+ echo_i "XML was not configured; skipping" >&2
+elif $PERL -e 'use XML::Simple;' 2>/dev/null; then
+ PERL_XML=1
else
- unset PERL_XML
- echo_i "XML tests require XML::Simple; skipping" >&2
+ unset PERL_XML
+ echo_i "XML tests require XML::Simple; skipping" >&2
fi
if [ ! "$PERL_JSON" ] && [ ! "$PERL_XML" ]; then
- echo_i "skipping all tests"
- exit 0
+ echo_i "skipping all tests"
+ exit 0
fi
-
getzones() {
- sleep 1
- echo_i "... using $1"
- case $1 in
- xml) path='xml/v3/zones' ;;
- json) path='json/v1/zones' ;;
- *) return 1 ;;
- esac
- file=$($PERL fetch.pl -p ${EXTRAPORT1} $path)
- cp $file $file.$1.$3
- { $PERL zones-${1}.pl $file $2 2>/dev/null | sort > zones.out.$3; result=$?; } || true
- return $result
+ sleep 1
+ echo_i "... using $1"
+ case $1 in
+ xml) path='xml/v3/zones' ;;
+ json) path='json/v1/zones' ;;
+ *) return 1 ;;
+ esac
+ file=$($PERL fetch.pl -p ${EXTRAPORT1} $path)
+ cp $file $file.$1.$3
+ {
+ $PERL zones-${1}.pl $file $2 2>/dev/null | sort >zones.out.$3
+ result=$?
+ } || true
+ return $result
}
# TODO: Move loadkeys_on to conf.sh.common
loadkeys_on() {
- nsidx=$1
- zone=$2
- nextpart ns${nsidx}/named.run > /dev/null
- $RNDCCMD 10.53.0.${nsidx} loadkeys ${zone} | sed "s/^/ns${nsidx} /" | cat_i
- wait_for_log 20 "next key event" ns${nsidx}/named.run
+ nsidx=$1
+ zone=$2
+ nextpart ns${nsidx}/named.run >/dev/null
+ $RNDCCMD 10.53.0.${nsidx} loadkeys ${zone} | sed "s/^/ns${nsidx} /" | cat_i
+ wait_for_log 20 "next key event" ns${nsidx}/named.run
}
# verify that the http server dropped the connection without replying
check_http_dropped() {
- if [ -x "${NC}" ] ; then
- "${NC}" 10.53.0.3 "${EXTRAPORT1}" > nc.out$n || ret=1
- if test -s nc.out$n; then
- ret=1
- fi
- else
- echo_i "skipping test as nc not found"
+ if [ -x "${NC}" ]; then
+ "${NC}" 10.53.0.3 "${EXTRAPORT1}" >nc.out$n || ret=1
+ if test -s nc.out$n; then
+ ret=1
fi
+ else
+ echo_i "skipping test as nc not found"
+ fi
}
status=0
@@ -133,12 +131,12 @@ n=$((n + 1))
echo_i "Prepare for if-modified-since test ($n)"
ret=0
i=0
-if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ] ; then
- URL="http://10.53.0.3:${EXTRAPORT1}/bind9.xsl"
- ${CURL} --silent --show-error --fail --output bind9.xsl.1 $URL
- ret=$?
+if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ]; then
+ URL="http://10.53.0.3:${EXTRAPORT1}/bind9.xsl"
+ ${CURL} --silent --show-error --fail --output bind9.xsl.1 $URL
+ ret=$?
else
- echo_i "skipping test: requires libxml2 and curl"
+ echo_i "skipping test: requires libxml2 and curl"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -147,38 +145,38 @@ n=$((n + 1))
echo_i "checking consistency between named.stats and xml/json ($n)"
ret=0
rm -f ns2/named.stats
-$DIGCMD +tcp example ns > dig.out.$n || ret=1
+$DIGCMD +tcp example ns >dig.out.$n || ret=1
$RNDCCMD 10.53.0.2 stats 2>&1 | sed 's/^/I:ns1 /'
query_count=$(awk '/QUERY/ {print $1}' ns2/named.stats)
txt_count=$(awk '/TXT/ {print $1}' ns2/named.stats)
noerror_count=$(awk '/NOERROR/ {print $1}' ns2/named.stats)
if [ $PERL_XML ]; then
- file=$($PERL fetch.pl -p ${EXTRAPORT1} xml/v3/server)
- mv $file xml.stats
- $PERL server-xml.pl > xml.fmtstats 2> /dev/null
- xml_query_count=$(awk '/opcode QUERY/ { print $NF }' xml.fmtstats)
- xml_query_count=${xml_query_count:-0}
- [ "$query_count" -eq "$xml_query_count" ] || ret=1
- xml_txt_count=$(awk '/qtype TXT/ { print $NF }' xml.fmtstats)
- xml_txt_count=${xml_txt_count:-0}
- [ "$txt_count" -eq "$xml_txt_count" ] || ret=1
- xml_noerror_count=$(awk '/rcode NOERROR/ { print $NF }' xml.fmtstats)
- xml_noerror_count=${xml_noerror_count:-0}
- [ "$noerror_count" -eq "$xml_noerror_count" ] || ret=1
+ file=$($PERL fetch.pl -p ${EXTRAPORT1} xml/v3/server)
+ mv $file xml.stats
+ $PERL server-xml.pl >xml.fmtstats 2>/dev/null
+ xml_query_count=$(awk '/opcode QUERY/ { print $NF }' xml.fmtstats)
+ xml_query_count=${xml_query_count:-0}
+ [ "$query_count" -eq "$xml_query_count" ] || ret=1
+ xml_txt_count=$(awk '/qtype TXT/ { print $NF }' xml.fmtstats)
+ xml_txt_count=${xml_txt_count:-0}
+ [ "$txt_count" -eq "$xml_txt_count" ] || ret=1
+ xml_noerror_count=$(awk '/rcode NOERROR/ { print $NF }' xml.fmtstats)
+ xml_noerror_count=${xml_noerror_count:-0}
+ [ "$noerror_count" -eq "$xml_noerror_count" ] || ret=1
fi
if [ $PERL_JSON ]; then
- file=$($PERL fetch.pl -p ${EXTRAPORT1} json/v1/server)
- mv $file json.stats
- $PERL server-json.pl > json.fmtstats 2> /dev/null
- json_query_count=$(awk '/opcode QUERY/ { print $NF }' json.fmtstats)
- json_query_count=${json_query_count:-0}
- [ "$query_count" -eq "$json_query_count" ] || ret=1
- json_txt_count=$(awk '/qtype TXT/ { print $NF }' json.fmtstats)
- json_txt_count=${json_txt_count:-0}
- [ "$txt_count" -eq "$json_txt_count" ] || ret=1
- json_noerror_count=$(awk '/rcode NOERROR/ { print $NF }' json.fmtstats)
- json_noerror_count=${json_noerror_count:-0}
- [ "$noerror_count" -eq "$json_noerror_count" ] || ret=1
+ file=$($PERL fetch.pl -p ${EXTRAPORT1} json/v1/server)
+ mv $file json.stats
+ $PERL server-json.pl >json.fmtstats 2>/dev/null
+ json_query_count=$(awk '/opcode QUERY/ { print $NF }' json.fmtstats)
+ json_query_count=${json_query_count:-0}
+ [ "$query_count" -eq "$json_query_count" ] || ret=1
+ json_txt_count=$(awk '/qtype TXT/ { print $NF }' json.fmtstats)
+ json_txt_count=${json_txt_count:-0}
+ [ "$txt_count" -eq "$json_txt_count" ] || ret=1
+ json_noerror_count=$(awk '/rcode NOERROR/ { print $NF }' json.fmtstats)
+ json_noerror_count=${json_noerror_count:-0}
+ [ "$noerror_count" -eq "$json_noerror_count" ] || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -187,19 +185,19 @@ n=$((n + 1))
ret=0
echo_i "checking malloced memory statistics xml/json ($n)"
if [ $PERL_XML ]; then
- file=$($PERL fetch.pl -p ${EXTRAPORT1} xml/v3/mem)
- mv $file xml.mem
- $PERL mem-xml.pl $file > xml.fmtmem
- grep "'Malloced' => '[0-9][0-9]*'" xml.fmtmem > /dev/null || ret=1
- grep "'malloced' => '[0-9][0-9]*'" xml.fmtmem > /dev/null || ret=1
- grep "'maxmalloced' => '[0-9][0-9]*'" xml.fmtmem > /dev/null || ret=1
+ file=$($PERL fetch.pl -p ${EXTRAPORT1} xml/v3/mem)
+ mv $file xml.mem
+ $PERL mem-xml.pl $file >xml.fmtmem
+ grep "'Malloced' => '[0-9][0-9]*'" xml.fmtmem >/dev/null || ret=1
+ grep "'malloced' => '[0-9][0-9]*'" xml.fmtmem >/dev/null || ret=1
+ grep "'maxmalloced' => '[0-9][0-9]*'" xml.fmtmem >/dev/null || ret=1
fi
if [ $PERL_JSON ]; then
- file=$($PERL fetch.pl -p ${EXTRAPORT1} json/v1/mem)
- mv $file json.mem
- grep '"malloced":[0-9][0-9]*,' json.mem > /dev/null || ret=1
- grep '"maxmalloced":[0-9][0-9]*,' json.mem > /dev/null || ret=1
- grep '"Malloced":[0-9][0-9]*,' json.mem > /dev/null || ret=1
+ file=$($PERL fetch.pl -p ${EXTRAPORT1} json/v1/mem)
+ mv $file json.mem
+ grep '"malloced":[0-9][0-9]*,' json.mem >/dev/null || ret=1
+ grep '"maxmalloced":[0-9][0-9]*,' json.mem >/dev/null || ret=1
+ grep '"Malloced":[0-9][0-9]*,' json.mem >/dev/null || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -207,48 +205,46 @@ n=$((n + 1))
echo_i "checking consistency between regular and compressed output ($n)"
ret=0
-if [ -x "${CURL}" ] ; then
- for i in 1 2 3 4 5; do
- ret=0
- if $FEATURETEST --have-libxml2;
- then
- URL="http://10.53.0.2:${EXTRAPORT1}/xml/v3/server"
- filter_str='s#<current-time>.*</current-time>##g'
- else
- URL="http://10.53.0.2:${EXTRAPORT1}/json/v1/server"
- filter_str='s#"current-time.*",##g'
- fi
- "${CURL}" -D regular.headers "$URL" 2>/dev/null | \
- sed -e "$filter_str" > regular.out || ret=1
- "${CURL}" -D compressed.headers --compressed "$URL" 2>/dev/null | \
- sed -e "$filter_str" > compressed.out || ret=1
- diff regular.out compressed.out >/dev/null || ret=1
- if [ $ret != 0 ]; then
- echo_i "failed on try $i, probably a timing issue, trying again"
- sleep 1
- else
- break
- fi
- done
+if [ -x "${CURL}" ]; then
+ for i in 1 2 3 4 5; do
+ ret=0
+ if $FEATURETEST --have-libxml2; then
+ URL="http://10.53.0.2:${EXTRAPORT1}/xml/v3/server"
+ filter_str='s#<current-time>.*</current-time>##g'
+ else
+ URL="http://10.53.0.2:${EXTRAPORT1}/json/v1/server"
+ filter_str='s#"current-time.*",##g'
+ fi
+ "${CURL}" -D regular.headers "$URL" 2>/dev/null \
+ | sed -e "$filter_str" >regular.out || ret=1
+ "${CURL}" -D compressed.headers --compressed "$URL" 2>/dev/null \
+ | sed -e "$filter_str" >compressed.out || ret=1
+ diff regular.out compressed.out >/dev/null || ret=1
+ if [ $ret != 0 ]; then
+ echo_i "failed on try $i, probably a timing issue, trying again"
+ sleep 1
+ else
+ break
+ fi
+ done
else
- echo_i "skipping test as curl not found"
+ echo_i "skipping test as curl not found"
fi
status=$((status + ret))
n=$((n + 1))
ret=0
echo_i "checking if compressed output is really compressed ($n)"
-if $FEATURETEST --with-zlib;
-then
- REGSIZE=$(cat regular.headers | \
- grep -i Content-Length | sed -e "s/.*: \([0-9]*\).*/\1/")
- COMPSIZE=$(cat compressed.headers | \
- grep -i Content-Length | sed -e "s/.*: \([0-9]*\).*/\1/")
- if [ ! $((REGSIZE / COMPSIZE)) -gt 2 ]; then
- ret=1
- fi
+if $FEATURETEST --with-zlib; then
+ REGSIZE=$(cat regular.headers \
+ | grep -i Content-Length | sed -e "s/.*: \([0-9]*\).*/\1/")
+ COMPSIZE=$(cat compressed.headers \
+ | grep -i Content-Length | sed -e "s/.*: \([0-9]*\).*/\1/")
+ if [ ! $((REGSIZE / COMPSIZE)) -gt 2 ]; then
+ ret=1
+ fi
else
- echo_i "skipped"
+ echo_i "skipped"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -266,21 +262,21 @@ ret=0
# The dnssec zone has 10 RRsets to sign (including NSEC) with the ZSK and one
# RRset (DNSKEY) with the KSK. So starting named with signatures that expire
# almost right away, this should trigger 10 zsk and 1 ksk sign operations.
-echo "${refresh_prefix} ${zsk_id}: 10" > zones.expect
-echo "${refresh_prefix} ${ksk_id}: 1" >> zones.expect
-echo "${sign_prefix} ${zsk_id}: 10" >> zones.expect
-echo "${sign_prefix} ${ksk_id}: 1" >> zones.expect
-cat zones.expect | sort > zones.expect.$n
+echo "${refresh_prefix} ${zsk_id}: 10" >zones.expect
+echo "${refresh_prefix} ${ksk_id}: 1" >>zones.expect
+echo "${sign_prefix} ${zsk_id}: 10" >>zones.expect
+echo "${sign_prefix} ${ksk_id}: 1" >>zones.expect
+cat zones.expect | sort >zones.expect.$n
rm -f zones.expect
# Fetch and check the dnssec sign statistics.
echo_i "fetching zone '$zone' stats data after zone maintenance at startup ($n)"
if [ $PERL_XML ]; then
- getzones xml $zone x$n || ret=1
- cmp zones.out.x$n zones.expect.$n || ret=1
+ getzones xml $zone x$n || ret=1
+ cmp zones.out.x$n zones.expect.$n || ret=1
fi
if [ $PERL_JSON ]; then
- getzones json 0 j$n || ret=1
- cmp zones.out.j$n zones.expect.$n || ret=1
+ getzones json 0 j$n || ret=1
+ cmp zones.out.j$n zones.expect.$n || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -289,28 +285,28 @@ n=$((n + 1))
# Test sign operations after dynamic update.
ret=0
(
-# Update dnssec zone to trigger signature creation.
-echo zone $zone
-echo server 10.53.0.2 "$PORT"
-echo update add $zone. 300 in txt "nsupdate added me"
-echo send
+ # Update dnssec zone to trigger signature creation.
+ echo zone $zone
+ echo server 10.53.0.2 "$PORT"
+ echo update add $zone. 300 in txt "nsupdate added me"
+ echo send
) | $NSUPDATE
# This should trigger the resign of SOA, TXT and NSEC (+3 zsk).
-echo "${refresh_prefix} ${zsk_id}: 10" > zones.expect
-echo "${refresh_prefix} ${ksk_id}: 1" >> zones.expect
-echo "${sign_prefix} ${zsk_id}: 13" >> zones.expect
-echo "${sign_prefix} ${ksk_id}: 1" >> zones.expect
-cat zones.expect | sort > zones.expect.$n
+echo "${refresh_prefix} ${zsk_id}: 10" >zones.expect
+echo "${refresh_prefix} ${ksk_id}: 1" >>zones.expect
+echo "${sign_prefix} ${zsk_id}: 13" >>zones.expect
+echo "${sign_prefix} ${ksk_id}: 1" >>zones.expect
+cat zones.expect | sort >zones.expect.$n
rm -f zones.expect
# Fetch and check the dnssec sign statistics.
echo_i "fetching zone '$zone' stats data after dynamic update ($n)"
if [ $PERL_XML ]; then
- getzones xml $zone x$n || ret=1
- cmp zones.out.x$n zones.expect.$n || ret=1
+ getzones xml $zone x$n || ret=1
+ cmp zones.out.x$n zones.expect.$n || ret=1
fi
if [ $PERL_JSON ]; then
- getzones json 0 j$n || ret=1
- cmp zones.out.j$n zones.expect.$n || ret=1
+ getzones json 0 j$n || ret=1
+ cmp zones.out.j$n zones.expect.$n || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -321,23 +317,23 @@ ret=0
echo_i "fetch zone '$zone' stats data after updating DNSKEY RRset ($n)"
# Add a standby DNSKEY, this triggers resigning the DNSKEY RRset.
zsk=$("$KEYGEN" -K ns2 -q -a "$DEFAULT_ALGORITHM" -b "$DEFAULT_BITS" "$zone")
-$SETTIME -K ns2 -P now -A never $zsk.key > /dev/null
+$SETTIME -K ns2 -P now -A never $zsk.key >/dev/null
loadkeys_on 2 $zone || ret=1
# This should trigger the resign of SOA (+1 zsk) and DNSKEY (+1 ksk).
-echo "${refresh_prefix} ${zsk_id}: 11" > zones.expect
-echo "${refresh_prefix} ${ksk_id}: 2" >> zones.expect
-echo "${sign_prefix} ${zsk_id}: 14" >> zones.expect
-echo "${sign_prefix} ${ksk_id}: 2" >> zones.expect
-cat zones.expect | sort > zones.expect.$n
+echo "${refresh_prefix} ${zsk_id}: 11" >zones.expect
+echo "${refresh_prefix} ${ksk_id}: 2" >>zones.expect
+echo "${sign_prefix} ${zsk_id}: 14" >>zones.expect
+echo "${sign_prefix} ${ksk_id}: 2" >>zones.expect
+cat zones.expect | sort >zones.expect.$n
rm -f zones.expect
# Fetch and check the dnssec sign statistics.
if [ $PERL_XML ]; then
- getzones xml $zone x$n || ret=1
- cmp zones.out.x$n zones.expect.$n || ret=1
+ getzones xml $zone x$n || ret=1
+ cmp zones.out.x$n zones.expect.$n || ret=1
fi
if [ $PERL_JSON ]; then
- getzones json 0 j$n || ret=1
- cmp zones.out.j$n zones.expect.$n || ret=1
+ getzones json 0 j$n || ret=1
+ cmp zones.out.j$n zones.expect.$n || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -356,29 +352,29 @@ zsk14_id=$(cat ns2/$zone.zsk14.id)
# RRset (DNSKEY) with the KSKs. So starting named with signatures that expire
# almost right away, this should trigger 10 zsk and 1 ksk sign operations per
# key.
-echo "${refresh_prefix} ${zsk8_id}: 10" > zones.expect
-echo "${refresh_prefix} ${zsk13_id}: 10" >> zones.expect
-echo "${refresh_prefix} ${zsk14_id}: 10" >> zones.expect
-echo "${refresh_prefix} ${ksk8_id}: 1" >> zones.expect
-echo "${refresh_prefix} ${ksk13_id}: 1" >> zones.expect
-echo "${refresh_prefix} ${ksk14_id}: 1" >> zones.expect
-echo "${sign_prefix} ${zsk8_id}: 10" >> zones.expect
-echo "${sign_prefix} ${zsk13_id}: 10" >> zones.expect
-echo "${sign_prefix} ${zsk14_id}: 10" >> zones.expect
-echo "${sign_prefix} ${ksk8_id}: 1" >> zones.expect
-echo "${sign_prefix} ${ksk13_id}: 1" >> zones.expect
-echo "${sign_prefix} ${ksk14_id}: 1" >> zones.expect
-cat zones.expect | sort > zones.expect.$n
+echo "${refresh_prefix} ${zsk8_id}: 10" >zones.expect
+echo "${refresh_prefix} ${zsk13_id}: 10" >>zones.expect
+echo "${refresh_prefix} ${zsk14_id}: 10" >>zones.expect
+echo "${refresh_prefix} ${ksk8_id}: 1" >>zones.expect
+echo "${refresh_prefix} ${ksk13_id}: 1" >>zones.expect
+echo "${refresh_prefix} ${ksk14_id}: 1" >>zones.expect
+echo "${sign_prefix} ${zsk8_id}: 10" >>zones.expect
+echo "${sign_prefix} ${zsk13_id}: 10" >>zones.expect
+echo "${sign_prefix} ${zsk14_id}: 10" >>zones.expect
+echo "${sign_prefix} ${ksk8_id}: 1" >>zones.expect
+echo "${sign_prefix} ${ksk13_id}: 1" >>zones.expect
+echo "${sign_prefix} ${ksk14_id}: 1" >>zones.expect
+cat zones.expect | sort >zones.expect.$n
rm -f zones.expect
# Fetch and check the dnssec sign statistics.
echo_i "fetching zone '$zone' stats data after zone maintenance at startup ($n)"
if [ $PERL_XML ]; then
- getzones xml $zone x$n || ret=1
- cmp zones.out.x$n zones.expect.$n || ret=1
+ getzones xml $zone x$n || ret=1
+ cmp zones.out.x$n zones.expect.$n || ret=1
fi
if [ $PERL_JSON ]; then
- getzones json 2 j$n || ret=1
- cmp zones.out.j$n zones.expect.$n || ret=1
+ getzones json 2 j$n || ret=1
+ cmp zones.out.j$n zones.expect.$n || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -387,36 +383,36 @@ n=$((n + 1))
# Test sign operations after dynamic update (many keys).
ret=0
(
-# Update dnssec zone to trigger signature creation.
-echo zone $zone
-echo server 10.53.0.2 "$PORT"
-echo update add $zone. 300 in txt "nsupdate added me"
-echo send
+ # Update dnssec zone to trigger signature creation.
+ echo zone $zone
+ echo server 10.53.0.2 "$PORT"
+ echo update add $zone. 300 in txt "nsupdate added me"
+ echo send
) | $NSUPDATE
# This should trigger the resign of SOA, TXT and NSEC (+3 zsk).
-echo "${refresh_prefix} ${zsk8_id}: 10" > zones.expect
-echo "${refresh_prefix} ${zsk13_id}: 10" >> zones.expect
-echo "${refresh_prefix} ${zsk14_id}: 10" >> zones.expect
-echo "${refresh_prefix} ${ksk8_id}: 1" >> zones.expect
-echo "${refresh_prefix} ${ksk13_id}: 1" >> zones.expect
-echo "${refresh_prefix} ${ksk14_id}: 1" >> zones.expect
-echo "${sign_prefix} ${zsk8_id}: 13" >> zones.expect
-echo "${sign_prefix} ${zsk13_id}: 13" >> zones.expect
-echo "${sign_prefix} ${zsk14_id}: 13" >> zones.expect
-echo "${sign_prefix} ${ksk8_id}: 1" >> zones.expect
-echo "${sign_prefix} ${ksk13_id}: 1" >> zones.expect
-echo "${sign_prefix} ${ksk14_id}: 1" >> zones.expect
-cat zones.expect | sort > zones.expect.$n
+echo "${refresh_prefix} ${zsk8_id}: 10" >zones.expect
+echo "${refresh_prefix} ${zsk13_id}: 10" >>zones.expect
+echo "${refresh_prefix} ${zsk14_id}: 10" >>zones.expect
+echo "${refresh_prefix} ${ksk8_id}: 1" >>zones.expect
+echo "${refresh_prefix} ${ksk13_id}: 1" >>zones.expect
+echo "${refresh_prefix} ${ksk14_id}: 1" >>zones.expect
+echo "${sign_prefix} ${zsk8_id}: 13" >>zones.expect
+echo "${sign_prefix} ${zsk13_id}: 13" >>zones.expect
+echo "${sign_prefix} ${zsk14_id}: 13" >>zones.expect
+echo "${sign_prefix} ${ksk8_id}: 1" >>zones.expect
+echo "${sign_prefix} ${ksk13_id}: 1" >>zones.expect
+echo "${sign_prefix} ${ksk14_id}: 1" >>zones.expect
+cat zones.expect | sort >zones.expect.$n
rm -f zones.expect
# Fetch and check the dnssec sign statistics.
echo_i "fetching zone '$zone' stats data after dynamic update ($n)"
if [ $PERL_XML ]; then
- getzones xml $zone x$n || ret=1
- cmp zones.out.x$n zones.expect.$n || ret=1
+ getzones xml $zone x$n || ret=1
+ cmp zones.out.x$n zones.expect.$n || ret=1
fi
if [ $PERL_JSON ]; then
- getzones json 2 j$n || ret=1
- cmp zones.out.j$n zones.expect.$n || ret=1
+ getzones json 2 j$n || ret=1
+ cmp zones.out.j$n zones.expect.$n || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -431,21 +427,21 @@ $RNDCCMD 10.53.0.2 reload 2>&1 | sed 's/^/I:ns2 /'
# be cleared and thus no longer visible. But NSEC and SOA are (mistakenly)
# counted double, one time because of zone_resigninc and one time because of
# zone_nsec3chain. So +5 zsk in total.
-echo "${refresh_prefix} ${zsk8_id}: 15" > zones.expect
-echo "${refresh_prefix} ${ksk8_id}: 2" >> zones.expect
-echo "${sign_prefix} ${zsk8_id}: 18" >> zones.expect
-echo "${sign_prefix} ${ksk8_id}: 2" >> zones.expect
-cat zones.expect | sort > zones.expect.$n
+echo "${refresh_prefix} ${zsk8_id}: 15" >zones.expect
+echo "${refresh_prefix} ${ksk8_id}: 2" >>zones.expect
+echo "${sign_prefix} ${zsk8_id}: 18" >>zones.expect
+echo "${sign_prefix} ${ksk8_id}: 2" >>zones.expect
+cat zones.expect | sort >zones.expect.$n
rm -f zones.expect
# Fetch and check the dnssec sign statistics.
echo_i "fetching zone '$zone' stats data after dnssec-policy change ($n)"
if [ $PERL_XML ]; then
- getzones xml $zone x$n || ret=1
- cmp zones.out.x$n zones.expect.$n || ret=1
+ getzones xml $zone x$n || ret=1
+ cmp zones.out.x$n zones.expect.$n || ret=1
fi
if [ $PERL_JSON ]; then
- getzones json 2 j$n || ret=1
- cmp zones.out.j$n zones.expect.$n || ret=1
+ getzones json 2 j$n || ret=1
+ cmp zones.out.j$n zones.expect.$n || ret=1
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -453,8 +449,8 @@ n=$((n + 1))
echo_i "Check HTTP/1.1 client-side pipelined requests are handled (GET) ($n)"
ret=0
-if [ -x "${NC}" ] ; then
- "${NC}" 10.53.0.3 "${EXTRAPORT1}" << EOF > nc.out$n || ret=1
+if [ -x "${NC}" ]; then
+ "${NC}" 10.53.0.3 "${EXTRAPORT1}" <<EOF >nc.out$n || ret=1
GET /xml/v3/status HTTP/1.1
Host: 10.53.0.3:${EXTRAPORT1}
@@ -463,15 +459,15 @@ Host: 10.53.0.3:${EXTRAPORT1}
Connection: close
EOF
- lines=$(grep -c "^<statistics version" nc.out$n)
- test "$lines" = 2 || ret=1
- # keep-alive not needed in HTTP/1.1, second response has close
- lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
- test "$lines" = 0 || ret=1
- lines=$(grep -c "^Connection: close" nc.out$n)
- test "$lines" = 1 || ret=1
+ lines=$(grep -c "^<statistics version" nc.out$n)
+ test "$lines" = 2 || ret=1
+ # keep-alive not needed in HTTP/1.1, second response has close
+ lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
+ test "$lines" = 0 || ret=1
+ lines=$(grep -c "^Connection: close" nc.out$n)
+ test "$lines" = 1 || ret=1
else
- echo_i "skipping test as nc not found"
+ echo_i "skipping test as nc not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -480,7 +476,7 @@ n=$((n + 1))
echo_i "Check HTTP/1.1 client-side pipelined requests are handled (POST) ($n)"
ret=0
if [ -x "${NC}" ]; then
- "${NC}" 10.53.0.3 "${EXTRAPORT1}" << EOF > nc.out$n || ret=1
+ "${NC}" 10.53.0.3 "${EXTRAPORT1}" <<EOF >nc.out$n || ret=1
POST /xml/v3/status HTTP/1.1
Host: 10.53.0.3:${EXTRAPORT1}
Content-Type: application/json
@@ -495,15 +491,15 @@ Connection: close
{}
EOF
- lines=$(grep -c "^<statistics version" nc.out$n)
- test "$lines" = 2 || ret=1
- # keep-alive not needed in HTTP/1.1, second response has close
- lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
- test "$lines" = 0 || ret=1
- lines=$(grep -c "^Connection: close" nc.out$n)
- test "$lines" = 1 || ret=1
+ lines=$(grep -c "^<statistics version" nc.out$n)
+ test "$lines" = 2 || ret=1
+ # keep-alive not needed in HTTP/1.1, second response has close
+ lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
+ test "$lines" = 0 || ret=1
+ lines=$(grep -c "^Connection: close" nc.out$n)
+ test "$lines" = 1 || ret=1
else
- echo_i "skipping test as nc not found"
+ echo_i "skipping test as nc not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -512,23 +508,23 @@ n=$((n + 1))
echo_i "Check HTTP/1.0 keep-alive ($n)"
ret=0
if [ -x "${NC}" ]; then
- "${NC}" 10.53.0.3 "${EXTRAPORT1}" << EOF > nc.out$n || ret=1
+ "${NC}" 10.53.0.3 "${EXTRAPORT1}" <<EOF >nc.out$n || ret=1
GET /xml/v3/status HTTP/1.0
Connection: keep-alive
GET /xml/v3/status HTTP/1.0
EOF
- # should be two responses
- lines=$(grep -c "^<statistics version" nc.out$n)
- test "$lines" = 2 || ret=1
- # first response has keep-alive, second has close
- lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
- test "$lines" = 1 || ret=1
- lines=$(grep -c "^Connection: close" nc.out$n)
- test "$lines" = 1 || ret=1
+ # should be two responses
+ lines=$(grep -c "^<statistics version" nc.out$n)
+ test "$lines" = 2 || ret=1
+ # first response has keep-alive, second has close
+ lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
+ test "$lines" = 1 || ret=1
+ lines=$(grep -c "^Connection: close" nc.out$n)
+ test "$lines" = 1 || ret=1
else
- echo_i "skipping test as nc not found"
+ echo_i "skipping test as nc not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -537,7 +533,7 @@ n=$((n + 1))
echo_i "Check inconsistent Connection: headers ($n)"
ret=0
if [ -x "${NC}" ]; then
- "${NC}" 10.53.0.3 "${EXTRAPORT1}" << EOF > nc.out$n || ret=1
+ "${NC}" 10.53.0.3 "${EXTRAPORT1}" <<EOF >nc.out$n || ret=1
GET /xml/v3/status HTTP/1.0
Connection: keep-alive
Connection: close
@@ -545,46 +541,45 @@ Connection: close
GET /xml/v3/status HTTP/1.0
EOF
- # should be one response (second is ignored)
- lines=$(grep -c "^<statistics version" nc.out$n)
- test "$lines" = 1 || ret=1
- # no keep-alive, one close
- lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
- test "$lines" = 0 || ret=1
- lines=$(grep -c "^Connection: close" nc.out$n)
- test "$lines" = 1 || ret=1
+ # should be one response (second is ignored)
+ lines=$(grep -c "^<statistics version" nc.out$n)
+ test "$lines" = 1 || ret=1
+ # no keep-alive, one close
+ lines=$(grep -c "^Connection: Keep-Alive" nc.out$n || true)
+ test "$lines" = 0 || ret=1
+ lines=$(grep -c "^Connection: close" nc.out$n)
+ test "$lines" = 1 || ret=1
else
- echo_i "skipping test as nc not found"
+ echo_i "skipping test as nc not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
if [ -x "${CURL}" ] && ! ("${CURL}" --next 2>&1 | grep 'option --next: is unknown'); then
- CURL_NEXT="${CURL}"
+ CURL_NEXT="${CURL}"
fi
echo_i "Check HTTP with more than 100 headers ($n)"
ret=0
i=0
-if [ -x "${CURL_NEXT}" ] ; then
- # build input stream.
- : > header.in$n
- while test $i -lt 101
- do
- printf 'X-Bloat%d: VGhlIG1vc3QgY29tbW9uIHJlYXNvbiBmb3IgYmxvYXRpbmcgaXMgaGF2aW5nIGEgbG90IG9mIGdhcyBpbiB5b3VyIGd1dC4gCg==\r\n' $i >> header.in$n
- i=$((i+1))
- done
- printf '\r\n' >> header.in$n
-
- # send the requests then wait for named to close the socket.
- URL="http://10.53.0.3:${EXTRAPORT1}/xml/v3/status"
- "${CURL}" --silent --include --get "$URL" --next --get --header @header.in$n "$URL" > curl.out$n && ret=1
- # we expect 1 request to be processed.
- lines=$(grep -c "^<statistics version" curl.out$n)
- test "$lines" = 1 || ret=1
+if [ -x "${CURL_NEXT}" ]; then
+ # build input stream.
+ : >header.in$n
+ while test $i -lt 101; do
+ printf 'X-Bloat%d: VGhlIG1vc3QgY29tbW9uIHJlYXNvbiBmb3IgYmxvYXRpbmcgaXMgaGF2aW5nIGEgbG90IG9mIGdhcyBpbiB5b3VyIGd1dC4gCg==\r\n' $i >>header.in$n
+ i=$((i + 1))
+ done
+ printf '\r\n' >>header.in$n
+
+ # send the requests then wait for named to close the socket.
+ URL="http://10.53.0.3:${EXTRAPORT1}/xml/v3/status"
+ "${CURL}" --silent --include --get "$URL" --next --get --header @header.in$n "$URL" >curl.out$n && ret=1
+ # we expect 1 request to be processed.
+ lines=$(grep -c "^<statistics version" curl.out$n)
+ test "$lines" = 1 || ret=1
else
- echo_i "skipping test as curl with --next support not found"
+ echo_i "skipping test as curl with --next support not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -593,24 +588,23 @@ n=$((n + 1))
echo_i "Check HTTP/1.1 keep-alive with truncated stream ($n)"
ret=0
i=0
-if [ -x "${CURL_NEXT}" ] ; then
- # build input stream.
- printf 'X-Bloat: ' > header.in$n
- while test $i -lt 5000
- do
- printf '%s' "VGhlIG1vc3QgY29tbW9uIHJlYXNvbiBmb3IgYmxvYXRpbmcgaXMgaGF2aW5nIGEgbG90IG9mIGdhcyBpbiB5b3VyIGd1dC4gCg==" >> header.in$n
- i=$((i+1))
- done
- printf '\r\n' >> header.in$n
-
- # send the requests then wait for named to close the socket.
- URL="http://10.53.0.3:${EXTRAPORT1}/xml/v3/status"
- "${CURL}" --silent --include --get "$URL" --next --get --header @header.in$n "$URL" > curl.out$n && ret=1
- # we expect 1 request to be processed.
- lines=$(grep -c "^<statistics version" curl.out$n)
- test "$lines" = 1 || ret=1
+if [ -x "${CURL_NEXT}" ]; then
+ # build input stream.
+ printf 'X-Bloat: ' >header.in$n
+ while test $i -lt 5000; do
+ printf '%s' "VGhlIG1vc3QgY29tbW9uIHJlYXNvbiBmb3IgYmxvYXRpbmcgaXMgaGF2aW5nIGEgbG90IG9mIGdhcyBpbiB5b3VyIGd1dC4gCg==" >>header.in$n
+ i=$((i + 1))
+ done
+ printf '\r\n' >>header.in$n
+
+ # send the requests then wait for named to close the socket.
+ URL="http://10.53.0.3:${EXTRAPORT1}/xml/v3/status"
+ "${CURL}" --silent --include --get "$URL" --next --get --header @header.in$n "$URL" >curl.out$n && ret=1
+ # we expect 1 request to be processed.
+ lines=$(grep -c "^<statistics version" curl.out$n)
+ test "$lines" = 1 || ret=1
else
- echo_i "skipping test as curl with --next support not found"
+ echo_i "skipping test as curl with --next support not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -619,12 +613,12 @@ n=$((n + 1))
echo_i "Check that consequtive responses do not grow excessively ($n)"
ret=0
i=0
-if [ -x "${CURL}" ] ; then
- URL="http://10.53.0.3:${EXTRAPORT1}/json/v1"
- "${CURL}" --silent --include --header "Accept-Encoding: deflate, gzip, br, zstd" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" > curl.out$n || ret=1
- grep -a Content-Length curl.out$n | awk 'BEGIN { prev=0; } { if (prev != 0 && $2 - prev > 100) { exit(1); } prev = $2; }' || ret=1
+if [ -x "${CURL}" ]; then
+ URL="http://10.53.0.3:${EXTRAPORT1}/json/v1"
+ "${CURL}" --silent --include --header "Accept-Encoding: deflate, gzip, br, zstd" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" "$URL" >curl.out$n || ret=1
+ grep -a Content-Length curl.out$n | awk 'BEGIN { prev=0; } { if (prev != 0 && $2 - prev > 100) { exit(1); } prev = $2; }' || ret=1
else
- echo_i "skipping test as curl not found"
+ echo_i "skipping test as curl not found"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
@@ -632,21 +626,20 @@ n=$((n + 1))
echo_i "Check if-modified-since works ($n)"
ret=0
-if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ] ; then
- URL="http://10.53.0.3:${EXTRAPORT1}/bind9.xsl"
- # ensure over-long time stamps are ignored
- ${CURL} --silent --show-error --fail --output bind9.xsl.2 $URL \
- --header 'If-Modified-Since: 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789'
- if ! [ bind9.xsl.2 -nt bind9.xsl.1 ] ||
- ! ${CURL} --silent --show-error --fail \
- --output bind9.xsl.3 $URL \
- --time-cond bind9.xsl.1 ||
- [ -f bind9.xsl.3 ]
- then
- ret=1
- fi
+if $FEATURETEST --have-libxml2 && [ -x "${CURL}" ]; then
+ URL="http://10.53.0.3:${EXTRAPORT1}/bind9.xsl"
+ # ensure over-long time stamps are ignored
+ ${CURL} --silent --show-error --fail --output bind9.xsl.2 $URL \
+ --header 'If-Modified-Since: 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789'
+ if ! [ bind9.xsl.2 -nt bind9.xsl.1 ] \
+ || ! ${CURL} --silent --show-error --fail \
+ --output bind9.xsl.3 $URL \
+ --time-cond bind9.xsl.1 \
+ || [ -f bind9.xsl.3 ]; then
+ ret=1
+ fi
else
- echo_i "skipping test: requires libxml2 and curl"
+ echo_i "skipping test: requires libxml2 and curl"
fi
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
diff --git a/bin/tests/system/statschannel/tests_json.py b/bin/tests/system/statschannel/tests_json.py
index c459925..4f7c4a7 100755
--- a/bin/tests/system/statschannel/tests_json.py
+++ b/bin/tests/system/statschannel/tests_json.py
@@ -15,9 +15,11 @@ from datetime import datetime
import pytest
-import generic
import pytest_custom_markers
+pytest.register_assert_rewrite("generic")
+import generic
+
pytestmark = pytest_custom_markers.have_json_c
requests = pytest.importorskip("requests")
@@ -98,8 +100,5 @@ def test_zone_with_many_keys_json(statsport):
)
-def test_traffic_json(named_port, statsport):
- generic_dnspython = pytest.importorskip("generic_dnspython")
- generic_dnspython.test_traffic(
- fetch_traffic_json, statsip="10.53.0.2", statsport=statsport, port=named_port
- )
+def test_traffic_json(statsport):
+ generic.test_traffic(fetch_traffic_json, statsip="10.53.0.2", statsport=statsport)
diff --git a/bin/tests/system/statschannel/tests_xml.py b/bin/tests/system/statschannel/tests_xml.py
index 7f0b37e..5329615 100755
--- a/bin/tests/system/statschannel/tests_xml.py
+++ b/bin/tests/system/statschannel/tests_xml.py
@@ -16,9 +16,11 @@ import xml.etree.ElementTree as ET
import pytest
-import generic
import pytest_custom_markers
+pytest.register_assert_rewrite("generic")
+import generic
+
pytestmark = pytest_custom_markers.have_libxml2
requests = pytest.importorskip("requests")
@@ -128,8 +130,5 @@ def test_zone_with_many_keys_xml(statsport):
)
-def test_traffic_xml(named_port, statsport):
- generic_dnspython = pytest.importorskip("generic_dnspython")
- generic_dnspython.test_traffic(
- fetch_traffic_xml, statsip="10.53.0.2", statsport=statsport, port=named_port
- )
+def test_traffic_xml(statsport):
+ generic.test_traffic(fetch_traffic_xml, statsip="10.53.0.2", statsport=statsport)