From 9e76b301d3777e6cc7501a48401f878379aa493f Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Tue, 3 Apr 2018 09:55:35 +0200 Subject: [PATCH] dnsdist tests: avoid failure on not-so-optimal distribution (cherry picked from commit d54864b1b0bd670722cf70a3e58d230aaab3a14a) --- pdns/dnsdistdist/test-dnsdistrings_cc.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pdns/dnsdistdist/test-dnsdistrings_cc.cc b/pdns/dnsdistdist/test-dnsdistrings_cc.cc index c98016c72..db6d7c4b9 100644 --- a/pdns/dnsdistdist/test-dnsdistrings_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistrings_cc.cc @@ -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); -- 2.40.0