]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
exercise named-makejournal with multiple transactions
authorEvan Hunt <each@isc.org>
Sat, 15 Feb 2025 02:12:09 +0000 (18:12 -0800)
committerEvan Hunt <each@isc.org>
Sat, 14 Jun 2025 04:20:13 +0000 (21:20 -0700)
the journal system test now checks that named-makejournal is
able to create journal files with multiple transactions.

bin/tests/system/journal/tests.sh
bin/tests/system/journal/tests_sh_journal.py
bin/tests/system/journal/zones/example-hi.db [new file with mode: 0644]
bin/tests/system/journal/zones/example.db [new file with mode: 0644]
bin/tests/system/journal/zones/example2.db [new file with mode: 0644]
bin/tests/system/journal/zones/example3.db [new file with mode: 0644]

index 79b90ba45364845d106e2a2b89570ab7b3bf3563..4f776562fda1b9b824b706a6eb4ef558774d0eda 100644 (file)
@@ -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
index 3f506ef774b778564ddc1a684b5bfc36b844fa42..9d192fd359042f97e4d265189630742412dcdef4 100644 (file)
@@ -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 (file)
index 0000000..f592f6d
--- /dev/null
@@ -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 (file)
index 0000000..2a5d29d
--- /dev/null
@@ -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 (file)
index 0000000..64aad92
--- /dev/null
@@ -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 (file)
index 0000000..5ac2653
--- /dev/null
@@ -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