From bc0461d4aeb78f804352e56779799dfc34242fa5 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Mon, 17 Apr 2023 12:22:49 +0000 Subject: [PATCH] Implement new checks for the xfer system test Check the max-transfer-time-in and max-transfer-idle-in options. (cherry picked from commit 5324f047b22a82f5cf5e25c9672b8fcd21e870ac) --- bin/tests/system/xfer/clean.sh | 1 + .../system/xfer/ns1/axfr-max-idle-time.db | 15 +++++++ .../system/xfer/ns1/axfr-max-transfer-time.db | 15 +++++++ .../ns1/{named.conf.in => named1.conf.in} | 10 +++++ bin/tests/system/xfer/ns1/named2.conf.in | 40 ++++++++++++++++++ bin/tests/system/xfer/ns1/named3.conf.in | 40 ++++++++++++++++++ bin/tests/system/xfer/ns6/named.args | 1 + bin/tests/system/xfer/ns6/named.conf.in | 15 +++++++ bin/tests/system/xfer/setup.sh | 2 +- bin/tests/system/xfer/tests.sh | 41 +++++++++++++++++++ 10 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 bin/tests/system/xfer/ns1/axfr-max-idle-time.db create mode 100644 bin/tests/system/xfer/ns1/axfr-max-transfer-time.db rename bin/tests/system/xfer/ns1/{named.conf.in => named1.conf.in} (88%) create mode 100644 bin/tests/system/xfer/ns1/named2.conf.in create mode 100644 bin/tests/system/xfer/ns1/named3.conf.in create mode 100644 bin/tests/system/xfer/ns6/named.args diff --git a/bin/tests/system/xfer/clean.sh b/bin/tests/system/xfer/clean.sh index bf5016e8f9..effdda8a92 100644 --- a/bin/tests/system/xfer/clean.sh +++ b/bin/tests/system/xfer/clean.sh @@ -38,3 +38,4 @@ rm -f ns6/*.db ns6/*.bk ns6/*.jnl rm -f ns7/*.db ns7/*.bk ns7/*.jnl rm -f ns8/large.db ns8/small.db rm -f stats.* +rm -f wait_for_message.* diff --git a/bin/tests/system/xfer/ns1/axfr-max-idle-time.db b/bin/tests/system/xfer/ns1/axfr-max-idle-time.db new file mode 100644 index 0000000000..252925f8dc --- /dev/null +++ b/bin/tests/system/xfer/ns1/axfr-max-idle-time.db @@ -0,0 +1,15 @@ +; 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. + +$TTL 3600 +@ IN SOA . . 0 0 0 0 0 +@ IN NS . +$GENERATE 1-5000 host$ TXT data-$ diff --git a/bin/tests/system/xfer/ns1/axfr-max-transfer-time.db b/bin/tests/system/xfer/ns1/axfr-max-transfer-time.db new file mode 100644 index 0000000000..252925f8dc --- /dev/null +++ b/bin/tests/system/xfer/ns1/axfr-max-transfer-time.db @@ -0,0 +1,15 @@ +; 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. + +$TTL 3600 +@ IN SOA . . 0 0 0 0 0 +@ IN NS . +$GENERATE 1-5000 host$ TXT data-$ diff --git a/bin/tests/system/xfer/ns1/named.conf.in b/bin/tests/system/xfer/ns1/named1.conf.in similarity index 88% rename from bin/tests/system/xfer/ns1/named.conf.in rename to bin/tests/system/xfer/ns1/named1.conf.in index 1cd72719f8..8673a4027a 100644 --- a/bin/tests/system/xfer/ns1/named.conf.in +++ b/bin/tests/system/xfer/ns1/named1.conf.in @@ -44,6 +44,16 @@ zone "edns-expire" { file "edns-expire.db"; }; +zone "axfr-max-transfer-time" { + type primary; + file "axfr-max-transfer-time.db"; +}; + +zone "axfr-max-idle-time" { + type primary; + file "axfr-max-idle-time.db"; +}; + zone "axfr-too-big" { type primary; file "axfr-too-big.db"; diff --git a/bin/tests/system/xfer/ns1/named2.conf.in b/bin/tests/system/xfer/ns1/named2.conf.in new file mode 100644 index 0000000000..434743d101 --- /dev/null +++ b/bin/tests/system/xfer/ns1/named2.conf.in @@ -0,0 +1,40 @@ +/* + * 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. + */ + +include "../../common/rndc.key"; + +controls { + inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + +options { + query-source address 10.53.0.1; + notify-source 10.53.0.1; + transfer-source 10.53.0.1; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.1; }; + listen-on-v6 { none; }; + recursion no; + notify yes; +}; + +zone "." { + type primary; + file "root.db"; +}; + +zone "axfr-max-transfer-time" { + type primary; + file "axfr-max-transfer-time.db"; +}; diff --git a/bin/tests/system/xfer/ns1/named3.conf.in b/bin/tests/system/xfer/ns1/named3.conf.in new file mode 100644 index 0000000000..4f6344c697 --- /dev/null +++ b/bin/tests/system/xfer/ns1/named3.conf.in @@ -0,0 +1,40 @@ +/* + * 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. + */ + +include "../../common/rndc.key"; + +controls { + inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; +}; + +options { + query-source address 10.53.0.1; + notify-source 10.53.0.1; + transfer-source 10.53.0.1; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.1; }; + listen-on-v6 { none; }; + recursion no; + notify yes; +}; + +zone "." { + type primary; + file "root.db"; +}; + +zone "axfr-max-idle-time" { + type primary; + file "axfr-max-idle-time.db"; +}; diff --git a/bin/tests/system/xfer/ns6/named.args b/bin/tests/system/xfer/ns6/named.args new file mode 100644 index 0000000000..2be062bbdd --- /dev/null +++ b/bin/tests/system/xfer/ns6/named.args @@ -0,0 +1 @@ +-D xfer-ns6 -X named.lock -m record -c named.conf -d 99 -g -U 4 -T maxcachesize=2097152 -T transferinsecs diff --git a/bin/tests/system/xfer/ns6/named.conf.in b/bin/tests/system/xfer/ns6/named.conf.in index 636400cfce..d5b8710896 100644 --- a/bin/tests/system/xfer/ns6/named.conf.in +++ b/bin/tests/system/xfer/ns6/named.conf.in @@ -29,6 +29,7 @@ options { notify yes; ixfr-from-differences primary; check-integrity no; + tcp-idle-timeout 600; }; zone "." { @@ -54,6 +55,20 @@ zone "edns-expire" { file "edns-expire.bk"; }; +zone "axfr-max-transfer-time" { + type secondary; + max-transfer-time-in 1; # this is tested as seconds, when used with '-T transferinsecs' + primaries { 10.53.0.1; }; + file "axfr-max-transfer-time.bk"; +}; + +zone "axfr-max-idle-time" { + type secondary; + max-transfer-idle-in 50; # this is tested as seconds, when used with '-T transferinsecs' + primaries { 10.53.0.1; }; + file "axfr-max-idle-time.bk"; +}; + zone "axfr-too-big" { type secondary; max-records 30; diff --git a/bin/tests/system/xfer/setup.sh b/bin/tests/system/xfer/setup.sh index 092d798799..ff64d8fbdd 100644 --- a/bin/tests/system/xfer/setup.sh +++ b/bin/tests/system/xfer/setup.sh @@ -23,7 +23,7 @@ $SHELL ${TOP_SRCDIR}/bin/tests/system/genzone.sh 7 >ns7/primary2.db cp -f ns4/root.db.in ns4/root.db $PERL -e 'for ($i=0;$i<10000;$i++){ printf("x%u 0 in a 10.53.0.1\n", $i);}' >> ns4/root.db -copy_setports ns1/named.conf.in ns1/named.conf +copy_setports ns1/named1.conf.in ns1/named.conf copy_setports ns2/named.conf.in ns2/named.conf copy_setports ns3/named.conf.in ns3/named.conf copy_setports ns6/named.conf.in ns6/named.conf diff --git a/bin/tests/system/xfer/tests.sh b/bin/tests/system/xfer/tests.sh index 11096d08b9..ecdfc49c1f 100755 --- a/bin/tests/system/xfer/tests.sh +++ b/bin/tests/system/xfer/tests.sh @@ -15,6 +15,7 @@ DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd -p ${PORT}" RNDCCMD="$RNDC -c ../common/rndc.conf -p ${CONTROLPORT} -s" +NS_PARAMS="-X named.lock -m record -c named.conf -d 99 -g -U 4 -T maxcachesize=2097152" status=0 n=0 @@ -580,5 +581,45 @@ grep "10.53.0.3#${EXTRAPORT1} (primary): query 'primary/SOA/IN' approved" ns6/na if test $tmp != 0 ; then echo_i "failed"; fi status=$((status+tmp)) +wait_for_message() ( + nextpartpeek ns6/named.run > wait_for_message.$n + grep -F "$1" wait_for_message.$n >/dev/null +) + +nextpart ns6/named.run > /dev/null + +n=$((n+1)) +echo_i "test max-transfer-time-in with 1 second timeout ($n)" +stop_server ns1 +copy_setports ns1/named2.conf.in ns1/named.conf +start_server --noclean --restart --port ${PORT} ns1 -- "-D xfer-ns1 $NS_PARAMS -T transferinsecs -T transferslowly" +sleep 1 +$RNDCCMD 10.53.0.6 retransfer axfr-max-transfer-time 2>&1 | sed 's/^/ns6 /' | cat_i +tmp=0 +retry_quiet 10 wait_for_message "maximum transfer time exceeded: timed out" || tmp=1 +status=$((status+tmp)) + +nextpart ns6/named.run > /dev/null + +n=$((n+1)) +echo_i "test max-transfer-idle-in with 50 seconds timeout ($n)" +stop_server ns1 +copy_setports ns1/named3.conf.in ns1/named.conf +start_server --noclean --restart --port ${PORT} ns1 -- "-D xfer-ns1 $NS_PARAMS -T transferinsecs -T transferstuck" +sleep 1 +start=`date +%s` +$RNDCCMD 10.53.0.6 retransfer axfr-max-idle-time 2>&1 | sed 's/^/ns6 /' | cat_i +tmp=0 +retry_quiet 60 wait_for_message "maximum idle time exceeded: timed out" || tmp=1 +if [ $tmp -eq 0 ]; then + now=`date +%s` + diff=$((now - start)) + # we expect a timeout in 50 seconds + test $diff -lt 50 && tmp=1 + test $diff -ge 59 && tmp=1 + if test $tmp != 0 ; then echo_i "unexpected diff value: ${diff}"; fi +fi +status=$((status+tmp)) + echo_i "exit status: $status" [ $status -eq 0 ] || exit 1