Commit graph

6509 commits

Author SHA1 Message Date
Colin Vidal
5bfae10fa5 add startup root DNSKEY refresh system test
Root trust anchors are automatically updated as described in RFC5011.
Add a system test which ensures the root DNSKEYs are always queried by
named during startup.

Because this test uses real internet DNS root servers, it is enabled
only when `CI_ENABLE_LIVE_INTERNET_TESTS` is set.

(cherry picked from commit b0a33f77dc)
2025-06-30 12:52:12 +00:00
Nicki Křížek
c0ca8854c5 Log assertion failures right after test result
The extra messages are typically traceback from assertion failures.
Previously, they'd be printed only after all individual test case
results have been printed. That made it difficult to pair the traceback
to the failing test in some cases, as the node information (aka test
name) might not always be present.

Instead, log any extra messages related to a particular test failure
directly after reporting its result, making the failure details more
readily available and easy to connect with a particular test case.

(cherry picked from commit fcf31417dd)
2025-06-27 20:30:21 +02:00
Nicki Křížek
88549e8849 Log command stdout when using isctest.run.cmd()
The command's stdout may provide useful debug info, so make sure we log
it by default. It doesn't seem to have a significant impact on the log
size.

(cherry picked from commit 9f3f6ec38e)
2025-06-27 20:30:21 +02:00
Nicki Křížek
9549c8885a Log query and response when using isctest.query.*
Make sure the queries and responses are logged at the DEBUG level, which
may provide useful information in case of failing tests.

This doesn't seem to significantly increase the overall artifacts size.
Previously, pytest.log.txt files from all system tests would take around
3 MB, with this change, it's around 8 MB).

(cherry picked from commit 56fec9ba04)
2025-06-27 20:30:21 +02:00
Nicki Křížek
7aa00bcddc Use proper logging in SPNEGO tests
Avoid using print() and use proper logging facility instead.

(cherry picked from commit 51ac5bdd14)
2025-06-27 20:30:21 +02:00
Nicki Křížek
03af371948 Add options for query&response logging to pytest
In some cases, it's useful to log the sent and received DNS messages.
Add options to enable this on demand. Query is only logged the first
time it's sent, since it doesn't change. If response logging is turned
on, then each response is logged, since it might be different every
time.

(cherry picked from commit 1e87b5ffc6)
2025-06-27 20:30:21 +02:00
Nicki Křížek
a6599a0822 Indent multiline output in pytest logging
When multiline message is logged, indent all but the first line (which
will be preceeded by the LOG_FORMAT). This improves the clarity of logs,
as it's immediately clear which lines are regular log output, and which
ones are multiline debug output.

Adjust the isctest.run.cmd() stdout/stderr logging to this new format.

(cherry picked from commit 23e6b49cc5)
2025-06-27 20:30:21 +02:00
Nicki Křížek
129dd186fc Don't log empty test result messages
The messages obtained from test results may contain stuff like detailed
failure/error information, tracebacks etc. In many cases, the message
will be empty, in which case it doesn't need to be logged.

For an example, run test with many test cases, e.g.
verify/test_verify.py, and inspect the tail of the pytest.log.txt before
and after this commit.

(cherry picked from commit 0a6b0cf68c)
2025-06-27 20:30:21 +02:00
Nicki Křížek
2b77921470 Replace print statements in checkds test
Use isctest.log logging facility for consistent and predictable logging
output rather than using print(). Remove writes of stderr, as that
output will be logged in the debug log in case the commands called with
isctest.run.cmd() fails.

(cherry picked from commit 4b8998e4ad)
2025-06-27 20:30:21 +02:00
Štěpán Balážik
96e8e72dbe Move root zone mirror system test to a separate directory
This test doesn't require artifact checking but when bundled in the same
directory with the shell based tests, the `system:clang:tsan` job was
failing non-deterministically.

(cherry picked from commit d5874d5df9)
2025-06-27 17:28:27 +02:00
Štěpán Balážik
97caa0addc Add a system test that ensures root zone mirroring works out of the box
This is a test for #5380.

