]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fix a spuriously failing recursorcache_cc test: reset globals (indirectly) used 13346/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 9 Oct 2023 13:07:36 +0000 (15:07 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 9 Oct 2023 13:07:36 +0000 (15:07 +0200)
For SyncRes tests we have a general mechanism setting the globals
before the test are run, but the non-syncres tests do not have that, while
they still use some globals.  In this particular case, the test would
fail if the last SyncRes test run before was setting
SyncRes::s_locked_ttlperc.

While there, pass the time to the prune functions. This avoids
potential timing issues for some tests.

pdns/cachecleaner.hh
pdns/recursordist/negcache.cc
pdns/recursordist/negcache.hh
pdns/recursordist/rec-main.cc
pdns/recursordist/recpacketcache.cc
pdns/recursordist/recpacketcache.hh
pdns/recursordist/recursor_cache.cc
pdns/recursordist/recursor_cache.hh
pdns/recursordist/test-negcache_cc.cc
pdns/recursordist/test-recpacketcache_cc.cc
pdns/recursordist/test-recursorcache_cc.cc

index 8373ae6f01c6e24b89ba05103c9060ef5c5aa9fe..fa45ca5736c42034ba1537155d0407d623aa3eed 100644 (file)
@@ -131,9 +131,8 @@ uint64_t pruneLockedCollectionsVector(std::vector<T>& maps)
 }
 
 template <typename S, typename C, typename T>
