Commit graph

9269 commits

Author SHA1 Message Date
Witold Kręcicki
8cdad6bedf Fix timing issues in catz test
Make the log checks more precise and use the retry() function for
repeating the checks.

(cherry picked from commit 9b43e65c01)
2020-01-08 14:11:29 +01:00
Ondřej Surý
4a6d9ea152 Fix multiple issues in named setuid check
(cherry picked from commit cd804158b4)
2020-01-08 09:31:13 +01:00
Evan Hunt
dc760867d8 fixed a test failure, some other shell cleanup
(cherry picked from commit 7a8269207d)
2020-01-08 09:30:00 +01:00
Ondřej Surý
355eb0c288 Instead of sleeping for a fixed time, wait for named to log specific message in a loop
(cherry picked from commit f020199925)
2020-01-08 09:29:24 +01:00
Ondřej Surý
57b6aeabd5 Make runtime/tests.sh shellcheck and set -e clean
This mostly comprises of:

* using $(...) instead of `...`
* changing the directories in subshell and not ignoring `cd` return code
* handling every error gracefully instead of ignoring the return code

(cherry picked from commit 340b1d2b6b)
2020-01-08 09:28:24 +01:00
Ondřej Surý
d26e7166a6 Further improve the runtime tests to look for a specific instead of generic error
(cherry picked from commit 8f539a8886)
2020-01-08 09:27:48 +01:00
Ondřej Surý
60f335204a Fix couple of no-op tests to actually test something (configuration files were missing)
(cherry picked from commit b5a18ac439)
2020-01-08 09:27:16 +01:00
Ondřej Surý
fe021299e0 runtime test: make the pidfiles match the names of configuration files
(cherry picked from commit ce86721bc3)
2020-01-08 09:24:49 +01:00
Ondřej Surý
e9d348bac5 runtime test: use helper function that kills named and waits for the finish
(cherry picked from commit e9fa7b831b)
2020-01-08 09:22:59 +01:00
Mark Andrews
546efbe2ee Address timing issues in 'inline' system test.
"rndc signing -serial <value>" could take longer than a second to
complete.  Loop waiting for update to succeed.

For tests where "rndc signing -serial <value>" is supposed to not
succeed, repeatedly test that we don't get the new serial, then
test that we have the old value.  This should prevent false negatives.

(cherry picked from commit 13fa80ede8)
2020-01-08 08:31:42 +01:00
Ondřej Surý
ba2b616a4a Detect cores on FreeBSD
(cherry picked from commit 38277ddb0b)
2020-01-07 15:58:44 +01:00
Ondřej Surý
48512e11be Reduce the minimal numbers of days in jitter test to 5
(cherry picked from commit 4b2911a45a)
2020-01-07 15:46:28 +01:00
Ondřej Surý
e359a954fc Tune the performance of CDS/CDNSKEY deletion test
(cherry picked from commit 76eac9a691)
2020-01-07 15:46:27 +01:00
Ondřej Surý
46403cff2c Tune the performance of oldsigs test
The oldsigs test was checking only for the validity of the A
a.oldsigs.example. resource record and associated DNSSEC signature while
the zone might not have been fully signed yet leading to validation
failures because of bogus signatures on the validation path.

This commit changes the test to test that all old signatures in the
oldsigs.example. zone were replaced and the zone is fully resigned
before running the main check.

(cherry picked from commit 519b047362)
2020-01-07 15:44:50 +01:00
Ondřej Surý
a6a19bb246 Tune the performance of the jitter test
(cherry picked from commit ffb7ae8beb)
2020-01-07 15:44:50 +01:00
Ondřej Surý
2f57988483 Wait a little bit longer for autosign, bail out on not enough categories
(cherry picked from commit f1cbdc5498)
2020-01-07 15:37:40 +01:00
Ondřej Surý
8061971926 Adjust the jitter range to +-3*stddev
(cherry picked from commit d6f68fc4f0)
2020-01-07 15:37:40 +01:00
Ondřej Surý
484d131137 Check if the RRSIG jitter falls into mean+-2.5*stddev range
(cherry picked from commit 0480a95ddf)
2020-01-07 15:34:33 +01:00
Ondřej Surý
002f908c2f Dump the backtrace to stdout when core is found in systest directory
(cherry picked from commit 512dadc8d1)
2020-01-07 14:42:06 +01:00
Evan Hunt
6e73d3266c update copyright year to 2020 2020-01-02 21:47:16 -08:00
Mark Andrews
631ac188ee update usage message
(cherry picked from commit 41d827893e)
2019-12-20 20:04:36 +11:00
Petr Menšík
e37d8aecba Include protobuf-c version
Include used version of protobuf-c in version info, both link time and
runtime version is available.