(cherry picked from commit a69efc678c)
2025-06-27 12:10:40 +00:00
Štěpán Balážik
e2a91c06c8 Add a pytest mark for system tests that require Internet connection
We skip those by default as:

a) we don't want to stress the upstream servers in every CI pipeline
b) system tests need to be runnable in a isolated environment by default

(cherry picked from commit 3a8ffc74df)
2025-06-27 12:10:40 +00:00
Štěpán Balážik
02cf400dc9 Rename CI_ENABLE_ALL_TESTS to CI_ENABLE_LONG_TESTS
New name is more descriptive and allows us to created more optional
test sets.

(cherry picked from commit c7a8f61055)
2025-06-27 12:10:39 +00:00
Štěpán Balážik
d8e6609aaa Use :global-test-result: when converting trs file to JUnit XML
There might be more than one :test-result: and they are collated into
the :global-test-result: field.

This only happens when system tests are run with `make check`.
2025-06-26 17:05:20 +02:00
Petr Menšík
a741244bc4 Do not expect fail in cpu test default configuration
Previous CPU test relied on either missing default named.conf or the
missing permissions to write into its default directory. In short that
default configuration would be unusable with current user. It would hang
indefinitely at cpu test if the named user could write into directory
specified in default configuration.

Change it instead to explicitly try non-existent configuration file.
It will still fail immediately, but will not rely on running user or
presence of file at default configuration file path.

(cherry picked from commit 8e789ea62f)
2025-06-25 11:36:35 +00:00
Mark Andrews
53738b0e5e Use clang-format-20 to update formatting
(cherry picked from commit 422b9118e8)
2025-06-25 13:32:08 +10:00
Nicki Křížek
da7cab2243 Make extra_artifacts check optional
There is an ongoing debate about the usefulness of the extra artifacts
check. While it might be useful to detect unexpected behaviour in some
tests, it feels extraneous in many cases. This change provides a middle
ground by making the artifact checking optional. This might be
especially useful for writing new tests, since the author gets to decide
whether the check is useful -- and can utilize it, or can skip it for
sake of brevity.

(cherry picked from commit c06dc71cd5)
2025-06-24 14:57:59 +00:00
Mark Andrews
9bc7a73e50 verify-axfr.db gets updated too fast in mirror test
Add a 1 second wait before updating verify-axfr.db so that the
modification time of the file changes.

(cherry picked from commit c19956b3cb)
2025-06-19 16:27:45 +00:00
Nicki Křížek
e19e108698 Ignore softhsm2 errors when deleting token in keyfromlabel test
In some rare cases, the softhsm2 utility reports failure to delete the
token directory, despite the token being found. Subsequent attempts to
delete the token again indicate that the token was deleted.

Ignore this cleanup error, as it doesn't prevent our tests from working
properly. There is also an attempt to delete the token before the test
starts which ensures a clean state before the test is executed, in case
there's actually a leftover token.

(cherry picked from commit e786a2e950)
2025-06-19 13:52:16 +00:00
Nicki Křížek
455766e643 Use time.monotonic() for time measumeremts in pytest
For duration measurements, i.e. deadlines and timeouts, it's more
suitable to use monotonic time as it's guaranteed to only go forward,
unlike time.time() which can be affected by local clock settings.

(cherry picked from commit 069e4ef0f7)
2025-06-19 13:06:39 +00:00
Nicki Křížek
3e927e43d7 Move param to isctest.util
(cherry picked from commit 481b46ffcc)
2025-06-19 13:06:39 +00:00
Nicki Křížek
ab9b2c947f Improve logging from isctest.run.retry_with_timeout
Allow use of exception (and by extension, assert statements) in the
called function in order to extract essential debug information about
the type of failure that was encountered.

In case the called function fails to succeed on the last retry and
raised an exception, log it as error and set it as the assert message to
propagate it through the pytest framework.

(cherry picked from commit 620c884133)
2025-06-19 13:06:39 +00:00
Matthijs Mekking
61b2b4074e Test purge-keys with views
Create a test scenario where a signed zone is in multiple views and
then a key may be purged. This is a bug case where the key files are
removed by one view and then the other view starts complaining.