-uint64_t pruneMutexCollectionsVector(C& container, std::vector<T>& maps, uint64_t maxCached, uint64_t cacheSize)
+uint64_t pruneMutexCollectionsVector(time_t now, C& container, std::vector<T>& maps, uint64_t maxCached, uint64_t cacheSize)
 {
-  const time_t now = time(nullptr);
   uint64_t totErased = 0;
   uint64_t toTrim = 0;
   uint64_t lookAt = 0;
index be67da138bac3f756497279634f21a9c8c80e6ec..af6cd1fa6aa9b858993e448dc5648be250a390a1 100644 (file)
@@ -284,10 +284,10 @@ void NegCache::clear()
  *
  * \param maxEntries The maximum number of entries that may exist in the cache.
  */
-void NegCache::prune(size_t maxEntries)
+void NegCache::prune(time_t now, size_t maxEntries)
 {
   size_t cacheSize = size();
-  pruneMutexCollectionsVector<SequenceTag>(*this, d_maps, maxEntries, cacheSize);
+  pruneMutexCollectionsVector<SequenceTag>(now, *this, d_maps, maxEntries, cacheSize);
 }
 
 /*!
index 1ac2855e31f1d171d2301f4139382872ddfed1ca..86c3b562f428e3e1b636cb1c33f5bcfd3bc9c554 100644 (file)
@@ -98,7 +98,7 @@ public:
   bool getRootNXTrust(const DNSName& qname, const struct timeval& now, NegCacheEntry& ne, bool serveStale, bool refresh);
   size_t count(const DNSName& qname);
   size_t count(const DNSName& qname, QType qtype);
-  void prune(size_t maxEntries);
+  void prune(time_t now, size_t maxEntries);
   void clear();
   size_t doDump(int fd, size_t maxCacheEntries, time_t now = time(nullptr));
   size_t wipe(const DNSName& name, bool subtree = false);
index 25e6d7d74c7c7ebeae5610fa8ef02553d1fb3d23..0c9ca1cf8f8ae241e7cc8b963464f40ea4ee9053 100644 (file)
@@ -2404,18 +2404,18 @@ static void houseKeepingWork(Logr::log_t log)
   else if (info.isHandler()) {
     if (g_packetCache) {
       static PeriodicTask packetCacheTask{"packetCacheTask", 5};
-      packetCacheTask.runIfDue(now, []() {
-        g_packetCache->doPruneTo(g_maxPacketCacheEntries);
+      packetCacheTask.runIfDue(now, [now]() {
+        g_packetCache->doPruneTo(now.tv_sec, g_maxPacketCacheEntries);
       });
     }
     static PeriodicTask recordCachePruneTask{"RecordCachePruneTask", 5};
-    recordCachePruneTask.runIfDue(now, []() {
-      g_recCache->doPrune(g_maxCacheEntries);
+    recordCachePruneTask.runIfDue(now, [now]() {
+      g_recCache->doPrune(now.tv_sec, g_maxCacheEntries);
     });
 
     static PeriodicTask negCachePruneTask{"NegCachePrunteTask", 5};
-    negCachePruneTask.runIfDue(now, []() {
-      g_negCache->prune(g_maxCacheEntries / 8);
+    negCachePruneTask.runIfDue(now, [now]() {
+      g_negCache->prune(now.tv_sec, g_maxCacheEntries / 8);
     });
 
     static PeriodicTask aggrNSECPruneTask{"AggrNSECPruneTask", 5};
index 4ae3cb51704ed0731b2a3eb63405dfab5453c526..f19176a141517c93160a7af672cc24c5572fe768 100644 (file)
@@ -251,10 +251,10 @@ void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash,
   assert(map.getEntriesCount() == shard->d_map.size()); // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay): clib implementation
 }
 
-void RecursorPacketCache::doPruneTo(size_t maxSize)
+void RecursorPacketCache::doPruneTo(time_t now, size_t maxSize)
 {
   size_t cacheSize = size();
-  pruneMutexCollectionsVector<SequencedTag>(*this, d_maps, maxSize, cacheSize);
+  pruneMutexCollectionsVector<SequencedTag>(now, *this, d_maps, maxSize, cacheSize);
 }
 
 uint64_t RecursorPacketCache::doDump(int file)
index 22207068a9b4e15786cc24d5fdd915243f4c75a1..0e51cea628f0de42ceaeffa5c68b5ea61fafc427 100644 (file)
@@ -83,7 +83,7 @@ public:
   bool getResponsePacket(unsigned int tag, const std::string& queryPacket, DNSName& qname, uint16_t* qtype, uint16_t* qclass, time_t now, std::string* responsePacket, uint32_t* age, vState* valState, uint32_t* qhash, OptPBData* pbdata, bool tcp);
 
   void insertResponsePacket(unsigned int tag, uint32_t qhash, std::string&& query, const DNSName& qname, uint16_t qtype, uint16_t qclass, std::string&& responsePacket, time_t now, uint32_t ttl, const vState& valState, OptPBData&& pbdata, bool tcp);
-  void doPruneTo(size_t maxSize);
+  void doPruneTo(time_t now, size_t maxSize);
   uint64_t doDump(int file);
   uint64_t doWipePacketCache(const DNSName& name, uint16_t qtype = 0xffff, bool subtree = false);
 
index d3e434017eecc3cd6bf4e57b691db8d90fc82c2f..12067195c5e8c00c9078f0adf05db97c3725a17e 100644 (file)
 
 uint16_t MemRecursorCache::s_maxServedStaleExtensions;
 
+void MemRecursorCache::resetStaticsForTests()
+{
+  s_maxServedStaleExtensions = 0;
+  SyncRes::s_refresh_ttlperc = 0;
+  SyncRes::s_locked_ttlperc = 0;
+  SyncRes::s_minimumTTL = 0;
+}
+
 MemRecursorCache::MemRecursorCache(size_t mapsCount) :
   d_maps(mapsCount == 0 ? 1 : mapsCount)
 {
@@ -821,10 +829,10 @@ uint64_t MemRecursorCache::doDump(int fd, size_t maxCacheEntries)
   return count;
 }
 
-void MemRecursorCache::doPrune(size_t keep)
+void MemRecursorCache::doPrune(time_t now, size_t keep)
 {
   size_t cacheSize = size();
-  pruneMutexCollectionsVector<SequencedTag>(*this, d_maps, keep, cacheSize);
+  pruneMutexCollectionsVector<SequencedTag>(now, *this, d_maps, keep, cacheSize);
 }
 
 namespace boost
index 7cc2f0316c051e36d8d35e56402bec2b60138801..ccbcad2b507c96296cd4e61f054f081b82e576c6 100644 (file)
@@ -71,7 +71,7 @@ public:
 
   void replace(time_t, const DNSName& qname, const QType qt, const vector<DNSRecord>& content, const vector<shared_ptr<const RRSIGRecordContent>>& signatures, const std::vector<std::shared_ptr<DNSRecord>>& authorityRecs, bool auth, const DNSName& authZone, boost::optional<Netmask> ednsmask = boost::none, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, boost::optional<ComboAddress> from = boost::none, bool refresh = false, time_t ttl_time = time(nullptr));
 
-  void doPrune(size_t keep);
+  void doPrune(time_t now, size_t keep);
   uint64_t doDump(int fd, size_t maxCacheEntries);
 
   size_t doWipeCache(const DNSName& name, bool sub, QType qtype = 0xffff);
@@ -80,6 +80,8 @@ public:
 
   pdns::stat_t cacheHits{0}, cacheMisses{0};
 
+  static void resetStaticsForTests();
+
 private:
   struct CacheEntry
   {
index 96172d458faac144aa2ea88549b0b2d9f33dbb70..be31d1e7afeace01d3afbd44332549b28a9a28d4 100644 (file)
@@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(test_prune)
 
   BOOST_CHECK_EQUAL(cache.size(), 400U);
 
-  cache.prune(100);
+  cache.prune(now.tv_sec, 100);
 
   BOOST_CHECK_EQUAL(cache.size(), 100U);
 }
@@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(test_prune_many_shards)
 
   BOOST_CHECK_EQUAL(cache.size(), 400U);
 
-  cache.prune(100);
+  cache.prune(now.tv_sec, 100);
 
   BOOST_CHECK_EQUAL(cache.size(), 100U);
 }
@@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(test_prune_valid_entries)
 
   /* power2 has been inserted more recently, so it should be
      removed last */
-  cache.prune(1);
+  cache.prune(now.tv_sec, 1);
   BOOST_CHECK_EQUAL(cache.size(), 1U);
 
   NegCache::NegCacheEntry got;
@@ -362,7 +362,7 @@ BOOST_AUTO_TEST_CASE(test_prune_valid_entries)
 
   /* power2 has been updated more recently, so it should be
      removed last */
-  cache.prune(1);
+  cache.prune(now.tv_sec, 1);
 
   BOOST_CHECK_EQUAL(cache.size(), 1U);
   got = NegCache::NegCacheEntry();
index a3d783b0910dd954c0f1aa5d6c909edff57f108a..353407ea276f7bacb4c658fe7cb874084beb0f5b 100644 (file)
@@ -35,31 +35,32 @@ BOOST_AUTO_TEST_CASE(test_recPacketCacheSimple)
   string qpacket((const char*)&packet[0], packet.size());
   pw.startRecord(qname, QType::A, ttd);
 
-  BOOST_CHECK_EQUAL(rpc.getResponsePacket(tag, qpacket, time(nullptr), &fpacket, &age, &qhash), false);
-  BOOST_CHECK_EQUAL(rpc.getResponsePacket(tag, qpacket, qname, QType::A, QClass::IN, time(nullptr), &fpacket, &age, &qhash), false);
+  time_t now = time(nullptr);
+  BOOST_CHECK_EQUAL(rpc.getResponsePacket(tag, qpacket, now, &fpacket, &age, &qhash), false);
+  BOOST_CHECK_EQUAL(rpc.getResponsePacket(tag, qpacket, qname, QType::A, QClass::IN, now, &fpacket, &age, &qhash), false);
 
   ARecordContent ar("127.0.0.1");
   ar.toPacket(pw);
   pw.commit();
   string rpacket((const char*)&packet[0], packet.size());
 
-  rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), time(0), ttd, vState::Indeterminate, boost::none, false);
+  rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), now, ttd, vState::Indeterminate, boost::none, false);
   BOOST_CHECK_EQUAL(rpc.size(), 1U);
