Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-13898: Allow inexact double comparison. Close resources.

Andrzej Bialecki66e78ba7c567
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolrCachePerf.java b/solr/core/src/test/org/apache/solr/search/TestSolrCachePerf.java
index 1dc3ca66d20..cc9cf736f0e 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolrCachePerf.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolrCachePerf.java
@@ -69,11 +69,20 @@ public class TestSolrCachePerf extends SolrTestCaseJ4 {
}
computeRatio.forEach((type, computeStats) -> {
SummaryStatistics getPutStats = getPutRatio.get(type);
- assertTrue("compute ratio (" + computeStats.getMean() + ") should be higher or equal from get/put ("
- + getPutStats.getMean() + ")", computeStats.getMean() >= getPutStats.getMean());
+ assertGreaterThanOrEqual( "Compute ratio should be higher or equal to get/put ratio", computeStats.getMean(), getPutStats.getMean(), 0.0001);
});
}
+ private void assertGreaterThanOrEqual(String message, double greater, double smaller, double delta) {
+ if (greater > smaller) {
+ return;
+ } else {
+ if (Math.abs(greater - smaller) > delta) {
+ fail(message + ": " + greater + " >= " + smaller);
+ }
+ }
+ }
+
static final String VALUE = "foo";
private void doTestGetPutCompute(Map<String, SummaryStatistics> ratioStats, Map<String, SummaryStatistics> timeStats, int numThreads, boolean useCompute) throws Exception {
@@ -135,6 +144,7 @@ public class TestSolrCachePerf extends SolrTestCaseJ4 {
perImplRatio.addValue(
Double.parseDouble(String.valueOf(metrics.get("CACHE.foo.hitratio"))));
perImplTime.addValue((double)(stopTime - startTime));
+ cache.close();
}
}
}