(cherry picked from commit 85f3476894)
2019-12-18 00:31:43 +00:00
Petr Menšík
412d7724ae Provide GeoIP2 library version in version
Libmaxmind does not provide any version macro for link time version.
Print at least runtime version library used, if linked.

(cherry picked from commit e6d7384c0d)
2019-12-18 00:31:43 +00:00
Michał Kępień
f60cd0c730 Include prepare-softhsm2.sh in source tarballs
The util/prepare-softhsm2.sh script is useful for initializing a working
SoftHSM environment which can be used by unit tests and system tests.
However, since it is a test-specific script, it does not really belong
in the util/ subdirectory which is mostly pruned during the BIND source
tarball creation process.  Move the prepare-softhsm2.sh script to
bin/tests/ so that its location is more appropriate for its purpose and
also so that it does not get removed during the BIND source tarball
creation process, allowing it to be used for setting up test
environments for tarball-based builds.

(cherry picked from commit c0be772ebc)
2019-12-11 12:23:20 +01:00
Michał Kępień
7c14f67d74 Only use LC_ALL=C where intended
The LC_ALL=C assignments in the "idna" system test, which were only
meant to affect a certain subset of checks, in fact persist throughout
all the subsequent checks in that system test.  That affects the test's
behavior and is misleading.

When the "VARIABLE=value command ..." syntax is used in a shell script,
in order for the variable assignment to only apply to "command", the
latter must be an external binary; otherwise, the VARIABLE=value
assignment persists for all subsequent commands in a script:

    $ cat foo.sh
    #!/bin/sh

    foo() {
        /bin/sh bar.sh
    }

    BAR="baz0"
    BAR="baz1" /bin/sh bar.sh
    echo "foo: BAR=${BAR}"
    BAR="baz2" foo
    echo "foo: BAR=${BAR}"

    $ cat bar.sh
    #!/bin/sh

    echo "bar: BAR=${BAR}"

    $ /bin/sh foo.sh
    bar: BAR=baz1
    foo: BAR=baz0
    bar: BAR=baz2
    foo: BAR=baz2
    $

Fix by saving the value of LC_ALL before the relevant set of checks in
the "idna" system test, restoring it afterwards, and dropping the
"LC_ALL=C command ..." syntax.

(cherry picked from commit 2ee7ff23ce)
2019-12-10 11:57:57 +01:00
Matthijs Mekking
6658c11251 Better error handling in autosign system test
(cherry picked from commit bd4035900a)
2019-12-09 16:01:53 +01:00
Matthijs Mekking
fb0ddd5bfe Fix race in autosign test
The autosign test has a test case where a DNSSEC maintaiend zone
has a set of DNSSEC keys without any timing metadata set.  It
tests if named picks up the key for publication and signing if a
delayed dnssec-settime/loadkeys event has occured.

The test failed intermittently despite the fact it sleeps for 5
seconds but the triggered key reconfigure action should happen after
3 seconds.

However, the test output showed that the test query came in before
the key reconfigure action was complete (see excerpts below).

The loadkeys command is received:

15:38:36 received control channel command 'loadkeys delay.example.'

The reconfiguring zone keys action is triggered after 3 seconds:

15:38:39 zone delay.example/IN: reconfiguring zone keys
15:38:39 DNSKEY delay.example/NSEC3RSASHA1/7484 (ZSK) is now published
15:38:39 DNSKEY delay.example/NSEC3RSASHA1/7455 (KSK) is now published
15:38:39 writing to journal

Two seconds later the test query comes in:

15:38:41 client @0x7f1b8c0562b0 10.53.0.1#44177: query
15:38:41 client @0x7f1b8c0562b0 10.53.0.1#44177: endrequest

And 6 more seconds later the reconfigure keys action is complete:

15:38:47 zone delay.example/IN: next key event: 05-Dec-2019 15:48:39

This commit fixes the test by checking the "next key event" log has
been seen before executing the test query, making sure that the
reconfigure keys action has been complete.

This commit however does not fix, nor explain why it took such a long
time (8 seconds) to reconfigure the keys.

(cherry picked from commit 2e4273b55a)
2019-12-09 15:53:02 +01:00
Matthijs Mekking
5d6fad9e1e Introduce wait_for_log in autosign test 2019-12-09 15:52:00 +01:00
Matthijs Mekking
440732acd7 Save settime output
(cherry picked from commit 6b4a17ef7c)
2019-12-09 15:45:11 +01:00
Michał Kępień
5f82122ffa Automatically run clean.sh from run.sh
The first step in all existing setup.sh scripts is to call clean.sh.  To
reduce code duplication and ensure all system tests added in the future
behave consistently with existing ones, invoke clean.sh from run.sh
before calling setup.sh.