-  rpc.doPruneTo(0);
+  rpc.doPruneTo(now, 0);
   BOOST_CHECK_EQUAL(rpc.size(), 0U);
-  rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), time(0), ttd, vState::Indeterminate, boost::none, false);
+  rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), now, ttd, vState::Indeterminate, boost::none, false);
   BOOST_CHECK_EQUAL(rpc.size(), 1U);
   rpc.doWipePacketCache(qname);
   BOOST_CHECK_EQUAL(rpc.size(), 0U);
 
-  rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), time(0), ttd, vState::Indeterminate, boost::none, false);
+  rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), now, ttd, vState::Indeterminate, boost::none, false);
   BOOST_CHECK_EQUAL(rpc.size(), 1U);
   uint32_t qhash2 = 0;
-  bool found = rpc.getResponsePacket(tag, qpacket, time(nullptr), &fpacket, &age, &qhash2);
+  bool found = rpc.getResponsePacket(tag, qpacket, now, &fpacket, &age, &qhash2);
   BOOST_CHECK_EQUAL(found, true);
   BOOST_CHECK_EQUAL(qhash, qhash2);
   BOOST_CHECK_EQUAL(fpacket, rpacket);
-  found = rpc.getResponsePacket(tag, qpacket, qname, QType::A, QClass::IN, time(nullptr), &fpacket, &age, &qhash2);
+  found = rpc.getResponsePacket(tag, qpacket, qname, QType::A, QClass::IN, now, &fpacket, &age, &qhash2);
   BOOST_CHECK_EQUAL(found, true);
   BOOST_CHECK_EQUAL(qhash, qhash2);
   BOOST_CHECK_EQUAL(fpacket, rpacket);
