diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java index adbaf2b72a9..97ae487dc4a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudPivotFacet.java @@ -81,6 +81,11 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + // because floating point addition can depende on the order of operations, we ignore + // any stats that can be lossy -- the purpose of testing stats here is just to sanity check + // that the basic hooks between pivot faceting and stats.field work, and these let us do that + private static final String USE_STATS = "count=true missing=true min=true max=true"; + // param used by test purely for tracing & validation private static String TRACE_MIN = "_test_min"; // param used by test purely for tracing & validation @@ -110,8 +115,6 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase { //commented 2-Aug-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 28-June-2018 public void test() throws Exception { - sanityCheckAssertNumerics(); - waitForThingsToLevelOut(30000); // TODO: why would we have to wait? // handle.clear(); @@ -141,7 +144,6 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase { final String[] fieldNames = fieldNameSet.toArray(new String[fieldNameSet.size()]); Arrays.sort(fieldNames); // need determinism when picking random fields - for (int i = 0; i < 5; i++) { String q = "*:*"; @@ -161,11 +163,11 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase { // if we are doing stats, then always generated the same # of STATS_FIELD // params, using multiple tags from a fixed set, but with diff fieldName values. // later, each pivot will randomly pick a tag. - baseP.add(StatsParams.STATS_FIELD, "{!key=sk1 tag=st1,st2}" + + baseP.add(StatsParams.STATS_FIELD, "{!key=sk1 tag=st1,st2 "+USE_STATS+"}" + pickRandomStatsFields(fieldNames)); - baseP.add(StatsParams.STATS_FIELD, "{!key=sk2 tag=st2,st3}" + + baseP.add(StatsParams.STATS_FIELD, "{!key=sk2 tag=st2,st3 "+USE_STATS+"}" + pickRandomStatsFields(fieldNames)); - baseP.add(StatsParams.STATS_FIELD, "{!key=sk3 tag=st3,st4}" + + baseP.add(StatsParams.STATS_FIELD, "{!key=sk3 tag=st3,st4 "+USE_STATS+"}" + pickRandomStatsFields(fieldNames)); // NOTE: there's a chance that some of those stats field names // will be the same, but if so, all the better to test that edge case @@ -387,21 +389,18 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase { // regular stats, compare everything... assert actualStats != null; - String msg = " of " + statsKey + " => " + message; + try { + String msg = " of " + statsKey; + + // no wiggle room, these should always be exactly equals, regardless of field type + assertEquals("Count" + msg, pivotStats.getCount(), actualStats.getCount()); + assertEquals("Missing" + msg, pivotStats.getMissing(), actualStats.getMissing()); + assertEquals("Min" + msg, pivotStats.getMin(), actualStats.getMin()); + assertEquals("Max" + msg, pivotStats.getMax(), actualStats.getMax()); - // no wiggle room, these should always be exactly equals, regardless of field type - assertEquals("Count" + msg, pivotStats.getCount(), actualStats.getCount()); - assertEquals("Missing" + msg, pivotStats.getMissing(), actualStats.getMissing()); - assertEquals("Min" + msg, pivotStats.getMin(), actualStats.getMin()); - assertEquals("Max" + msg, pivotStats.getMax(), actualStats.getMax()); - - // precision loss can affect these in some field types depending on shards used - // and the order that values are accumulated - assertNumerics("Sum" + msg, pivotStats.getSum(), actualStats.getSum()); - assertNumerics("Mean" + msg, pivotStats.getMean(), actualStats.getMean()); - assertNumerics("Stddev" + msg, pivotStats.getStddev(), actualStats.getStddev()); - assertNumerics("SumOfSquares" + msg, - pivotStats.getSumOfSquares(), actualStats.getSumOfSquares()); + } catch (AssertionError e) { + throw new AssertionError("Stats: Pivot[" + pivotStats + "] <==> Actual[" + actualStats + "] => " + message, e); + } } } @@ -690,147 +689,6 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase { assertEquals(msg, expected, response.getResults().getNumFound()); } - /** - * Given two objects returned as stat values asserts that they are they are either both null - * or all of the following are true: - *