diff --git a/muted-tests.yml b/muted-tests.yml index b5cadd72fa12f..b4f2035d62709 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -420,9 +420,6 @@ tests: - class: org.elasticsearch.xpack.security.authc.jwt.JwtRealmAuthenticateTests method: testJwkUpdatesByReloadWithFile issue: https://github.com/elastic/elasticsearch/issues/138397 -- class: org.elasticsearch.compute.data.ExponentialHistogramBlockTests - method: testComponentAccess - issue: https://github.com/elastic/elasticsearch/issues/138399 # Examples: # diff --git a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/ExponentialHistogramParserTests.java b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/ExponentialHistogramParserTests.java index 3c48e06c71760..664cce981f049 100644 --- a/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/ExponentialHistogramParserTests.java +++ b/x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/ExponentialHistogramParserTests.java @@ -35,29 +35,31 @@ public class ExponentialHistogramParserTests extends ESTestCase { private static final String TEST_FIELD_NAME = "test_field"; public void testParseRandomHistogram() throws IOException { - ExponentialHistogram histogram = ExponentialHistogramTestUtils.randomHistogram(); + for (int i = 0; i < 20; i++) { + ExponentialHistogram histogram = ExponentialHistogramTestUtils.randomHistogram(); - ExponentialHistogramParser.ParsedExponentialHistogram parsed; - try (XContentBuilder builder = XContentFactory.jsonBuilder()) { - ExponentialHistogramXContent.serialize(builder, histogram); - String json = Strings.toString(builder); - parsed = doParse(json); - } + ExponentialHistogramParser.ParsedExponentialHistogram parsed; + try (XContentBuilder builder = XContentFactory.jsonBuilder()) { + ExponentialHistogramXContent.serialize(builder, histogram); + String json = Strings.toString(builder); + parsed = doParse(json); + } - List expectedPositiveBuckets = IndexWithCount.fromIterator(histogram.positiveBuckets().iterator()); - List expectedNegativeBuckets = IndexWithCount.fromIterator(histogram.negativeBuckets().iterator()); + List expectedPositiveBuckets = IndexWithCount.fromIterator(histogram.positiveBuckets().iterator()); + List expectedNegativeBuckets = IndexWithCount.fromIterator(histogram.negativeBuckets().iterator()); - assertThat(parsed.scale(), equalTo(histogram.scale())); + assertThat(parsed.scale(), equalTo(histogram.scale())); - assertThat(parsed.zeroThreshold(), equalTo(histogram.zeroBucket().zeroThreshold())); - assertThat(parsed.zeroCount(), equalTo(histogram.zeroBucket().count())); + assertThat(parsed.zeroThreshold(), equalTo(histogram.zeroBucket().zeroThreshold())); + assertThat(parsed.zeroCount(), equalTo(histogram.zeroBucket().count())); - assertThat(parsed.positiveBuckets(), equalTo(expectedPositiveBuckets)); - assertThat(parsed.negativeBuckets(), equalTo(expectedNegativeBuckets)); + assertThat(parsed.positiveBuckets(), equalTo(expectedPositiveBuckets)); + assertThat(parsed.negativeBuckets(), equalTo(expectedNegativeBuckets)); - assertThat(parsed.sum(), equalTo(histogram.sum())); - assertThat(parsed.min(), equalTo(Double.isNaN(histogram.min()) ? null : histogram.min())); - assertThat(parsed.max(), equalTo(Double.isNaN(histogram.max()) ? null : histogram.max())); + assertThat(parsed.sum(), equalTo(histogram.valueCount() == 0 ? null : histogram.sum())); + assertThat(parsed.min(), equalTo(Double.isNaN(histogram.min()) ? null : histogram.min())); + assertThat(parsed.max(), equalTo(Double.isNaN(histogram.max()) ? null : histogram.max())); + } } public void testParseScaleMissing() { diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/ExponentialHistogramBlockTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/ExponentialHistogramBlockTests.java index 9b9c96bce33df..4136d7a1b7900 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/ExponentialHistogramBlockTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/ExponentialHistogramBlockTests.java @@ -95,9 +95,13 @@ public void testComponentAccess() { } } case SUM -> { - assertThat(componentBlock.getValueCount(i), equalTo(1)); - int valueIndex = componentBlock.getFirstValueIndex(i); - assertThat(((DoubleBlock) componentBlock).getDouble(valueIndex), equalTo(histo.sum())); + if (histo.valueCount() == 0) { + assertThat(componentBlock.isNull(i), equalTo(true)); + } else { + assertThat(componentBlock.getValueCount(i), equalTo(1)); + int valueIndex = componentBlock.getFirstValueIndex(i); + assertThat(((DoubleBlock) componentBlock).getDouble(valueIndex), equalTo(histo.sum())); + } } case COUNT -> { assertThat(componentBlock.getValueCount(i), equalTo(1));