From f86f314d7e51981ebcce5f0fb65c97b611851a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Thu, 28 Jun 2018 13:38:39 +0200 Subject: [PATCH] Add a system test for mirror zones Create the basic files comprising a system test and define a few helper functions which will be useful when testing mirror zones. --- bin/tests/system/Makefile.in | 2 +- bin/tests/system/conf.sh.in | 2 +- bin/tests/system/conf.sh.win32 | 2 +- bin/tests/system/mirror/clean.sh | 12 +++++ bin/tests/system/mirror/ns1/named.conf.in | 21 +++++++++ bin/tests/system/mirror/ns1/root.db.in | 13 ++++++ bin/tests/system/mirror/ns2/named.conf.in | 21 +++++++++ bin/tests/system/mirror/ns3/named.conf.in | 26 +++++++++++ bin/tests/system/mirror/setup.sh | 19 ++++++++ bin/tests/system/mirror/tests.sh | 55 +++++++++++++++++++++++ util/copyrights | 7 +++ 11 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 bin/tests/system/mirror/clean.sh create mode 100644 bin/tests/system/mirror/ns1/named.conf.in create mode 100644 bin/tests/system/mirror/ns1/root.db.in create mode 100644 bin/tests/system/mirror/ns2/named.conf.in create mode 100644 bin/tests/system/mirror/ns3/named.conf.in create mode 100644 bin/tests/system/mirror/setup.sh create mode 100644 bin/tests/system/mirror/tests.sh diff --git a/bin/tests/system/Makefile.in b/bin/tests/system/Makefile.in index c17fac83d2..94d88c57ec 100644 --- a/bin/tests/system/Makefile.in +++ b/bin/tests/system/Makefile.in @@ -62,7 +62,7 @@ PARALLEL = rpzrecurse serve-stale dnssec \ fetchlimit filter-aaaa formerr forward \ geoip glue idna inline integrity ixfr keepalive \ legacy limits logfileconfig \ - masterfile masterformat metadata mkeys \ + masterfile masterformat metadata mirror mkeys \ names notify nslookup nsupdate nzd2nzf \ padding pending pipelined qmin \ reclimit redirect resolver rndc rootkeysentinel rpz \ diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index ada6f04a5c..d3837db9a3 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -93,7 +93,7 @@ PARALLELDIRS="acl additional addzone allow-query auth autosign \ fetchlimit filter-aaaa formerr forward \ geoip glue idna inline integrity ixfr keepalive \ legacy limits logfileconfig \ - masterfile masterformat metadata mkeys \ + masterfile masterformat metadata mirror mkeys \ names notify nslookup nsupdate nzd2nzf \ padding pending pipelined qmin \ reclimit redirect resolver rndc rootkeysentinel rpz rpzrecurse \ diff --git a/bin/tests/system/conf.sh.win32 b/bin/tests/system/conf.sh.win32 index 0c3ef19f09..6b5c8639b7 100644 --- a/bin/tests/system/conf.sh.win32 +++ b/bin/tests/system/conf.sh.win32 @@ -90,7 +90,7 @@ SEQUENTIALDIRS="acl additional addzone autosign builtin \ ednscompliance emptyzones \ fetchlimit filter-aaaa formerr forward geoip glue idna inline ixfr \ keepalive @KEYMGR@ legacy limits logfileconfig masterfile \ - masterformat metadata mkeys names notify nslookup nsupdate \ + masterformat metadata mirror mkeys names notify nslookup nsupdate \ nzd2nzf padding pending pipelined @PKCS11_TEST@ qmin \ reclimit redirect resolver rndc rpz rrchecker rrl \ rrsetorder rsabigexponent runtime sfcache smartsign sortlist \ diff --git a/bin/tests/system/mirror/clean.sh b/bin/tests/system/mirror/clean.sh new file mode 100644 index 0000000000..983f1ac273 --- /dev/null +++ b/bin/tests/system/mirror/clean.sh @@ -0,0 +1,12 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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 http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +rm -f */*.conf +rm -f */named.memstats +rm -f */named.run diff --git a/bin/tests/system/mirror/ns1/named.conf.in b/bin/tests/system/mirror/ns1/named.conf.in new file mode 100644 index 0000000000..b967b9e6d7 --- /dev/null +++ b/bin/tests/system/mirror/ns1/named.conf.in @@ -0,0 +1,21 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +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; +}; diff --git a/bin/tests/system/mirror/ns1/root.db.in b/bin/tests/system/mirror/ns1/root.db.in new file mode 100644 index 0000000000..3c5e60fd98 --- /dev/null +++ b/bin/tests/system/mirror/ns1/root.db.in @@ -0,0 +1,13 @@ +; Copyright (C) Internet Systems Consortium, Inc. ("ISC") +; +; 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 http://mozilla.org/MPL/2.0/. +; +; See the COPYRIGHT file distributed with this work for additional +; information regarding copyright ownership. + +$TTL 3600 +@ SOA a.root-servers.nil. hostmaster 2000010100 3600 1200 604800 3600 +@ NS a.root-servers.nil. +a.root-servers.nil. A 10.53.0.1 diff --git a/bin/tests/system/mirror/ns2/named.conf.in b/bin/tests/system/mirror/ns2/named.conf.in new file mode 100644 index 0000000000..f8208e82a7 --- /dev/null +++ b/bin/tests/system/mirror/ns2/named.conf.in @@ -0,0 +1,21 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + query-source address 10.53.0.2; + notify-source 10.53.0.2; + transfer-source 10.53.0.2; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.2; }; + listen-on-v6 { none; }; + recursion no; +}; diff --git a/bin/tests/system/mirror/ns3/named.conf.in b/bin/tests/system/mirror/ns3/named.conf.in new file mode 100644 index 0000000000..4d6b2ad5c5 --- /dev/null +++ b/bin/tests/system/mirror/ns3/named.conf.in @@ -0,0 +1,26 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + query-source address 10.53.0.3; + notify-source 10.53.0.3; + transfer-source 10.53.0.3; + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.3; }; + listen-on-v6 { none; }; + recursion yes; +}; + +zone "." { + type hint; + file "../../common/root.hint"; +}; diff --git a/bin/tests/system/mirror/setup.sh b/bin/tests/system/mirror/setup.sh new file mode 100644 index 0000000000..5093722efe --- /dev/null +++ b/bin/tests/system/mirror/setup.sh @@ -0,0 +1,19 @@ +#!/bin/sh -e +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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 http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +$SHELL clean.sh + +copy_setports ns1/named.conf.in ns1/named.conf +copy_setports ns2/named.conf.in ns2/named.conf +copy_setports ns3/named.conf.in ns3/named.conf diff --git a/bin/tests/system/mirror/tests.sh b/bin/tests/system/mirror/tests.sh new file mode 100644 index 0000000000..fdc0eda190 --- /dev/null +++ b/bin/tests/system/mirror/tests.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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 http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s" + +# Wait until the transfer of the given zone to ns3 either completes successfully +# or is aborted by a verification failure. +wait_for_transfer() { + zone=$1 + for i in 1 2 3 4 5 6 7 8 9 10; do + nextpartpeek ns3/named.run | egrep "'$zone/IN'.*Transfer status: (success|verify failure)" > /dev/null && return + sleep 1 + done + echo_i "exceeded time limit waiting for proof of '$zone' being transferred to appear in ns3/named.run" + ret=1 +} + +# Wait until loading the given zone on the given server either completes +# successfully for the specified serial number or fails. +wait_for_load() { + zone=$1 + serial=$2 + log=$3 + for i in 1 2 3 4 5 6 7 8 9 10; do + nextpartpeek $log | egrep "$zone.*(loaded serial $serial|unable to load)" > /dev/null && return + sleep 1 + done + echo_i "exceeded time limit waiting for proof of '$zone' being loaded to appear in $log" + ret=1 +} + +# Trigger a reload of ns2 and wait until loading the given zone completes. +reload_zone() { + zone=$1 + serial=$2 + $RNDCCMD 10.53.0.2 reload > /dev/null 2>&1 + wait_for_load $zone $serial ns2/named.run +} + +status=0 +n=0 + +echo_i "exit status: $status" +[ $status -eq 0 ] || exit 1 diff --git a/util/copyrights b/util/copyrights index 02f0c2a521..b87da463e4 100644 --- a/util/copyrights +++ b/util/copyrights @@ -1595,6 +1595,13 @@ ./bin/tests/system/metadata/prereq.sh SH 2009,2012,2014,2016,2018 ./bin/tests/system/metadata/setup.sh SH 2009,2011,2012,2014,2016,2017,2018 ./bin/tests/system/metadata/tests.sh SH 2009,2011,2012,2013,2014,2016,2017,2018 +./bin/tests/system/mirror/clean.sh SH 2018 +./bin/tests/system/mirror/ns1/named.conf.in CONF-C 2018 +./bin/tests/system/mirror/ns1/root.db.in ZONE 2018 +./bin/tests/system/mirror/ns2/named.conf.in CONF-C 2018 +./bin/tests/system/mirror/ns3/named.conf.in CONF-C 2018 +./bin/tests/system/mirror/setup.sh SH 2018 +./bin/tests/system/mirror/tests.sh SH 2018 ./bin/tests/system/mkeys/README TXT.BRIEF 2015,2016,2017,2018 ./bin/tests/system/mkeys/clean.sh SH 2015,2016,2017,2018 ./bin/tests/system/mkeys/ns1/named1.conf.in CONF-C 2015,2016,2017,2018