(cherry picked from commit d8905b7a9c)
2019-12-06 14:47:08 +01:00
Michał Kępień
3f7658bda7 Remove bin/tests/system/clean.sh
Since the role of the bin/tests/system/clean.sh script has now been
reduced to calling a given system test's clean.sh script, remove the
former altogether and replace its only use with a direct invocation of
the latter.

(cherry picked from commit bf3eeac067)
2019-12-06 14:47:08 +01:00
Michał Kępień
9a60296b84 Remove the -r switch from system test scripts
Since files containing system test output are no longer stored in test
subdirectories, bin/tests/system/clean.sh no longer needs to take care
of removing the test.output file for a given test as testsummary.sh
already takes care of that and even if a test suite terminates
abnormally and another one is started, tee invoked without the -a
command line switch overwrites the destination file if it exists, so
leftover test.output.* files from previous test suite runs are not a
concern.  Remove the -r command line switch and the code associated with
it from the relevant scripts.

(cherry picked from commit b4d37878f6)
2019-12-06 14:47:08 +01:00
Michał Kępień
38a4bedfcd Store system test output in bin/tests/system/
Some clean.sh scripts contain overly broad file deletion wildcards which
cause the test.output file (used by the system test framework for
collecting output) in a given system test's directory to be erroneously
removed immediately after the test is started (due to setup.sh scripts
calling clean.sh at the beginning).  This prevents the test's output
from being placed in bin/tests/system/systests.output at the end of a
test suite run and thus can lead to test failures being ignored.  Fix by
storing each test's output in a test.output.<test-name> file in
bin/tests/system/, which prevents clean.sh scripts from removing it (as
they should only ever affect files contained in a given system test's
directory).

(cherry picked from commit b0916bba41)
2019-12-06 14:47:08 +01:00
Michał Kępień
19cd59923c Detect missing system test results
At the end of each system test suite run, the system test framework
collects all existing test.output files from system test subdirectories
and produces bin/tests/system/systests.output from those files.
However, it does not check whether a test.output file was found for
every executed test.  Thus, if the test.output file is accidentally
deleted by the system test itself (e.g. due to an overly broad file
removal wildcard present in clean.sh), its output will not be included
in bin/tests/system/systests.output.  Since the result of each system
test suite run is determined by bin/tests/system/testsummary.sh, which
only operates on the contents of bin/tests/system/systests.output, this
can lead to test failures being ignored.  Fix by ensuring the number of
test results found in bin/tests/system/systests.output is equal to the
number of tests run and triggering a system test suite failure in case
of a discrepancy between these two values.

(cherry picked from commit 3c3085be3c)
2019-12-06 14:19:55 +01:00
Mark Andrews
a47736abb0 loop waiting for the redirect zone to load
(cherry picked from commit e4b1d0b686)
2019-12-06 10:57:16 +11:00
Michał Kępień
1313f06110 Move xmlInitThreads()/xmlCleanupThreads() calls
xmlInitThreads() and xmlCleanupThreads() are called from within
named_statschannels_configure() and named_statschannels_shutdown(),
respectively.  Both of these functions are executed by worker threads,
not the main named thread.  This causes ASAN to report memory leaks like
the following one upon shutdown (as long as named is asked to produce
any XML output over its configured statistics channels during its
lifetime):

    Direct leak of 968 byte(s) in 1 object(s) allocated from:
        #0 0x7f677c249cd8 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:153
        #1 0x7f677bc1838f in xmlGetGlobalState (/usr/lib/libxml2.so.2+0xa838f)

The data mentioned in the above report is a libxml2 state structure
stored as thread-specific data.  Such chunks of memory are automatically
released (by a destructor passed to pthread_key_create() by libxml2)
whenever a thread that allocated a given chunk exits.  However, if
xmlCleanupThreads() is called by a given thread before it exits, the
destructor will not be invoked (due to xmlCleanupThreads() calling
pthread_key_delete()) and ASAN will report a memory leak.  Thus,
xmlInitThreads() and xmlCleanupThreads() must not be called from worker
threads.  Since xmlInitThreads() must be called on Windows in order for
libxml2 to work at all, move xmlInitThreads() and xmlCleanupThreads()
calls to the main named thread (which does not produce any XML output
itself) in order to prevent the memory leak from being reported by ASAN.

