]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
3 years agoMerge branch 'mnowak/alpine-3.18' into 'main'
Michal Nowak [Wed, 31 May 2023 10:02:52 +0000 (10:02 +0000)] 
Merge branch 'mnowak/alpine-3.18' into 'main'

Add Alpine Linux 3.18

See merge request isc-projects/bind9!7985

3 years agoAdd Alpine Linux 3.18
Michal Nowak [Mon, 29 May 2023 13:48:56 +0000 (15:48 +0200)] 
Add Alpine Linux 3.18

3 years agoMerge branch 'aram/statschannel-spilled-clients-counter' into 'main'
Arаm Sаrgsyаn [Wed, 31 May 2023 09:52:29 +0000 (09:52 +0000)] 
Merge branch 'aram/statschannel-spilled-clients-counter' into 'main'

Add ClientQuota statistics channel counter

See merge request isc-projects/bind9!7978

3 years agoAdd a CHANGES note for [GL !7978]
Aram Sargsyan [Mon, 29 May 2023 18:01:31 +0000 (18:01 +0000)] 
Add a CHANGES note for [GL !7978]

3 years agoUpdate the documentation of the resolver statistics counters
Aram Sargsyan [Mon, 29 May 2023 15:20:02 +0000 (15:20 +0000)] 
Update the documentation of the resolver statistics counters

The reference manual doesn't document all the available resolver
statistics counters. Add information about the missing counters.

3 years agoAdd ClientQuota statistics channel counter
Aram Sargsyan [Mon, 29 May 2023 15:19:49 +0000 (15:19 +0000)] 
Add ClientQuota statistics channel counter

This counter indicates the number of the resolver's spilled
queries due to reaching the clients per query quota.

3 years agoMerge branch '4012-remove-win2k-hacks' into 'main'
Evan Hunt [Wed, 31 May 2023 08:29:20 +0000 (08:29 +0000)] 
Merge branch '4012-remove-win2k-hacks' into 'main'

remove win2k gss-tsig hacks

Closes #4012

See merge request isc-projects/bind9!7843

