]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Test that reused connections are moved to the active queue
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 8 Nov 2021 09:39:11 +0000 (10:39 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 8 Nov 2021 09:39:11 +0000 (10:39 +0100)
pdns/dnsdistdist/test-dnsdist-connections-cache.cc

index 6cde1186dae8ceec192a4caf5ce70a9de2f8fc4a..ef47ba6ac8bb1a5885c8bea801da25e06f28b7d9 100644 (file)
@@ -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();