(cherry picked from commit b425b5d56e)
2019-12-02 17:09:39 +01:00
Michał Kępień
5a0582f3e7 Fix GeoIP2 memory leak upon reconfiguration
Loaded GeoIP2 databases are only released when named is shut down, but
not during server reconfiguration.  This causes memory to be leaked
every time "rndc reconfig" or "rndc reload" is used, as long as any
GeoIP2 database is in use.  Fix by releasing any loaded GeoIP2 databases
before reloading them.  Do not call dns_geoip_shutdown() until server
shutdown as that function releases the memory context used for caching
GeoIP2 lookup results.

(cherry picked from commit 670afbe84a)
2019-12-02 15:21:38 +01:00
Michal Nowak
271c836a86 Fix the UID switch test to work with PKCS#11 build
Forward port of 32fe9a0051fc76be4657fc2742e71d2be6193011 by Ondřej Surý.

(cherry picked from commit c49c41a1adb9fa8ae75fe656692d9935de1d505f)
2019-11-27 17:14:53 +00:00
Evan Hunt
d445121c26 add a stats counter for clients dropped due to recursive-clients limit
(cherry picked from commit 715afa9c57)
2019-11-26 11:20:12 -08:00
Ondřej Surý
e78506c3a8 Request exclusive access when crashing via fatal()
When loading the configuration fails, there might be already other tasks
running and calling OpenSSL library functions.  The OpenSSL on_exit
handler is called when exiting the main process and there's a timing
race between the on_exit function that destroys OpenSSL allocated
resources (threads, locks, ...) and other tasks accessing the very same
resources leading to a crash in the system threading library. Therefore,
the fatal() function needs to request exlusive access to the task
manager to finish the already running tasks and exit only when no other
tasks are running.

(cherry picked from commit 952d7fde63)
2019-11-26 12:51:49 +01:00
Ondřej Surý
699bcc70ca Add retry_quiet() function to retry quietly for an event to occur
(cherry picked from commit 31264a7e00)
2019-11-26 09:19:52 +01:00
Mark Andrews
148c0f63fd alphabetise delv's usage.
(cherry picked from commit 78685ed173)
2019-11-23 00:09:29 +11:00
Michal Nowak
4c391e0a47 Verifying that named switches UID
This test runs only under root, which is required for the user-switch
`-u` option to work.

Closes #537.

(cherry picked from commit b00360537e)
2019-11-20 11:01:05 +00:00
Michał Kępień
3d58204f46 Address ShellCheck warnings
Address all outstanding warnings that ShellCheck reports for
bin/tests/system/tcp/tests.sh.

(cherry picked from commit 23ca0ec55b)
2019-11-19 15:39:04 +01:00
Michał Kępień
b1294b049c Use "set -e" in the "tcp" system test
Ensure any unexpected failure in the "tcp" system test causes it to be
immediately interrupted with an error to make the aforementioned test
more reliable.  Since the exit code for "expr 0 + 0" is 1, the status
variable needs to be updated using arithmetic expansion.

(cherry picked from commit 9841635b7f)
2019-11-19 15:39:03 +01:00
Michał Kępień
5e818012e5 Ensure all "tcp" system test errors are caught
Ensure any "rndc stats" failure causes the "tcp" system test to fail.
Do not hide "rndc stats" output.

(cherry picked from commit 46df363a0d)
2019-11-19 15:39:03 +01:00
Michał Kępień
1138e158f1 Make all "tcp" system test checks numbered
Ensure all checks in the "tcp" system test are numbered, so that
forensic data is preserved in case of any failure.

(cherry picked from commit 2f4877d11c)
2019-11-19 15:39:03 +01:00
Michał Kępień
8e19e3701b Fix argument order in assert_int_equal()
assert_int_equal() calls in bin/tests/system/tcp/tests.sh pass the found
value as the first argument and the expected value as the second
argument, while the function interprets its arguments the other way
round.  Fix argument handling in assert_int_equal() to make sure the
error messages printed by that function are correct.

(cherry picked from commit 6bd1f68bef)
2019-11-19 15:39:03 +01:00
Michał Kępień
1286db44f1 Allow retries when checking TCP high-water stats
In the TCP high-water checks, "rndc stats" is run after ans6 reports
that it opened the requested number of TCP connections.  However, we
fail to account for the fact that ns5 might not yet have called accept()
for these connections, in which case the counts output by "rndc stats"
will be off.  To prevent intermittent "tcp" system test failures, allow
the relevant connection count checks to be retried (just once, after one
second, as that should be enough for any system to accept() a dozen TCP
connections under any circumstances).

(cherry picked from commit 1e22e052d0)
2019-11-19 15:39:03 +01:00
Mark Andrews
3f27a0ccb2 alphabetize command line switch
(cherry picked from commit ca83a66618)
2019-11-19 20:44:21 +11:00