From: Remi Gacogne Date: Mon, 8 Nov 2021 09:39:11 +0000 (+0100) Subject: dnsdist: Test that reused connections are moved to the active queue X-Git-Tag: dnsdist-1.7.0-beta1~5^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7da062ca9e680fc50763a5c6801c0837366217a1;p=thirdparty%2Fpdns.git dnsdist: Test that reused connections are moved to the active queue --- diff --git a/pdns/dnsdistdist/test-dnsdist-connections-cache.cc b/pdns/dnsdistdist/test-dnsdist-connections-cache.cc index 6cde1186da..ef47ba6ac8 100644 --- a/pdns/dnsdistdist/test-dnsdist-connections-cache.cc +++ b/pdns/dnsdistdist/test-dnsdist-connections-cache.cc @@ -216,6 +216,18 @@ BOOST_AUTO_TEST_CASE(test_ConnectionsCache) BOOST_CHECK_EQUAL(manager.count(), maxIdleConnPerDownstream); BOOST_CHECK_EQUAL(manager.getActiveCount(), 0U); BOOST_CHECK_EQUAL(manager.getIdleCount(), maxIdleConnPerDownstream); + + { + /* if we ask for a connection, one of these should become active and no longer idle */ + /* but first we need to mark them as usable again */ + for (const auto& c : conns) { + c->d_usable = true; + } + auto got = manager.getConnectionToDownstream(mplexer, downstream1, now, std::string()); + BOOST_CHECK_EQUAL(manager.count(), maxIdleConnPerDownstream); + BOOST_CHECK_EQUAL(manager.getActiveCount(), 1U); + BOOST_CHECK_EQUAL(manager.getIdleCount(), maxIdleConnPerDownstream - 1U); + } } BOOST_AUTO_TEST_SUITE_END();