Commit Graph

37767 Commits

Author SHA1 Message Date
Mark Andrews
27eb8ed20f 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.

(cherry picked from commit ac2e0bc3ff)
2023-05-29 13:27:51 +10:00
Evan Hunt
9a1d565f07 Merge branch '3905-deprecate-tkey-dhkey-v9_18' into 'bind-9.18'
mark 'tkey-dhkey' as deprecated

See merge request isc-projects/bind9!7956
2023-05-28 08:07:25 +00:00
Evan Hunt
9a8f8d6046 CHANGES and release note for [GL #3905] 2023-05-28 00:55:55 -07:00
Evan Hunt
88383aa158 mark 'tkey-dhkey' as deprecated
Diffie-Hellman TKEY mode has been removed for 9.20.
2023-05-28 00:55:34 -07:00
Artem Boldariev
97d672d368 Merge branch '4091-syncrhonise-access-to-the-client-tlsctx-cache-9.18' into 'bind-9.18'
[9.18] ZMGR: TLS contexts cache - properly synchronise access

See merge request isc-projects/bind9!7972
2023-05-26 14:11:40 +00:00
Artem Boldariev
cec8947bc1 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.

(cherry picked from commit 0b95cf74ff)
2023-05-26 15:24:51 +03:00
Michal Nowak
207f9bb1c3 Merge branch 'mnowak/gitlab-runner-autoscaling-9.18' into 'bind-9.18'
[9.18] Run most Docker CI jobs in AWS with autoscaler

See merge request isc-projects/bind9!7969
2023-05-26 09:54:12 +00:00
Michal Nowak
94d83b7960 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.

(cherry picked from commit f09cf69594)
2023-05-26 11:47:20 +02:00
Evan Hunt
59827b21d1 Merge branch '4072-tcp-dispatch-timeout-bind-9.18' into 'bind-9.18'
[9.18] fix handling of TCP timeouts

See merge request isc-projects/bind9!7968
2023-05-26 09:32:22 +00:00
Evan Hunt
e9b6991357 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.

(cherry picked from commit 0e800467ee)
2023-05-26 02:07:02 -07:00
Evan Hunt
7045f33d45 Merge branch '4079-multiple-keyrings-bind-9.18' into 'bind-9.18'
[9.18] prevent TSIG keys from being added to multiple rings

See merge request isc-projects/bind9!7965
2023-05-25 23:43:36 +00:00
Evan Hunt
913fce98bf CHANGES for [GL #4079] 2023-05-25 15:08:59 -07:00
Evan Hunt
afae1b65e8 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.
2023-05-25 15:08:48 -07:00
Arаm Sаrgsyаn
911f3af2fb Merge branch '3765-interfacemgr-use-after-afree-on-shutdown-9.18' into 'bind-9.18'
[9.18] Fix an interfacemgr use-after-free error in zoneconf.c:isself()

See merge request isc-projects/bind9!7964
2023-05-25 11:42:18 +00:00
Aram Sargsyan
685d9ece61 Add a CHANGES note for [GL #3765]
(cherry picked from commit b409db08cf)
2023-05-25 08:39:20 +00:00
Aram Sargsyan
1d736cf451 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
3aca8e5bf3 commit. Later, in the
8eb88aafee 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.

(cherry picked from commit 64d69e4adc)
2023-05-25 08:39:20 +00:00
Tom Krizek
66254cf56d Merge branch 'tkrizek/system-tests-pytest-runner-9.18' into 'bind-9.18'
[9.18] System tests: support using pytest instead of run.sh

See merge request isc-projects/bind9!7959
2023-05-23 16:02:15 +00:00
Tom Krizek
81b7682e24 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.

(cherry picked from commit edaa5f5d2a)
2023-05-23 17:41:35 +02:00
Tom Krizek
b9b3b53e2c Add CHANGES and release note for [GL #3978]
(cherry picked from commit fd889bf0ad)
2023-05-23 17:41:35 +02:00
Tom Krizek
f3c0005257 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.

(cherry picked from commit 0f8a2b07a4)
2023-05-23 17:41:35 +02:00
Tom Krizek
6811f9704a 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.

(cherry picked from commit 1aaefc9cf4)
2023-05-23 17:41:34 +02:00
Tom Krizek
de206d6436 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.

(cherry picked from commit 8d40156bb2)
2023-05-23 17:41:34 +02:00
Tom Krizek
e2f7dbcbd1 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'

(cherry picked from commit 68b1c6877b)
2023-05-23 17:41:34 +02:00
Tom Krizek
5b5210854d 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.

(cherry picked from commit 12c724ee07)
2023-05-23 17:41:34 +02:00
Tom Krizek
16eeb36432 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.

(cherry picked from commit 99e2e50c0e)
2023-05-23 17:41:34 +02:00
Tom Krizek
b9596d2107 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.

(cherry picked from commit 6f134283eb)
2023-05-23 17:41:34 +02:00
Tom Krizek
1acb8a3f39 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.

(cherry picked from commit 952776b61f)
2023-05-23 17:41:34 +02:00
Tom Krizek
862f6e043a 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

(cherry picked from commit 087a9b3c97)
2023-05-23 17:41:34 +02:00
Tom Krizek
f0db1c27ba 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.

(cherry picked from commit 3a20e8d990)
2023-05-23 17:41:34 +02:00
Petr Špaček
0277c5098c 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.

(cherry picked from commit 37ed9ad2f8)
2023-05-23 17:41:33 +02:00
Tom Krizek
23b2777067 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.

(cherry picked from commit a6559176f1)
2023-05-23 17:41:33 +02:00
Tom Krizek
445b30b883 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.

(cherry picked from commit 0a063f51d3)
2023-05-23 17:41:33 +02:00
Tom Krizek
6103ee988e Run system tests sequentially if xdist is not available
(cherry picked from commit 1cc55d01c7)
2023-05-23 17:41:33 +02:00
Petr Špaček
8627d41d4d Include logs from failing tests in JUnit output
(cherry picked from commit 8952618262)
2023-05-23 17:41:33 +02:00
Petr Špaček
a802e84cd5 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.

(cherry picked from commit d0619c7a18)
2023-05-23 17:41:33 +02:00
Tom Krizek
a388a689cf 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.

(cherry picked from commit 8f57bce7af)
2023-05-23 17:41:33 +02:00
Tom Krizek
ac1e7eb40d 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).

(cherry picked from commit 4dbe8e5347)

(also manually added a additional run.sh -> legacy.run.sh renames)
2023-05-23 17:41:33 +02:00
Tom Krizek
75a31555bd 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.

(cherry picked from commit 4bc2b3be48)
2023-05-23 17:41:31 +02:00
Tom Krizek
2c167bb35f Add developer docs for pytest system test runner
(cherry picked from commit d1ef51f589)
2023-05-23 16:55:28 +02:00
Tom Krizek
e9c15a5736 Update user docs with pytest system test runner
(cherry picked from commit dc84121004)
2023-05-23 16:55:27 +02:00
Tom Krizek
3b6ca76f46 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.

(cherry picked from commit 2f5bf6d971)

(manually added host/tests_sh_host.py, tkey/tests_sh_tkey.py on top)
2023-05-23 16:55:26 +02:00
Tom Krizek
0df2ea8fab Ignore tempdirs during pytest collection phase
(cherry picked from commit 8a406b73c9)
2023-05-23 16:17:24 +02:00
Tom Krizek
b8d6434d5d 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.

(cherry picked from commit 527ac6ad26)
2023-05-23 16:17:24 +02:00
Tom Krizek
eaf64e93aa 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.

(cherry picked from commit 247e90c382)
2023-05-23 16:17:24 +02:00
Tom Krizek
cdbdbd9eaf 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.

(cherry picked from commit 2d93ed8546)
2023-05-23 16:17:24 +02:00
Tom Krizek
ba922ba774 Add --noclean option to pytest runner
Support the --noclean option to allow the user to keep the artifacts
from any test run.

(cherry picked from commit 8b1a906b39)
2023-05-23 16:17:24 +02:00
Tom Krizek
d1e6400d63 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.

(cherry picked from commit c571af8c8f)
2023-05-23 16:17:24 +02:00
Tom Krizek
0ed639010c 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.

(cherry picked from commit 2b64618624)
2023-05-23 16:17:24 +02:00
Tom Krizek
23cecd2190 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.

(cherry picked from commit 6886cc1826)
2023-05-23 16:17:23 +02:00
Tom Krizek
aa199e2726 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.

(cherry picked from commit 0061758156)
2023-05-23 16:17:23 +02:00