From: Evan Hunt Date: Sat, 15 Feb 2025 02:12:09 +0000 (-0800) Subject: exercise named-makejournal with multiple transactions X-Git-Tag: v9.21.10~51^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27a34fdac147c0adf25fc51fdf9e979593c76268;p=thirdparty%2Fbind9.git exercise named-makejournal with multiple transactions the journal system test now checks that named-makejournal is able to create journal files with multiple transactions. --- diff --git a/bin/tests/system/journal/tests.sh b/bin/tests/system/journal/tests.sh index 79b90ba4536..4f776562fda 100644 --- a/bin/tests/system/journal/tests.sh +++ b/bin/tests/system/journal/tests.sh @@ -250,6 +250,46 @@ echo_i "check that journal is applied to zone with keydata placeholder record" ret=0 grep 'managed-keys-zone: journal rollforward completed successfully: up to date' ns2/named.run >/dev/null 2>&1 || ret=1 [ $ret -eq 0 ] || echo_i "failed" +status=$((status + ret)) + +n=$((n + 1)) +echo_i "check named-makejournal with multiple transactions ($n)" +ret=0 +# fail if there's no delta to journal +$MAKEJOURNAL example zones/example.db zones/example.db >makejournal.out.test$n 2>&1 && ret=1 +grep -q "Error: SOA serial (1) unchanged between files" makejournal.out.test$n || ret=1 +# add first delta to journal +$MAKEJOURNAL example zones/example.db zones/example2.db >/dev/null 2>&1 || ret=1 +# warn if the new transaction doesn't update the serial +$MAKEJOURNAL example zones/example.db zones/example2.db >makejournal.out.test$n 2>&1 || ret=1 +grep -q "Journal zones/example.db.jnl already has serial 2" makejournal.out.test$n || ret=1 +# now add a second delta and count the transactions +$MAKEJOURNAL example zones/example.db zones/example3.db >/dev/null 2>&1 || ret=1 +$JOURNALPRINT zones/example.db.jnl >journalprint.out.test$n +soas=$(awk '$5 == "SOA" {print}' journalprint.out.test$n | wc -l) +[ "$soas" -eq 4 ] || ret=1 +[ $ret -eq 0 ] || echo_i "failed" +status=$((status + ret)) + +n=$((n + 1)) +echo_i "check named-makejournal with bad serial numbers ($n)" +ret=0 +# fail if the serial number goes backwards +rm -f zones/example.db.jnl zones/example3.db.jnl +$MAKEJOURNAL example zones/example3.db zones/example.db >makejournal.out.test$n 2>&1 && ret=1 +grep -q "malformed transaction: serial number did not increase" makejournal.out.test$n || ret=1 +# fail if the old serial number is missing from the journal +$MAKEJOURNAL example zones/example.db zones/example3.db >makejournal.out.test$n 2>&1 || ret=1 +# rename the 1->3 journal so it will be used for 2->3. +mv zones/example.db.jnl zones/example2.db.jnl +$MAKEJOURNAL example zones/example2.db zones/example3.db >makejournal.out.test$n 2>&1 && ret=1 +grep -q "journal zones/example2.db.jnl out of sync with zone" makejournal.out.test$n || ret=1 +# increase serial number by exactly 0x80000000 +rm -f zones/example3.db.jnl +$MAKEJOURNAL example zones/example3.db zones/example-hi.db >makejournal.out.test$n 2>&1 && ret=1 +grep -q "malformed transaction: serial number did not increase" makejournal.out.test$n || ret=1 +[ $ret -eq 0 ] || echo_i "failed" +status=$((status + ret)) echo_i "exit status: $status" [ $status -eq 0 ] || exit 1 diff --git a/bin/tests/system/journal/tests_sh_journal.py b/bin/tests/system/journal/tests_sh_journal.py index 3f506ef774b..9d192fd3590 100644 --- a/bin/tests/system/journal/tests_sh_journal.py +++ b/bin/tests/system/journal/tests_sh_journal.py @@ -15,11 +15,13 @@ pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", "journalprint.out.*", + "makejournal.out.*", "tmp.jnl", "ns*/*.db", "ns*/*.jnl", "ns1/managed-keys.bind", "ns2/managed-keys.bind", + "zones/*.jnl", ] ) diff --git a/bin/tests/system/journal/zones/example-hi.db b/bin/tests/system/journal/zones/example-hi.db new file mode 100644 index 00000000000..f592f6d0fd7 --- /dev/null +++ b/bin/tests/system/journal/zones/example-hi.db @@ -0,0 +1,23 @@ +; 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. +$ORIGIN example. +$TTL 300 ; 5 minutes +@ IN SOA ns1.example. hostmaster.example. ( + 2147483651 ; serial + 2000 ; refresh (33 minutes 20 seconds) + 2000 ; retry (33 minutes 20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) + NS ns1.example. +ns1 A 10.53.0.1 +b A 192.0.1.2 +c A 192.0.1.3 diff --git a/bin/tests/system/journal/zones/example.db b/bin/tests/system/journal/zones/example.db new file mode 100644 index 00000000000..2a5d29d2a2f --- /dev/null +++ b/bin/tests/system/journal/zones/example.db @@ -0,0 +1,23 @@ +; 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. +$ORIGIN example. +$TTL 300 ; 5 minutes +@ IN SOA ns1.example. hostmaster.example. ( + 1 ; serial + 2000 ; refresh (33 minutes 20 seconds) + 2000 ; retry (33 minutes 20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) + NS ns1.example. +ns1 A 10.53.0.1 +a A 192.0.1.1 +b A 192.0.1.2 diff --git a/bin/tests/system/journal/zones/example2.db b/bin/tests/system/journal/zones/example2.db new file mode 100644 index 00000000000..64aad92b366 --- /dev/null +++ b/bin/tests/system/journal/zones/example2.db @@ -0,0 +1,24 @@ +; 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. +$ORIGIN example. +$TTL 300 ; 5 minutes +@ IN SOA ns1.example. hostmaster.example. ( + 2 ; serial + 2000 ; refresh (33 minutes 20 seconds) + 2000 ; retry (33 minutes 20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) + NS ns1.example. +ns1 A 10.53.0.1 +a A 192.0.1.1 +b A 192.0.1.2 +c A 192.0.1.3 diff --git a/bin/tests/system/journal/zones/example3.db b/bin/tests/system/journal/zones/example3.db new file mode 100644 index 00000000000..5ac2653094a --- /dev/null +++ b/bin/tests/system/journal/zones/example3.db @@ -0,0 +1,23 @@ +; 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. +$ORIGIN example. +$TTL 300 ; 5 minutes +@ IN SOA ns1.example. hostmaster.example. ( + 3 ; serial + 2000 ; refresh (33 minutes 20 seconds) + 2000 ; retry (33 minutes 20 seconds) + 1814400 ; expire (3 weeks) + 3600 ; minimum (1 hour) + ) + NS ns1.example. +ns1 A 10.53.0.1 +b A 192.0.1.2 +c A 192.0.1.3