(cherry picked from commit 752d8617f5)
2025-06-19 11:42:03 +02:00
Matthijs Mekking
546fdb9c20 Remove kasp shell script remainders
Now that all tests have been converted, we can remove 'kasp/tests.sh'
and 'kasp/tests_sh_kasp.py'.

(cherry picked from commit 6994a604a7)
2025-06-18 14:47:17 +02:00
Matthijs Mekking
383605c902 Convert algorithm rollover tests to pytest
Roll the algorithm rollover test cases over to the rollover directory
and rewrite using pytest.

(cherry picked from commit 80992c7b96)
2025-06-18 14:47:07 +02:00
Matthijs Mekking
ffccf1fe8b Convert going insecure kasp test to pytest
When going insecure, we publish CDS and CDNSKEY DELETE records. Update
the check_apex function to test this.

Also, skip some tests in the 'check_rollover_step()' function. If
we change the DNSSEC Policy, keys that no longer match the policy will
be retired. When this exactly happens is hard to determine, as it
happens on the reconfigure. So for these tests, we skip the key timing
metadata checks.

Also, the zone becomes unsigned, so don't call 'check_zone_is_signed'
in those cases.

(cherry picked from commit b1d8217d1a)
2025-06-18 12:20:45 +00:00
Matthijs Mekking
62adf9957f Convert policy changes tests to pytest
These test cases involve a reconfiguration. The first one is a zone
that changes from dynamic to inline-signing. The others are tests that
key lifetimes are updated correctly after changing them.

(cherry picked from commit de3c0970eb)
2025-06-18 12:20:45 +00:00
Mark Andrews
3bb5c3c52b unstable rollover/tests_rollover.py::test_rollover_manual
The state files need to be written before trying to identify zsk/ksk
keys.  Wait for "keymgr: manual-rollover.kasp done" to appear in
named.run first.

(cherry picked from commit 80fedf7fcf)
2025-06-17 07:56:12 +00:00
Mark Andrews
de665b6570 Add tests for 'dig +coflag'
(cherry picked from commit c56af212f0)
2025-06-13 20:31:34 +10:00
Mark Andrews
9ad190c7f2 nsec3-ent.kasp.db is updated too fast for rndc reload
ensure a second has elasped before updating the zone file
by adding 'sleep 1' to test.sh

(cherry picked from commit 52c29e3ab2)
2025-06-13 08:11:23 +00:00
Mark Andrews
1ede0fc9d7 changing.db is updated too fast
ensure a second has elasped before updating the zone file
by adding 'time.sleep(1)' to xferquota/tests_xferquota.py

(cherry picked from commit d8d14cb780)
2025-06-13 07:11:05 +00:00
Evan Hunt
ea9f4749ed add tests for 'delv +ns -4' and '-6'
check that `delv +ns` sends iterative queries over both address
families when -4 and -6 are not used, and suppresses queries
appropriately when they are.

(cherry picked from commit d29f1d1710)
2025-06-12 21:03:25 -07:00
Evan Hunt
7395b717b1 Prevent .hypothesis artifacts in system test directories
The "run.sh" script, used by "make test", changes the working
directory to the system test directory before executing pytest.
If the test drops hypothesis artifacts while running, this
can cause spurious test failures due to an apparent mismatch
between the contents of the system test directory and the
temporary pytest directory. This has been addressed by having
"run.sh" call pytest from the parent directory instead.

(cherry picked from commit c08e78ef73)
2025-06-03 07:38:41 +00:00
Mark Andrews
75032a7cbb Add various multi-line inputs to named-rrchecker
(cherry picked from commit 5f882f95fe)
2025-06-03 02:27:46 +00:00
Michal Nowak
5419a563d8 Use "digit" class instead of character range in rndc_dumpdb()
The tr range did not work on Solaris 11.4. Let's use a class that is
defined in POSIX.

(cherry picked from commit baa5ccd795)
2025-06-02 11:04:02 +00:00
Nicki Křížek
a2591c8b38 Add dynamic update facility to NamedInstance
Deduplicate the code for dynamic updates and increase code clarity by
using an actual dns.update.UpdateMessage rather than an undefined
intermediary format passed around as a list of arguments.