3 years agoCHANGES and release notes for [GL #4012]
Evan Hunt [Fri, 14 Apr 2023 20:03:27 +0000 (13:03 -0700)] 
CHANGES and release notes for [GL #4012]

3 years agoremove win2k gss-tsig hacks
Evan Hunt [Fri, 14 Apr 2023 19:56:24 +0000 (12:56 -0700)] 
remove win2k gss-tsig hacks

Remove the code implementing nonstardard behaviors that were formerly
needed to allow GSS-TSIG to work with Windows 2000, which passed
End-of-Life in 2010.

Deprecate the "oldgsstsig" command and "-o" command line option
to nsupdate; these are now treated as synonyms for "gsstsig" and "-g"
respectively.

3 years agoMerge branch 'mnowak/custom-userspace-rcu-library' into 'main'
Michal Nowak [Tue, 30 May 2023 18:27:12 +0000 (18:27 +0000)] 
Merge branch 'mnowak/custom-userspace-rcu-library' into 'main'

Drop liburcu-related TSAN suppressions

See merge request isc-projects/bind9!7971

3 years agoChange images for TSAN jobs
Michal Nowak [Fri, 26 May 2023 08:50:58 +0000 (10:50 +0200)] 
Change images for TSAN jobs

Fedora 38 and Debian "bullseye" images were "forked" to images used only
for TSAN CI jobs. The new images contain TSAN-aware liburcu that does
not fit well with ASAN CI jobs for which original images were also used.

Also, drop liburcu-related TSAN suppressions because they are
unnecessary with TSAN-aware liburcu.

3 years agoMerge branch 'mnowak/look-for-core-files-in-TOP_BUILDDIR' into 'main'
Michal Nowak [Tue, 30 May 2023 17:54:48 +0000 (17:54 +0000)] 
Merge branch 'mnowak/look-for-core-files-in-TOP_BUILDDIR' into 'main'

Look for core files in $TOP_BUILDDIR

See merge request isc-projects/bind9!7869

3 years agoLook for core files in $TOP_BUILDDIR
Michal Nowak [Wed, 26 Apr 2023 09:21:28 +0000 (11:21 +0200)] 
Look for core files in $TOP_BUILDDIR

The get_core_dumps.sh script couldn't find and process core files of
out-of-tree configurations because it looked for them in the source
instead of the build directory.

3 years agoMerge branch 'tkrizek-fix-pytest-base-port' into 'main'
Tom Krizek [Tue, 30 May 2023 13:36:42 +0000 (13:36 +0000)] 
Merge branch 'tkrizek-fix-pytest-base-port' into 'main'

Fix base_port calculation in pytest runner

See merge request isc-projects/bind9!7981

3 years agoFix base_port calculation in pytest runner
Tom Krizek [Tue, 30 May 2023 12:11:14 +0000 (14:11 +0200)] 
Fix base_port calculation in pytest runner

The selected base port should be in the range <port_min, port_max), the
formula was incorrect.

Credit for discovering this fault goes to Ondrej Sury.

3 years agoMerge branch '3950-serve-stale-strikes-again' into 'main'
Matthijs Mekking [Tue, 30 May 2023 11:02:13 +0000 (11:02 +0000)] 
Merge branch '3950-serve-stale-strikes-again' into 'main'

Fix serve-stale bug when cache has no data

Closes #3950

See merge request isc-projects/bind9!7856

3 years agoAdd release note and changes for #3950
Matthijs Mekking [Mon, 1 May 2023 13:04:42 +0000 (15:04 +0200)] 
Add release note and changes for #3950

Fixing another serve-stale bug is still news.

3 years agoExtend serve-stale logging
Matthijs Mekking [Mon, 1 May 2023 12:43:59 +0000 (14:43 +0200)] 
Extend serve-stale logging

Print the database lookup result in serve-stale logs for debugging
potential future serve-stale issues.

3 years agoFix serve-stale bug when cache has no data
Matthijs Mekking [Thu, 20 Apr 2023 14:22:53 +0000 (16:22 +0200)] 
Fix serve-stale bug when cache has no data

We recently fixed a bug where in some cases (when following an
expired CNAME for example), named could return SERVFAIL if the target
record is still valid (see isc-projects/bind9#3678, and
isc-projects/bind9!7096). We fixed this by considering non-stale
RRsets as well during the stale lookup.

However, this triggered a new bug because despite the answer from
cache not being stale, the lookup may be triggered by serve-stale.
If the answer from database is not stale, the fix in
isc-projects/bind9!7096 erroneously skips the serve-stale logic.

Add 'answer_found' checks to the serve-stale logic to fix this issue.

3 years agoAdd serve-stale test case for GL #3950
Matthijs Mekking [Mon, 1 May 2023 12:46:29 +0000 (14:46 +0200)] 
Add serve-stale test case for GL #3950

Add a test case where when priming the cache with a slow authoritative
resolver, the stale-answer-client-timeout option should not return
a delegation to the client (it should wait until an applicable answer
is found, if no entry is found in the cache).

3 years agoMerge branch '3905-placeholder' into 'main'
Ondřej Surý [Mon, 29 May 2023 06:02:51 +0000 (06:02 +0000)] 
Merge branch '3905-placeholder' into 'main'

Add CHANGES placeholder for [GL #3905]

Closes #3905

See merge request isc-projects/bind9!7976

3 years agoAdd CHANGES placeholder for [GL #3905]
Ondřej Surý [Mon, 29 May 2023 06:00:16 +0000 (08:00 +0200)] 
Add CHANGES placeholder for [GL #3905]

3 years agoMerge branch '4098-remove-cruft-epoll-kqueue-configure-options' into 'main'
Ondřej Surý [Mon, 29 May 2023 05:57:03 +0000 (05:57 +0000)] 
Merge branch '4098-remove-cruft-epoll-kqueue-configure-options' into 'main'

Remove obsolete epoll/kqueue/devpoll configure options

Closes #4098

See merge request isc-projects/bind9!7973

3 years agoAdd CHANGES note for [GL #4098]
Ondřej Surý [Sat, 27 May 2023 06:51:47 +0000 (08:51 +0200)] 
Add CHANGES note for [GL #4098]

3 years agoRemove obsolete epoll/kqueue/devpoll configure options
Ondřej Surý [Sat, 27 May 2023 06:47:55 +0000 (08:47 +0200)] 
Remove obsolete epoll/kqueue/devpoll configure options

Since we don't use networking directly but rather via libuv, these
configure options were no-op.  Remove the configure checks for epoll
(Linux), kqueue (BSDs) and /dev/poll (Solaris).

3 years agoMerge branch '4090-corrected-bad-insist-logic-in-isc_radix_remove' into 'main'
Mark Andrews [Mon, 29 May 2023 02:22:18 +0000 (02:22 +0000)] 
Merge branch '4090-corrected-bad-insist-logic-in-isc_radix_remove' into 'main'

Resolve "Corrected bad INSIST logic in isc_radix_remove()"

Closes #4090

See merge request isc-projects/bind9!7966

3 years agoAdd regression test for [GL # 4090]
Mark Andrews [Fri, 26 May 2023 01:09:33 +0000 (11:09 +1000)] 
Add regression test for [GL # 4090]

These insertions are added to produce a radix tree that will trigger
the INSIST reported in [GL #4090].  Due to fixes added since BIND 9.9
an extra insert in needed to ensure node->parent is non NULL.

3 years agoMove isc_mem_put to after node is checked for equality
Mark Andrews [Fri, 26 May 2023 00:28:39 +0000 (10:28 +1000)] 
Move isc_mem_put to after node is checked for equality

isc_mem_put NULL's the pointer to the memory being freed.  The
equality test 'parent->r == node' was accidentally being turned
into a test against NULL.

3 years agoMerge branch '4085-httpd-shutdown-issue' into 'main'
Evan Hunt [Sat, 27 May 2023 04:12:09 +0000 (04:12 +0000)] 
Merge branch '4085-httpd-shutdown-issue' into 'main'

don't set SHUTTINGDOWN until after calling the request callbacks

Closes #4085

See merge request isc-projects/bind9!7961

3 years agodon't set SHUTTINGDOWN until after calling the request callbacks
Evan Hunt [Tue, 23 May 2023 21:33:28 +0000 (14:33 -0700)] 
don't set SHUTTINGDOWN until after calling the request callbacks

if we set ISC_HTTPDMGR_SHUTTINGDOWN in the http manager before
calling the pending request callbacks, it can trigger an assertion.

3 years agoMerge branch '4091-syncrhonise-access-to-the-client-tlsctx-cache' into 'main'
Artem Boldariev [Fri, 26 May 2023 12:07:43 +0000 (12:07 +0000)] 
Merge branch '4091-syncrhonise-access-to-the-client-tlsctx-cache' into 'main'

ZMGR: TLS contexts cache - properly synchronise access

Closes #4091

See merge request isc-projects/bind9!7967

3 years agoZMGR: TLS contexts cache - properly synchronise access
Artem Boldariev [Fri, 26 May 2023 08:06:59 +0000 (11:06 +0300)] 
ZMGR: TLS contexts cache - properly synchronise access

This commit ensures that access to the TLS context cache within zone
manager is properly synchronised.

Previously there was a possibility for it to get unexpectedly
NULLified for a brief moment by a call to
dns_zonemgr_set_tlsctx_cache() from one thread, while being accessed
from another (e.g. from got_transfer_quota()). This behaviour could
lead to server abort()ing on configuration reload (under very rare
circumstances).

That behaviour has been fixed.

3 years agoMerge branch '4082-rrl-would-limit-log-line' into 'main'
Tom Krizek [Fri, 26 May 2023 10:26:41 +0000 (10:26 +0000)] 
Merge branch '4082-rrl-would-limit-log-line' into 'main'

Disable rrl check in slow environments

Closes #4082

See merge request isc-projects/bind9!7963

3 years agoDisable rrl check in slow environments
Tom Krizek [Wed, 24 May 2023 11:58:01 +0000 (13:58 +0200)] 
Disable rrl check in slow environments

The check for 'would limit' log message is triggered by sending at least
three messages within one second. However, in extremely slow conditions
(currently when running with clang+TSAN in CI), the individual queries
might take too much time to send enough of them within one second.

Since this is a pretty rare condition, let's just silently skip this
test in environments where a single query takes more than 500 ms, since
there's no way to perform the check under such conditions.

Closes #4082

3 years agoMerge branch 'mnowak/gitlab-runner-autoscaling' into 'main'
Michal Nowak [Fri, 26 May 2023 09:45:53 +0000 (09:45 +0000)] 
Merge branch 'mnowak/gitlab-runner-autoscaling' into 'main'

Run most Docker CI jobs in AWS with autoscaler

See merge request isc-projects/bind9!7960

3 years agoRun most Docker CI jobs in AWS with autoscaler
Michal Nowak [Wed, 17 May 2023 12:33:12 +0000 (14:33 +0200)] 
Run most Docker CI jobs in AWS with autoscaler

All but the "respdiff-long" job, for which our AWS instances do not have
enough memory, are now being spawned in the AWS by the autoscaler
executor.

3 years agoMerge branch '4072-tcp-dispatch-timeout' into 'main'
Evan Hunt [Fri, 26 May 2023 08:49:52 +0000 (08:49 +0000)] 
Merge branch '4072-tcp-dispatch-timeout' into 'main'

fix handling of TCP timeouts

Closes #4072

See merge request isc-projects/bind9!7937

3 years agofix handling of TCP timeouts
Evan Hunt [Tue, 16 May 2023 22:35:00 +0000 (15:35 -0700)] 
fix handling of TCP timeouts

when a TCP dispatch times out, we call tcp_recv() with a result
value of ISC_R_TIMEDOUT; this cancels the oldest dispatch
entry in the dispatch's active queue, plus any additional entries
that have waited longer than their configured timeouts. if, at
that point, there were more dispatch entries still on the active
queue, it resumes reading, but until now it failed to restart
the timer.

this has been corrected: we now calculate a new timeout
based on the oldest dispatch entry still remaining.  this
requires us to initialize the start time of each dispatch entry
when it's first added to the queue.

in order to ensure that the handling of timed-out requests is
consistent, we now calculate the runtime of each dispatch
entry based on the same value for 'now'.

incidentally also fixed a compile error that turned up when
DNS_DISPATCH_TRACE was turned on.

3 years agoMerge branch '4079-multiple-keyrings' into 'main'
Evan Hunt [Thu, 25 May 2023 22:01:33 +0000 (22:01 +0000)] 
Merge branch '4079-multiple-keyrings' into 'main'

prevent TSIG keys from being added to multiple rings

Closes #4079

See merge request isc-projects/bind9!7955

3 years agoCHANGES for [GL #4079]
Evan Hunt [Sun, 21 May 2023 20:44:26 +0000 (13:44 -0700)] 
CHANGES for [GL #4079]

3 years agoprevent TSIG keys from being added to multiple rings
Evan Hunt [Sun, 21 May 2023 19:59:38 +0000 (12:59 -0700)] 
prevent TSIG keys from being added to multiple rings

it was possible to add a TSIG key to more than one TSIG
keyring at a time, and this was in fact happening with the
session key, which was generated once and then added to the
keyrings for each view as it was configured.

this has been corrected and a REQUIRE added to dns_tsigkeyring_add()
to prevent it from happening again.

3 years agoMerge branch '3765-interfacemgr-use-after-afree-on-shutdown' into 'main'
Arаm Sаrgsyаn [Thu, 25 May 2023 08:29:01 +0000 (08:29 +0000)] 
Merge branch '3765-interfacemgr-use-after-afree-on-shutdown' into 'main'

Fix an interfacemgr use-after-free error in zoneconf.c:isself()

Closes #3765

See merge request isc-projects/bind9!7962

3 years agoAdd a CHANGES note for [GL #3765]
Aram Sargsyan [Wed, 24 May 2023 14:38:53 +0000 (14:38 +0000)] 
Add a CHANGES note for [GL #3765]

3 years agoFix an interfacemgr use-after-free error in zoneconf.c:isself()
Aram Sargsyan [Wed, 24 May 2023 14:26:04 +0000 (14:26 +0000)] 
Fix an interfacemgr use-after-free error in zoneconf.c:isself()

The 'named_g_server->interfacemgr' pointer is saved in the zone
structure using dns_zone_setisself(), as a void* argument to be
passed to the isself() callback, so there is no attach/detach,
and when shutting down, the interface manager can be destroyed
by the shutdown_server(), running in exclusive mode, and causing
isself() to crash when trying to use the pointer.

Instead of keeping the interface manager pointer in the zone
structure, just check and use the 'named_g_server->interfacemgr'
itself, as it was implemented originally in the
3aca8e5bf3740bbcc3bb13dde242d7cc369abb27 commit. Later, in the
8eb88aafee951859264e36c315b1289cd8c2088b commit, the code was
changed to pass the interface manager pointer using the additional
void* argument, but the commit message doesn't mention if there
was any practical reason for that.

Additionally, don't pass the interfacemgr pointer to the
ns_interfacemgr_getaclenv() function before it is checked
against NULL.

3 years agoMerge branch 'tkrizek/ci-clang-tsan-allow-failure' into 'main'
Tom Krizek [Wed, 24 May 2023 08:38:46 +0000 (08:38 +0000)] 
Merge branch 'tkrizek/ci-clang-tsan-allow-failure' into 'main'

Allow the system:clang:tsan job to fail in CI

See merge request isc-projects/bind9!7958

3 years agoAllow the system:clang:tsan job to fail in CI
Tom Krizek [Tue, 23 May 2023 13:28:22 +0000 (15:28 +0200)] 
Allow the system:clang:tsan job to fail in CI

There are couple of known failures currently affecting this test:
- rrl (GL #4082)
- upforwd (GL #4072)

3 years agoMerge branch '2710-fix-inline-signing-multisigner-bugs-matthijs' into 'main'
Matthijs Mekking [Tue, 23 May 2023 12:05:46 +0000 (12:05 +0000)] 
Merge branch '2710-fix-inline-signing-multisigner-bugs-matthijs' into 'main'

Make multisigner server capabilities work with inline-signing

Closes #2710

See merge request isc-projects/bind9!6901

3 years agoFix dnssec system test
Matthijs Mekking [Mon, 6 Mar 2023 15:48:17 +0000 (16:48 +0100)] 
Fix dnssec system test

The 'update-nsec3.example' requires to be DNSSEC maintained via
dynamic update. Commit 03b22983cd20cec51ad8b9f25f2e7d0e472dc79c adds
checks to make sure the raw zone is not signed. So the test case neesd
to be updated to allow for DNSSEC maintenance.

3 years agoAdd new dns_rdatatype_iskeymaterial() function
Matthijs Mekking [Wed, 15 Mar 2023 10:51:33 +0000 (11:51 +0100)] 
Add new dns_rdatatype_iskeymaterial() function

The following code block repeats quite often:

    if (rdata.type == dns_rdatatype_dnskey ||
        rdata.type == dns_rdatatype_cdnskey ||
        rdata.type == dns_rdatatype_cds)

Introduce a new function to reduce the repetition.

3 years agoMake make_dnskey() a public funcion
Matthijs Mekking [Fri, 3 Mar 2023 13:15:59 +0000 (14:15 +0100)] 
Make make_dnskey() a public funcion

It can be used to compare DNSKEY, CDNSKEY, and CDS records with
signing keys.

3 years agoAdd more multisigner tests, removing records
Matthijs Mekking [Fri, 3 Mar 2023 10:51:55 +0000 (11:51 +0100)] 
Add more multisigner tests, removing records

A zone in multisigner model 2 should also be possible to remove
previously added DNSKEY, CDS and CDNSKEY records from the zone operated
by the other provider.

3 years agoAdd bump in the wire multisigner test
Matthijs Mekking [Fri, 3 Mar 2023 10:46:48 +0000 (11:46 +0100)] 
Add bump in the wire multisigner test

Add a test case where updates are being made against a hidden primary
and two bump in the wire signers (the providers in the multisigner
model) serve the zone.

The test covers the same cases as for two primary providers that is:
- Add DNSKEY
- Remove (previously added) DNSKEY
- Add CDNSKEY
- Remove (previously added) CDNSKEY
- Add CDS
- Remove (previously added) CDS

3 years agoDon't sign the raw zone
Mark Andrews [Wed, 12 Oct 2022 06:01:57 +0000 (17:01 +1100)] 
Don't sign the raw zone

The raw zone is not supposed to be signed.  DNSKEY records in a raw zone
should not trigger zone signing.  The update code needs to be able to
identify when it is working on a raw zone.  Add dns_zone_israw() and
dns_zone_issecure() enable it to do this. Also, we need to check the
case for 'auto-dnssec maintain'.

3 years agoEnsure no DNSSEC records are in the raw journal
Matthijs Mekking [Thu, 13 Oct 2022 07:09:12 +0000 (09:09 +0200)] 
Ensure no DNSSEC records are in the raw journal

Add checks to the multisigner test to make sure no DNSSEC related
records (NSEC, NSEC3, NSEC3PARAM, RRSIG) end up in the raw journal.

3 years agoAdd notes and change entry
Matthijs Mekking [Wed, 5 Oct 2022 14:32:35 +0000 (16:32 +0200)] 
Add notes and change entry

3 years agoAdd more multisigner tests
Matthijs Mekking [Wed, 5 Oct 2022 15:11:50 +0000 (17:11 +0200)] 
Add more multisigner tests

A zone in multisigner model 2 should also be possible to publish the
CDS and CDNSKEY records from their KSK into the zone operated by the
other provider.

3 years agoFix dns_zone_getkasp() function
Matthijs Mekking [Wed, 5 Oct 2022 14:22:37 +0000 (16:22 +0200)] 
Fix dns_zone_getkasp() function

For inline-signing zones, sometimes kasp was not detected because
the function was called on the raw (unsigned) version of the zone,
but the kasp is only set on the secure (signed) version of the zone.

Fix the dns_zone_getkasp() function to check whether the zone
structure is inline_raw(), and if so, use the kasp from the
secure version.

In zone.c we can access the kasp pointer directly.

3 years agoAllow DNSKEY when syncing secure journal/db
Matthijs Mekking [Wed, 5 Oct 2022 11:36:42 +0000 (13:36 +0200)] 
Allow DNSKEY when syncing secure journal/db

When synchronizing the journal or database from the unsigned version of
the zone to the secure version of the zone, allow DNSKEY records to be
synced, because these may be added by the user with the sole intent to
publish the record (not used for signing). This may be the case for
example in the multisigner model 2 (RFC 8901).

Additional code needs to be added to ensure that we do not remove DNSKEY
records that are under our control. Keys under our control are keys that
are used for signing the zone and thus that we have key files for.

Same counts for CDNSKEY and CDS (records that are derived from keys).

3 years agoAdd function to check if a DNSKEY record is in use
Matthijs Mekking [Fri, 3 Mar 2023 13:19:14 +0000 (14:19 +0100)] 
Add function to check if a DNSKEY record is in use

Add a function that checks whether a DNSKEY, CDNSKEY, or CDS record
belongs to a key that is being used for signing.

3 years agoAdd multisigner system test
Matthijs Mekking [Tue, 4 Oct 2022 13:42:03 +0000 (15:42 +0200)] 
Add multisigner system test

Add a new system test to test multisigner model use cases. This
initial test just tests a small part of the model 2, and uses two
providers for the same zone, ns3 and ns4, each with their own unique
key set. This commit tests that each provider can import their ZSK
of the other provider into their DNSKEY RRset, using dynamic update.

Both providers use dnssec-policy, ns3 applies the DNSSEC records
directly, while ns4 uses inline-signing.

3 years agoMerge branch '4053-cid-453470-use-after-free-in-lib-ns-client-c' into 'main'
Mark Andrews [Tue, 23 May 2023 03:02:26 +0000 (03:02 +0000)] 
Merge branch '4053-cid-453470-use-after-free-in-lib-ns-client-c' into 'main'

Resolve "CID 453470: Use after free in lib/ns/client.c"

Closes #4053

See merge request isc-projects/bind9!7898

3 years agoSilence Coverity USE_AFTER_FREE warning
Mark Andrews [Wed, 10 May 2023 04:50:59 +0000 (14:50 +1000)] 
Silence Coverity USE_AFTER_FREE warning

Use current used pointer - 16 instead of a saved pointer as Coverity
thinks the memory may be freed between assignment and use of 'cp'.
isc_buffer_put{mem,uint{8,16,32}} can theoretically free the memory
if there is a dynamic buffer in use but that is not the case here.

3 years agoMerge branch 'each-placeholder' into 'main'
Evan Hunt [Mon, 22 May 2023 23:15:59 +0000 (23:15 +0000)] 
Merge branch 'each-placeholder' into 'main'

placeholder for [GL #3905]

See merge request isc-projects/bind9!7957

3 years agoplaceholder for [GL #3905]
Evan Hunt [Mon, 22 May 2023 23:09:49 +0000 (16:09 -0700)] 
placeholder for [GL #3905]

3 years agoMerge branch 'tkrizek/system-tests-pytest-runner' into 'main'
Tom Krizek [Mon, 22 May 2023 14:53:00 +0000 (14:53 +0000)] 
Merge branch 'tkrizek/system-tests-pytest-runner' into 'main'

System tests: support using pytest instead of run.sh

Closes #3978

See merge request isc-projects/bind9!6809

3 years agoReorder dead primary checks in upforwd test
Tom Krizek [Mon, 22 May 2023 12:20:29 +0000 (14:20 +0200)] 
Reorder dead primary checks in upforwd test

The check which attempts to forward dynamic update to a dead primary may
trigger a timing issue #4080. For some reason, this has manifested under
the pytest runner, while the test still passes with the legacy runner.

Move the dead primary check closer to the end of the test to avoid
hitting this issue before we have a proper fix.

3 years agoAdd CHANGES and release note for [GL #3978]
Tom Krizek [Thu, 30 Mar 2023 13:32:59 +0000 (15:32 +0200)] 
Add CHANGES and release note for [GL #3978]

3 years agoTear down module logger handler in system tests
Tom Krizek [Tue, 9 May 2023 12:20:02 +0000 (14:20 +0200)] 
Tear down module logger handler in system tests

The module-level logger has a handler that writes into a temporary
directory. Ensure the logging output is flushed and the handler is
closed before attempting to remove this temporary directory.

3 years agoRewrite run.sh to invoke pytest in a system test directory
Tom Krizek [Tue, 9 May 2023 11:32:13 +0000 (13:32 +0200)] 
Rewrite run.sh to invoke pytest in a system test directory

Previously, run.sh tried to use pytest's -k option for test selection.
The downside was that this filter expression matched any test case with
the given substring, rather than executing a system test suite with the
given name.

The run.sh has been rewritten to invoke pytest from a system test
directory instead. This behaves more consistently with the run.sh from
legacy system test framework.

run.sh is now also a shell script to avoid confusion regarding its
file extension.

3 years agoAdd .log.txt to gitignore
Tom Krizek [Fri, 14 Apr 2023 12:40:51 +0000 (14:40 +0200)] 
Add .log.txt to gitignore

It can be useful to append the .txt extension to logs. When this
extension is used, GitLab is able to set the proper content type on such
artifacts in CI. This makes it possible to display those files directly
in the browser rather than having to download them.

3 years agoRemove "which" declaration from env vars in EL8+ tests
Tom Krizek [Wed, 12 Apr 2023 15:29:26 +0000 (17:29 +0200)] 
Remove "which" declaration from env vars in EL8+ tests

EL8+ systems declare "which" function using environment variables in the
/etc/profile.d/which2.sh file. Because of our suboptimal environment
variable detection, which is required in order to support the legacy
runner, these variables are picked up by the pytest runner.

If subprocesses are spawned with these environment variables set, it
will cause the following issue when they spawn yet another subprocess:

/bin/sh: which: line 1: syntax error: unexpected end of file
/bin/sh: error importing function definition for `which'

3 years agoCapture log output during pytest runner setup
Tom Krizek [Wed, 12 Apr 2023 12:22:27 +0000 (14:22 +0200)] 
Capture log output during pytest runner setup

Instantiate a new logger that is used during pytest initialization /
configuration. This logging isn't handled by pytest itself, since it
happens outside of any tests or fixtures.

Root logger can't be reused for this purpose, because that would
duplicate the logs. Instead, create a conftest-specific logger for this
purpose.

Unfortunately, this introduces another log file,
pytest.conftest.log.txt, which contains only the logging from pytest
initialization. However, unless one is debugging the runner /
environment, there should be no need to investigate this file.

3 years agoExecute long running system tests first
Tom Krizek [Wed, 5 Apr 2023 10:39:56 +0000 (12:39 +0200)] 
Execute long running system tests first

In order to take the most advantage of parallel execution of tests,
ensure certain long running tests are scheduled first.

The list of tests considered long-running was created empirically. In
addition to the test run time, its position in the default
(alphabetical) ordering was also taken into account.

3 years agoDisable pylint check for too-few-public-methods
Tom Krizek [Wed, 5 Apr 2023 08:48:57 +0000 (10:48 +0200)] 
Disable pylint check for too-few-public-methods

This check is overly aggressive and not really useful, especially for
non-Python codebase, where the primary use of Python is for testing.

3 years agoAdd test specific logger for pytests
Tom Krizek [Tue, 4 Apr 2023 15:44:10 +0000 (17:44 +0200)] 
Add test specific logger for pytests

The logger fixture is provided as a test-level logging facility which
can be easily passed to tests to enable capturing and/or displaying
messages from tests written in Python.

While this works optimally with the pytest runner, messages on INFO
level or above will also be visible when using the legacy runner.

3 years agoMark selected statschannel tests as xfail
Tom Krizek [Tue, 4 Apr 2023 08:34:37 +0000 (10:34 +0200)] 
Mark selected statschannel tests as xfail

The test_zone_timers_secondary_json() and
test_zone_timers_secondary_xml() tests are affected by issue #3983. Due
to the way tests are run, they are only affected when executing them
with the pytest runner.

Strict mode is set for pytest runner, as it always fails there. The
strict mode ensures we'll catch the change when the it starts passing
once the underlying issue is fixed. It can't be set for the legacy
runner, since the test (incorrectly) passes there.

Related #3983

3 years agoEnsure assertions and exceptions end up in system test log
Tom Krizek [Mon, 3 Apr 2023 16:05:29 +0000 (18:05 +0200)] 
Ensure assertions and exceptions end up in system test log

If a test fails with an assertion failure or exception, its content
along with traceback is displayed in pytest output. This information
should be preserved in the test-specific logger for a given system test
to make it easier to debug test failures.

3 years agoUse raw byte format of env variables in pytest
Petr Špaček [Tue, 28 Mar 2023 09:52:38 +0000 (11:52 +0200)] 
Use raw byte format of env variables in pytest

In order to avoid issues with decoding/encoding env variables due to
different encodings on different systems, deal with the environment
variables directly as bytes.

3 years agoDisplay pytest failures for system:gcc:tarball
Tom Krizek [Thu, 23 Mar 2023 15:47:32 +0000 (16:47 +0100)] 
Display pytest failures for system:gcc:tarball

Since the tarball build&tests happen in a subdirectory, ensure the
after_script switches to it, so artifacts can be found properly.

3 years agoHandle missing test_results due to pytest runner interrupt
Tom Krizek [Wed, 22 Mar 2023 14:52:05 +0000 (15:52 +0100)] 
Handle missing test_results due to pytest runner interrupt

If pytest execution is interrupted, the hook that exposes test_results
to the pytest session is never called so the results can't be
interpreted.

3 years agoRun system tests sequentially if xdist is not available
Tom Krizek [Tue, 28 Mar 2023 14:42:31 +0000 (16:42 +0200)] 
Run system tests sequentially if xdist is not available

3 years agoInclude logs from failing tests in JUnit output
Petr Špaček [Fri, 17 Mar 2023 12:20:59 +0000 (13:20 +0100)] 
Include logs from failing tests in JUnit output

3 years agoEnable live logging for non-parallel pytest runs
Petr Špaček [Thu, 16 Mar 2023 17:40:59 +0000 (18:40 +0100)] 
Enable live logging for non-parallel pytest runs

This provides incremental output when test is running _without xdist_,
just like the old runner did.

With xdist the live output is not available, I believe because of
https://github.com/pytest-dev/pytest-xdist/issues/402
https://github.com/pytest-dev/pytest-xdist/pull/883 might help with
that, but I'm not going to hold my breath until it is available on
distros we use.

3 years agoEnsure --dist=loadscope is used when running pytest in parallel
Tom Krizek [Tue, 28 Mar 2023 14:52:49 +0000 (16:52 +0200)] 
Ensure --dist=loadscope is used when running pytest in parallel

The loadscope setting is required for parallel execution of our system
tests using pytest. The option ensure that all tests within a single
(module) scope will be assigned to the same worker.

This is neccessary because the worker sets up the nameservers for all
the tests within a module scope. If tests from the same module would be
assigned to different workers, then the setup could happen multiple
times, causing a race condition. This happens because each module uses
deterministic port numbers for the nameservers.

3 years agoInvoke pytest runner from run.sh
Tom Krizek [Fri, 13 Jan 2023 15:32:39 +0000 (16:32 +0100)] 
Invoke pytest runner from run.sh

Utilize developers' muscle memory to incentivize using the pytest runner
instead of the legacy one. The script also serves as basic examples of
how to run the pyest command to achieve the same results as the legacy
runner.

Invoking pytest directly should be the end goal, since it offers many
potentially useful options (refer to pytest --help).

3 years agoUse pytest system test runner in CI
Tom Krizek [Tue, 22 Nov 2022 09:47:15 +0000 (10:47 +0100)] 
Use pytest system test runner in CI

Replace the legacy system test runner by the pytest system test runner.
Since EL7 and OpenBSD have only ancient versions of pytest / xdist, keep
using the legacy test runner there for now.

Out of tree tests aren't supported by the pytest runner yet. Use the
legacy test runner for that purpose as well.

Use awk to display failures and errors at the end of the log for
convenience, since pytest displays them first, which makes them
difficult to find.

3 years agoAdd developer docs for pytest system test runner
Tom Krizek [Fri, 13 Jan 2023 15:06:01 +0000 (16:06 +0100)] 
Add developer docs for pytest system test runner

3 years agoUpdate user docs with pytest system test runner
Tom Krizek [Wed, 11 Jan 2023 15:37:45 +0000 (16:37 +0100)] 
Update user docs with pytest system test runner

3 years agoAdd pytest functions for shell system tests
Tom Krizek [Tue, 29 Nov 2022 14:07:02 +0000 (15:07 +0100)] 
Add pytest functions for shell system tests

In order to run the shell system tests, the pytest runner has to pick
them up somehow. Adding an extra python file with a single function
for the shell tests for each system test proved to be the most
compatible way of running the shell tests across older pytest/xdist
versions.

Modify the legacy run.sh script to ignore these pytest-runner specific
glue files when executing tests written in pytest.

3 years agoIgnore tempdirs during pytest collection phase
Tom Krizek [Thu, 12 Jan 2023 17:02:39 +0000 (18:02 +0100)] 
Ignore tempdirs during pytest collection phase

3 years agoEnsure compatiblity with older pytest
Tom Krizek [Thu, 12 Jan 2023 17:01:02 +0000 (18:01 +0100)] 
Ensure compatiblity with older pytest

Special care needs to be taken to support older pytest / xdist versions.
The target versions are what is available in EL8, since that seems to
have the oldest versions that can be reasonably supported.

3 years agoKeep the tempdir in case test setup/teardown fails
Tom Krizek [Thu, 12 Jan 2023 16:59:51 +0000 (17:59 +0100)] 
Keep the tempdir in case test setup/teardown fails

When an issue occurs inside a fixture (e.g. servers fail to start/stop),
the test result won't be detected as failed, but rather an error will be
thrown.

To ensure the tempdir is kept even if the test itself passes but the
system_test() fixture throws an error, a different mechanism is needed.
At the start of the critical test setup section, note that the fixture
hasn't finished yet. When this is detected in the system_test_dir()
fixture, it is recognized as error in test setup/teardown and the temp
directory is kept.

This may seem cumbersome, because it is. It's basically a workaround for
the way pytest handles fixtures and test errors in general.

3 years agoEnsure tempdir is kept for failed system tests
Tom Krizek [Thu, 12 Jan 2023 16:41:35 +0000 (17:41 +0100)] 
Ensure tempdir is kept for failed system tests

The temporary directory contains artifacts for the pytest module. That
module may contain multiple individual tests which were executed
sequentially. The artifacts should be kept if even one of these tests
failed.

Since pytest doesn't have any facility to expose test results to
fixtures, customize the pytest_runtest_makereport() hook to enable that.
It stores the test results into a session scope variable which is
available in all fixtures.

When deciding whether to remove the temporary directory, find the
relevant test results for this module and don't remove the tmpdir if any
one the tests failed.

3 years agoAdd --noclean option to pytest runner
Tom Krizek [Thu, 12 Jan 2023 16:38:06 +0000 (17:38 +0100)] 
Add --noclean option to pytest runner

Support the --noclean option to allow the user to keep the artifacts
from any test run.

3 years agoRun system tests inside temporary directories
Tom Krizek [Thu, 12 Jan 2023 16:30:22 +0000 (17:30 +0100)] 
Run system tests inside temporary directories

For every pytest module, create a copy of its system test directory and
run the test from that directory. This makes it easier to clean up
afterwards and makes it less error-prone when re-running (failed) tests.

Configure the logger to capture the module's log output into a separate
file available from the temporary directory. This is quite convenient
for exploring failures.

Cases where temporary directory should be kept are handled in a
follow-up commits.

3 years agoExecute the system test workflow in pytest runner
Tom Krizek [Thu, 12 Jan 2023 16:27:07 +0000 (17:27 +0100)] 
Execute the system test workflow in pytest runner

This is basically the pytest re-implementation of the run.sh script.

The fixture is applied to every module and ensures complete test
setup/teardown, such as starting/stopping servers, detecting coredumps
etc.

Note that the fixture system_test_dir is not defined yet. It is omitted
now for review readability and it's added in follow-up commits.

3 years agoUtility fixtures for pytest runner
Tom Krizek [Thu, 12 Jan 2023 16:01:36 +0000 (17:01 +0100)] 
Utility fixtures for pytest runner

Add fixtures for deriving system test name from the directory name and
for a module-specific logger.

Add fixtures to execute shell and perl scripts. Similar to how run.sh
calls commands, this functionality is also needed in pytest. The
fixtures take care of switching to a proper directory, logging
everything and handling errors.

Note that the fixture system_test_dir is not defined yet. It is omitted
now for review readability and it's added in follow-up commits.

3 years agoAssign unique ports to pytest modules
Tom Krizek [Thu, 12 Jan 2023 15:52:49 +0000 (16:52 +0100)] 
Assign unique ports to pytest modules

This is basically a pytest re-implementation of the get_ports.sh script.
The main difference is that ports are assigned on a module basis, rather
than a directory basis. Module is the new atomic unit for parallel
execution, therefore it needs to have unique ports to avoid collisions.

Each module gets its ports through the env fixture which is updated with
ports and other module-specific variables.

3 years agoEnsure system test programs and deps are compiled
Tom Krizek [Thu, 12 Jan 2023 15:47:55 +0000 (16:47 +0100)] 
Ensure system test programs and deps are compiled

Some system tests require extra programs and/or dependencies to be
compiled first. This is done via `make check` with the automake
framework when using check_* variables such as check_PROGRAMS.

To avoid running any tests via the automake framework, set the TESTS
env variable to empty string and utilize `make -e check` to override
default Makefile variables with environment ones. This ensures automake
will only compile the needed dependencies without running any tests.

Additional consideration needs to be taken for xdist. The compilation
command should be called just once before any tests are executed. To
achieve that, use the pytest_configure() hook and check that the
PYTEST_XDIST_WORKER env variable isn't set -- if it is, it indicates
we're in the spawned xdist worker and the compilation was already done
by the main pytest process that spawned the workers.

This is mostly done to have on-par functionality with legacy test
framework. In the future, we should get rid of the need to run "empty"
make -e check and perhaps compile test-stuff by default.

3 years agoObtain env vars from conf.sh in pytest runner
Tom Krizek [Thu, 12 Jan 2023 15:41:41 +0000 (16:41 +0100)] 
Obtain env vars from conf.sh in pytest runner

The commands executed by pytest during a system test need to have the
same environment variables set as if they were executed by the run.sh
shell script.

It was decided that for the moment, legacy way of executing system tests
with run.sh should be kept, which complicates things a bit. In order to
avoid duplicating the required variables in both conf.sh and pytest, it
was decided to use the existing conf.sh as the only authoritative
place for the variables.

It is necessary to process the environment variables from conf.sh right
when conftest.py is loaded, since they might be needed right away (e.g.
to test for feature support during test collection).

This solution is a bit hacky and is only meant to be used during the
transitory phase when both pytest and the legacy run.sh are both
supported. In the future, a superior pytest-only solution should be
used.

For discussion of other options, refer to
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/6809#note_318889