]> granicus.if.org Git - pdns/commitdiff
dnsdist tests: avoid failure on not-so-optimal distribution
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Tue, 3 Apr 2018 07:55:35 +0000 (09:55 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 20 Apr 2018 16:48:54 +0000 (18:48 +0200)
(cherry picked from commit d54864b1b0bd670722cf70a3e58d230aaab3a14a)

pdns/dnsdistdist/test-dnsdistrings_cc.cc

index c98016c729315d3d13c980f72835d37f77c9cae7..db6d7c4b9b06cad3e64535ab414bfa92c7f1f622 100644 (file)
@@ -222,15 +222,18 @@ BOOST_AUTO_TEST_CASE(test_Rings_Threaded) {
   BOOST_CHECK_EQUAL(rings.getNumberOfShards(), numberOfShards);
   BOOST_CHECK_EQUAL(rings.d_shards.size(), rings.getNumberOfShards());
   BOOST_CHECK_LE(rings.getNumberOfQueryEntries(), numberOfEntries);
-  BOOST_CHECK_GT(rings.getNumberOfQueryEntries(), numberOfEntries * 0.99);
+  BOOST_WARN_GT(rings.getNumberOfQueryEntries(), numberOfEntries * 0.99);
   BOOST_CHECK_LE(rings.getNumberOfResponseEntries(), numberOfEntries);
-  BOOST_CHECK_GT(rings.getNumberOfResponseEntries(), numberOfEntries * 0.99);
+  BOOST_WARN_GT(rings.getNumberOfResponseEntries(), numberOfEntries * 0.99);
 
   size_t totalQueries = 0;
   size_t totalResponses = 0;
   for (const auto& shard : rings.d_shards) {
     BOOST_CHECK_LE(shard->queryRing.size(), entriesPerShard);
-    BOOST_CHECK_GT(shard->queryRing.size(), entriesPerShard * 0.95);
+    // verify that the shard is not empty
+    BOOST_CHECK_GT(shard->queryRing.size(), (entriesPerShard * 0.5) + 1);
+    // this would be optimal
+    BOOST_WARN_GT(shard->queryRing.size(), entriesPerShard * 0.95);
     totalQueries += shard->queryRing.size();
     for (const auto& entry : shard->queryRing) {
       BOOST_CHECK_EQUAL(entry.name, qname);
@@ -240,7 +243,10 @@ BOOST_AUTO_TEST_CASE(test_Rings_Threaded) {
       BOOST_CHECK_EQUAL(entry.requestor.toStringWithPort(), requestor.toStringWithPort());
     }
     BOOST_CHECK_LE(shard->respRing.size(), entriesPerShard);
-    BOOST_CHECK_GT(shard->respRing.size(), entriesPerShard * 0.95);
+    // verify that the shard is not empty
+    BOOST_CHECK_GT(shard->queryRing.size(), (entriesPerShard * 0.5) + 1);
+    // this would be optimal
+    BOOST_WARN_GT(shard->respRing.size(), entriesPerShard * 0.95);
     totalResponses += shard->respRing.size();
     for (const auto& entry : shard->respRing) {
       BOOST_CHECK_EQUAL(entry.name, qname);