(cherry picked from commit c00121b4c2)
2025-06-02 09:22:07 +00:00
Matthijs Mekking
5a5944a9ce Convert csk rollover test cases to pytest
Move the 'csk-roll1' and 'csk-roll2' zones to the rollover test dir and
convert CSK rollover tests to pytest.

The DS swap spans multiple steps. Only the first time we should check
if the "CDS is now published" log is there, and only the first time we
should run 'rndc dnssec -checkds' on the keys. Add a new key to the
step dictionary to disable the DS swap checks.

This made me realize that we need to check for "is not None" in case
the value in the dictionary is False. Update check_rollover_step()
accordingly, and also add a log message which step/zone we are currently
checking.

(cherry picked from commit fd290f391f)
2025-06-02 09:22:07 +00:00
Matthijs Mekking
4602ffae7c Convert the 'three is a crowd' test case to pytest
This test shows similarities with the Double KSK rollover method, so
put the test in there.

(cherry picked from commit 46800e407e)
2025-06-02 09:22:07 +00:00
Matthijs Mekking
fd9f966d5a Convert ksk rollover test case to pytest
Move the 'ksk-doubleksk' zones to the rollover test dir and convert KSK
rollover test to pytest.

Since the 'ksk-doubleksk' policy publishes different CDNSKEY/CDS RRsets,
update the 'check_rollover_step' to check which CDNSKEY/CDS RRsets should
be published and which should be prohibited. Update 'isctest.kasp'
accordingly.

We are changing the ZSK lifetime to unlimited in this test case as it
is of no importance (this actually discovered a bug in setting the
next time the keymgr should run).

(cherry picked from commit 9ff7609614)
2025-06-02 09:22:07 +00:00
Matthijs Mekking
239a37946b Convert zsk rollover test case to pytest
Move the 'zsk-prepub' zones to the rollover test dir and convert ZSK
rollover test to pytest.

We need a way to signal a smooth rollover is going on. Signatures are
being replaced gradually during a ZSK rollover, so the existing
signatures of the predecessor ZSK are still being used. Add a smooth
operator to set the right expectations on what signatures are being
used.

Setting expected key relationships is a bit crude: a list of two
elements where the first element is the index of the expected keys that
is the predecessor, and the second element is the index of the expected
keys that is the successor.

We are changing the KSK lifetime to unlimited in this test case as it
is of no importance.

(cherry picked from commit bd6c70bd67)
2025-06-02 09:22:07 +00:00
Matthijs Mekking
ee4199f22a Convert enable dnssec test case to pytest
Move the 'enable-dnssec' to the rollover test dir and convert to pytest.

This requires new test functionality to check that "CDS is published"
messages are logged (or prohibited).

The setup part is slightly adapted such that it no longer needs to
set the '-P sync' value in most cases (this is then set by 'named'),
and to adjust for the inappropriate safety intervals fix.

(cherry picked from commit 233fdb8d52)
2025-06-02 09:22:07 +00:00
Matthijs Mekking
fc0533b9f5 Convert kasp multi-signer tests to pytest
Move the multi-signer test scenarios to the rollover directory and
convert tests to pytest.

- If the KeyProperties set the "legacy" to True, don't set expected
  key times, nor check them. Also, when a matching key is found, set
  key.external to True.
- External keys don't show up in the 'rndc dnssec -status' output so
  skip them in the 'check_dnssecstatus' function. External keys never
  sign RRsets, so also skip those keys in the '_check_signatures'
  function.
- Key properties strings now can set expected key tag ranges, and if
  KeyProperties have tag ranges set, they are checked.

(cherry picked from commit 8ee02190a5)
2025-06-02 09:22:07 +00:00
Matthijs Mekking
ba71be8ed1 Move rollover test cases to separate test dir
In order to keep the kasp system test somewhat approachable, let's
move all rollover scenarios to its own test directory. Starting with
the manual rollover test cases.

A new test function is added to 'isctest.kasp', to verify that the
relationship metadata (Predecessor, Successor) is set correctly.

