]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/test-distributor_hh.cc
rec: ensure correct service user on debian
[thirdparty/pdns.git] / pdns / test-distributor_hh.cc
index 63ae49d3a15e39e870b059ed2c882e78cfcfe16a..f21a9b767cbfbcee3f332a18788f6449882ee349 100644 (file)
@@ -66,16 +66,29 @@ struct BackendSlow
   }
 };
 
+static std::atomic<int> g_receivedAnswers1;
+static void report1(DNSPacket* A)
+{
+  delete A;
+  g_receivedAnswers1++;
+}
 
 BOOST_AUTO_TEST_CASE(test_distributor_queue) {
+  ::arg().set("overload-queue-length","Maximum queuelength moving to packetcache only")="0";
+  ::arg().set("max-queue-length","Maximum queuelength before considering situation lost")="1000";
+  ::arg().set("queue-limit","Maximum number of milliseconds to queue a query")="1500";
+  S.declare("servfail-packets","Number of times a server-failed packet was sent out");
+  S.declare("timedout-packets", "timedout-packets");
+
   auto d=Distributor<DNSPacket, Question, BackendSlow>::Create(2);
 
   BOOST_CHECK_EXCEPTION( {
     int n;
-    for(n=0; n < 6000; ++n)  {
+    // bound should be higher than max-queue-length
+    for(n=0; n < 2000; ++n)  {
       auto q = new Question();
       q->d_dt.set(); 
-      d->question(q, report);
+      d->question(q, report1);
     }
     }, DistributorFatal, [](DistributorFatal) { return true; });
 };
@@ -115,9 +128,13 @@ static void report2(DNSPacket* A)
 
 
 BOOST_AUTO_TEST_CASE(test_distributor_dies) {
+  ::arg().set("overload-queue-length","Maximum queuelength moving to packetcache only")="0";
+  ::arg().set("max-queue-length","Maximum queuelength before considering situation lost")="5000";
+  ::arg().set("queue-limit","Maximum number of milliseconds to queue a query")="1500";
+  S.declare("servfail-packets","Number of times a server-failed packet was sent out");
+  S.declare("timedout-packets", "timedout-packets");
+
   auto d=Distributor<DNSPacket, Question, BackendDies>::Create(10);
-  sleep(1);
-  g_receivedAnswers=0;
 
   try {
     for(int n=0; n < 100; ++n)  {