@@ -73,9 +74,9 @@ BOOST_AUTO_TEST_CASE(test_recPacketCacheSimple)
   pw2.getHeader()->id = dns_random_uint16();
   qpacket.assign((const char*)&packet[0], packet.size());
 
-  found = rpc.getResponsePacket(tag, qpacket, time(nullptr), &fpacket, &age, &qhash);
+  found = rpc.getResponsePacket(tag, qpacket, now, &fpacket, &age, &qhash);
   BOOST_CHECK_EQUAL(found, false);
-  found = rpc.getResponsePacket(tag, qpacket, qname, QType::A, QClass::IN, time(nullptr), &fpacket, &age, &qhash);
+  found = rpc.getResponsePacket(tag, qpacket, qname, QType::A, QClass::IN, now, &fpacket, &age, &qhash);
   BOOST_CHECK_EQUAL(found, false);
 
   rpc.doWipePacketCache(DNSName("com"), 0xffff, true);
@@ -175,7 +176,7 @@ BOOST_AUTO_TEST_CASE(test_recPacketCacheSimplePost2038)
 
   rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), future, ttd, vState::Indeterminate, boost::none, false);
   BOOST_CHECK_EQUAL(rpc.size(), 1U);
-  rpc.doPruneTo(0);
+  rpc.doPruneTo(time(nullptr), 0);
   BOOST_CHECK_EQUAL(rpc.size(), 0U);
   rpc.insertResponsePacket(tag, qhash, string(qpacket), qname, QType::A, QClass::IN, string(rpacket), future, ttd, vState::Indeterminate, boost::none, false);
   BOOST_CHECK_EQUAL(rpc.size(), 1U);
@@ -280,7 +281,7 @@ BOOST_AUTO_TEST_CASE(test_recPacketCache_Tags)
   BOOST_CHECK_EQUAL(rpc.size(), 2U);
 
   /* remove all responses from the cache */
-  rpc.doPruneTo(0);
+  rpc.doPruneTo(time(nullptr), 0);
   BOOST_CHECK_EQUAL(rpc.size(), 0U);
 
   /* reinsert both */
@@ -393,7 +394,7 @@ BOOST_AUTO_TEST_CASE(test_recPacketCache_TCP)
   BOOST_CHECK_EQUAL(rpc.size(), 2U);
 
   /* remove all responses from the cache */
-  rpc.doPruneTo(0);
+  rpc.doPruneTo(time(nullptr), 0);
   BOOST_CHECK_EQUAL(rpc.size(), 0U);
 
   /* reinsert both */
index e456d3f11681e48827834846c2cfd244890802e7..71a05440eecb8b55da4fc2ae1341d07c0da7995d 100644 (file)
@@ -13,6 +13,7 @@ BOOST_AUTO_TEST_SUITE(recursorcache_cc)
 
 static void simple(time_t now)
 {
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC;
 
   std::vector<DNSRecord> records;
@@ -387,6 +388,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheSimpleDistantFuture)
 
 BOOST_AUTO_TEST_CASE(test_RecursorCacheGhost)
 {
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC;
 
   std::vector<DNSRecord> records;
@@ -430,6 +432,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheReplaceAuthByNonAuthMargin)
 {
   // Test #12140: as QM does a best NS lookup and then  uses it, incoming infra records should update
   // cache, otherwise they might expire in-between.
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC;
 
   std::vector<DNSRecord> records;
@@ -475,6 +478,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheReplaceAuthByNonAuthMargin)
 
 BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries)
 {
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC(1);
 
   std::vector<DNSRecord> records;
@@ -522,7 +526,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries)
   /* we ask that 10 entries remain in the cache, this is larger than
      the cache size (2), so 1 entry will be looked at as the code
      rounds up the 10% of entries per shard to look at */
-  MRC.doPrune(10);
+  MRC.doPrune(now, 10);
   BOOST_CHECK_EQUAL(MRC.size(), 1U);
 
   /* the remaining entry should be power2, but to get it
@@ -555,7 +559,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries)
   /* we ask that 10 entries remain in the cache, this is larger than
      the cache size (2), so 1 entry will be looked at as the code
      rounds up the 10% of entries per shard to look at */
-  MRC.doPrune(10);
+  MRC.doPrune(now, 10);
   BOOST_CHECK_EQUAL(MRC.size(), 1U);
 
   /* the remaining entry should be power1, but to get it
@@ -569,6 +573,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries)
 
 BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries)
 {
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC(1);
 
   std::vector<DNSRecord> records;
@@ -615,7 +620,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries)
   /* the one for power2 having been inserted
      more recently should be removed last */
   /* we ask that only entry remains in the cache */