The configuration and setup for the zone 'manual-rollover.kasp' are
almost copied verbatim, the only exception is the keytimes. Similar
to the test kasp cases, we no longer set "SyncPublish/PublishCDS" in
the setup script. In addition to that, the offset is changed from one
day ago to one week ago, so that the key states match the timing
metadata (one day is too short to move a key from "hidden" to
"omnipresent").

(cherry picked from commit 4d08ec50d1)
2025-06-02 09:22:07 +00:00
Michał Kępień
db8b22433b
Use isctest.asyncserver in the "chain" test
Replace the custom DNS servers used in the "chain" system test with
new code based on the isctest.asyncserver module.

For ans3, replace the sequence of logical conditions present in Perl
code with zone files and a limited amount of custom logic applied on top
of them where necessary.

For ans4, replace the ctl_channel() and create_response() functions with
a custom control command handler coupled with a dynamically instantiated
response handler, making the code more robust and readable.

Migrate sendcmd() and its uses to the new way of sending control queries
to custom servers used in system tests.

(cherry picked from commit c3d3c9955d)
2025-05-30 20:43:33 +02:00
Michał Kępień
f93d783ec6
Improve readability of sendcmd() calls
To improve readability of sendcmd() calls used for controlling
isctest.asyncserver-based custom DNS servers, pass the command's name
and arguments as separate parameters.

(cherry picked from commit 9a230c16ff)
2025-05-30 20:43:33 +02:00
Michał Kępień
f39864d3ec Force manual DNAME handling to be acknowledged
Adding proper DNAME support to AsyncDnsServer would add complexity to
its code for little gain: DNAME use in custom system test servers is
limited to crafting responses that attempt to trigger bugs in named.

This fact will not be obvious to AsyncDnsServer users as it
automatically loads all zone files it finds and handles CNAME records
like a normal authoritative DNS server would.

Therefore, to prevent surprises:

  - raise an exception whenever DNAME records are found in any of the
    zone files loaded by AsyncDnsServer,

  - add a new optional argument to the AsyncDnsServer constructor that
    enables suppressing this new behavior, enabling zones with DNAME
    records to be loaded anyway.

This enables response handlers to use the DNAME records present in zone
files in arbitrary ways without complicating the "base" code.

(cherry picked from commit 8a562526f6)
2025-05-30 16:19:05 +00:00
Michał Kępień
8acd4c685c Drop unused AsyncDnsServer constructor argument
The constructor for the AsyncDnsServer class takes a 'load_zones'
argument that is not used anywhere and is not expected to be useful in
the future: zone files are not required for an AsyncDnsServer instance
to start and, if necessary, zone-based answers can be suppressed or
modified by installing a custom response handler.

(cherry picked from commit 5110278008)
2025-05-30 16:19:04 +00:00
Michał Kępień
e3f75d1a44 Properly handle CNAMEs when preparing responses
dnspython does not treat CNAME records in zone files in any special way;
they are just RRsets belonging to zone nodes.  Process CNAMEs when
preparing zone-based responses just like a normal authoritative DNS
server would.

(cherry picked from commit 1b8ceec580)
2025-05-30 16:19:04 +00:00
Michał Kępień
717f334daf Add debug logs for outgoing DNS messages
Since AsyncDnsServer logs incoming DNS messages as seen on the wire, do
the same for the responses sent by the server.

(cherry picked from commit 2a9c74546d)
2025-05-30 16:19:04 +00:00
Matthijs Mekking
d2a6af1906 Fix intermittent kasp pytest failures
The pytest cases checks if a zone is signed by looking at the NSEC
record at the apex. If that has an RRSIG record, it is considered
signed. But 'named' signs zones incrementally (in batches) and so
the zone may still lack some signatures. In other words, the tests
may consider a zone signed while in fact signing is not yet complete,
then performs additional checks such as is a subdomain signed with the
right key. If this check happens before the zone is actually fully
signed, the check will fail.

Fix this by using 'check_dnssec_verify' instead of
'check_is_zone_signed'. We were already doing this check, but we now
move it up. This will transfer the zone and then run 'dnssec-verify'
on the response. If the zone is partially signed, the check will fail,
and it will retry for up to ten times.

(cherry picked from commit 7a31fd57e2)
2025-05-29 12:35:22 +00:00