diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:14:51 +0000 |
commit | bc282425088455198a7a99511c75914477d4ed32 (patch) | |
tree | 1b1fb887a634136a093deea7e4dd95d054201e7a /test-dnsdistasync.cc | |
parent | Releasing progress-linux version 1.8.3-3~progress7.99u1. (diff) | |
download | dnsdist-bc282425088455198a7a99511c75914477d4ed32.tar.xz dnsdist-bc282425088455198a7a99511c75914477d4ed32.zip |
Merging upstream version 1.9.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test-dnsdistasync.cc')
-rw-r--r-- | test-dnsdistasync.cc | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/test-dnsdistasync.cc b/test-dnsdistasync.cc index 7e8e137..e535ba3 100644 --- a/test-dnsdistasync.cc +++ b/test-dnsdistasync.cc @@ -19,7 +19,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef BOOST_TEST_DYN_LINK #define BOOST_TEST_DYN_LINK +#endif + #define BOOST_TEST_NO_MAIN #include <boost/test/unit_test.hpp> @@ -36,15 +39,15 @@ public: return true; } - void handleResponse(const struct timeval&, TCPResponse&&) override + void handleResponse([[maybe_unused]] const struct timeval& now, [[maybe_unused]] TCPResponse&& response) override { } - void handleXFRResponse(const struct timeval&, TCPResponse&&) override + void handleXFRResponse([[maybe_unused]] const struct timeval& now, [[maybe_unused]] TCPResponse&& response) override { } - void notifyIOError(InternalQueryState&&, const struct timeval&) override + void notifyIOError([[maybe_unused]] const struct timeval& now, [[maybe_unused]] TCPResponse&& response) override { errorRaised = true; } @@ -112,23 +115,29 @@ BOOST_AUTO_TEST_CASE(test_TimeoutFailClose) auto holder = std::make_unique<dnsdist::AsynchronousHolder>(false); uint16_t asyncID = 1; uint16_t queryID = 42; - struct timeval ttd; - gettimeofday(&ttd, nullptr); - // timeout in 10 ms - const timeval add{0, 10000}; - ttd = ttd + add; + struct timeval ttd + { + }; std::shared_ptr<DummyQuerySender> sender{nullptr}; { + // timeout in 10 ms + const timeval add{0, 10000}; auto query = std::make_unique<DummyCrossProtocolQuery>(); sender = query->d_sender; BOOST_REQUIRE(sender != nullptr); + gettimeofday(&ttd, nullptr); + ttd = ttd + add; holder->push(asyncID, queryID, ttd, std::move(query)); BOOST_CHECK(!holder->empty()); } - // sleep for 20 ms, to be sure - usleep(20000); + // the event should be triggered after 10 ms, but we have seen + // many spurious failures on our CI, likely because the box is + // overloaded, so sleep for up to 100 ms to be sure + for (size_t counter = 0; !holder->empty() && counter < 10; counter++) { + usleep(10000); + } BOOST_CHECK(holder->empty()); BOOST_CHECK(sender->errorRaised.load()); @@ -155,8 +164,13 @@ BOOST_AUTO_TEST_CASE(test_AddingExpiredEvent) holder->push(asyncID, queryID, ttd, std::move(query)); } - // sleep for 20 ms - usleep(20000); + // the expired event should be triggered almost immediately, + // but we have seen many spurious failures on our CI, + // likely because the box is overloaded, so sleep for up to + // 100 ms to be sure + for (size_t counter = 0; !holder->empty() && counter < 10; counter++) { + usleep(10000); + } BOOST_CHECK(holder->empty()); BOOST_CHECK(sender->errorRaised.load()); |