-  MRC.doPrune(1);
+  MRC.doPrune(now, 1);
   BOOST_CHECK_EQUAL(MRC.size(), 1U);
 
   /* the remaining entry should be power2 */
@@ -649,7 +654,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries)
      to the back of the expunge queue, so power2 should be at the front
      and should this time be removed first */
   /* we ask that only entry remains in the cache */
-  MRC.doPrune(1);
+  MRC.doPrune(now, 1);
   BOOST_CHECK_EQUAL(MRC.size(), 1U);
 
   /* the remaining entry should be power1 */
@@ -681,7 +686,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries)
   /* the entry for power1 should have been moved to the back of the expunge queue
      due to the hit, so power2 should be at the front and should this time be removed first */
   /* we ask that only entry remains in the cache */
-  MRC.doPrune(1);
+  MRC.doPrune(now, 1);
   BOOST_CHECK_EQUAL(MRC.size(), 1U);
 
   /* the remaining entry should be power1 */
@@ -691,7 +696,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries)
   /* check that power2 is gone */
   BOOST_CHECK_EQUAL(MRC.get(now, power2, QType(dr2.d_type), MemRecursorCache::None, &retrieved, who, boost::none, nullptr), -1);
 
-  MRC.doPrune(0);
+  MRC.doPrune(now, 0);
   BOOST_CHECK_EQUAL(MRC.size(), 0U);
 
   /* add a lot of netmask-specific entries */
@@ -716,7 +721,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries)
 
   /* remove a bit less than half of them */
   size_t keep = 129;
-  MRC.doPrune(keep);
+  MRC.doPrune(now, keep);
   BOOST_CHECK_EQUAL(MRC.size(), keep);
   BOOST_CHECK_EQUAL(MRC.ecsIndexSize(), 1U);
 
@@ -740,13 +745,14 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries)
   BOOST_CHECK_EQUAL(found, keep);
 
   /* remove the rest */
-  MRC.doPrune(0);
+  MRC.doPrune(now, 0);
   BOOST_CHECK_EQUAL(MRC.size(), 0U);
   BOOST_CHECK_EQUAL(MRC.ecsIndexSize(), 0U);
 }
 
 BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex)
 {
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC(1);
 
   const DNSName power("powerdns.com.");
@@ -797,7 +803,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex)
   BOOST_CHECK_EQUAL(getRR<ARecordContent>(retrieved.at(0))->getCA().toString(), dr1Content.toString());
 
   /* wipe everything */
-  MRC.doPrune(0);
+  MRC.doPrune(now, 0);
   BOOST_CHECK_EQUAL(MRC.size(), 0U);
   BOOST_CHECK_EQUAL(MRC.ecsIndexSize(), 0U);
 
@@ -835,7 +841,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex)
   BOOST_CHECK_EQUAL(getRR<ARecordContent>(retrieved.at(0))->getCA().toString(), dr1Content.toString());
 
   /* wipe everything */
-  MRC.doPrune(0);
+  MRC.doPrune(now, 0);
   BOOST_CHECK_EQUAL(MRC.size(), 0U);
   BOOST_CHECK_EQUAL(MRC.ecsIndexSize(), 0U);
 
@@ -870,7 +876,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex)
   BOOST_CHECK_EQUAL(MRC.size(), 2U);
 
   /* wipe everything */
-  MRC.doPrune(0);
+  MRC.doPrune(now, 0);
   BOOST_CHECK_EQUAL(MRC.size(), 0U);
   BOOST_CHECK_EQUAL(MRC.ecsIndexSize(), 0U);
 
@@ -899,13 +905,14 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex)
   BOOST_CHECK_EQUAL(MRC.ecsIndexSize(), 1U);
 
   /* wipe everything */
-  MRC.doPrune(0);
+  MRC.doPrune(now, 0);
   BOOST_CHECK_EQUAL(MRC.size(), 0U);
   BOOST_CHECK_EQUAL(MRC.ecsIndexSize(), 0U);
 }
 
 BOOST_AUTO_TEST_CASE(test_RecursorCache_Wipe)
 {
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC;
 
   const DNSName power("powerdns.com.");
@@ -996,6 +1003,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_Wipe)
 
 BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged)
 {
+  MemRecursorCache::resetStaticsForTests();
   MemRecursorCache MRC;
 
   const DNSName authZone(".");