Skip to content

Commit 5df50df

Browse files
Merge branch 'main' into ironscales-add_ilm_delete_index
2 parents 1bf0130 + 29398f3 commit 5df50df

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,6 @@ tests:
420420
- class: org.elasticsearch.xpack.security.authc.jwt.JwtRealmAuthenticateTests
421421
method: testJwkUpdatesByReloadWithFile
422422
issue: https://github.com/elastic/elasticsearch/issues/138397
423-
- class: org.elasticsearch.compute.data.ExponentialHistogramBlockTests
424-
method: testComponentAccess
425-
issue: https://github.com/elastic/elasticsearch/issues/138399
426423

427424
# Examples:
428425
#

x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/mapper/ExponentialHistogramParserTests.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,31 @@ public class ExponentialHistogramParserTests extends ESTestCase {
3535
private static final String TEST_FIELD_NAME = "test_field";
3636

3737
public void testParseRandomHistogram() throws IOException {
38-
ExponentialHistogram histogram = ExponentialHistogramTestUtils.randomHistogram();
38+
for (int i = 0; i < 20; i++) {
39+
ExponentialHistogram histogram = ExponentialHistogramTestUtils.randomHistogram();
3940

40-
ExponentialHistogramParser.ParsedExponentialHistogram parsed;
41-
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
42-
ExponentialHistogramXContent.serialize(builder, histogram);
43-
String json = Strings.toString(builder);
44-
parsed = doParse(json);
45-
}
41+
ExponentialHistogramParser.ParsedExponentialHistogram parsed;
42+
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
43+
ExponentialHistogramXContent.serialize(builder, histogram);
44+
String json = Strings.toString(builder);
45+
parsed = doParse(json);
46+
}
4647

47-
List<IndexWithCount> expectedPositiveBuckets = IndexWithCount.fromIterator(histogram.positiveBuckets().iterator());
48-
List<IndexWithCount> expectedNegativeBuckets = IndexWithCount.fromIterator(histogram.negativeBuckets().iterator());
48+
List<IndexWithCount> expectedPositiveBuckets = IndexWithCount.fromIterator(histogram.positiveBuckets().iterator());
49+
List<IndexWithCount> expectedNegativeBuckets = IndexWithCount.fromIterator(histogram.negativeBuckets().iterator());
4950

50-
assertThat(parsed.scale(), equalTo(histogram.scale()));
51+
assertThat(parsed.scale(), equalTo(histogram.scale()));
5152

52-
assertThat(parsed.zeroThreshold(), equalTo(histogram.zeroBucket().zeroThreshold()));
53-
assertThat(parsed.zeroCount(), equalTo(histogram.zeroBucket().count()));
53+
assertThat(parsed.zeroThreshold(), equalTo(histogram.zeroBucket().zeroThreshold()));
54+
assertThat(parsed.zeroCount(), equalTo(histogram.zeroBucket().count()));
5455

55-
assertThat(parsed.positiveBuckets(), equalTo(expectedPositiveBuckets));
56-
assertThat(parsed.negativeBuckets(), equalTo(expectedNegativeBuckets));
56+
assertThat(parsed.positiveBuckets(), equalTo(expectedPositiveBuckets));
57+
assertThat(parsed.negativeBuckets(), equalTo(expectedNegativeBuckets));
5758

58-
assertThat(parsed.sum(), equalTo(histogram.sum()));
59-
assertThat(parsed.min(), equalTo(Double.isNaN(histogram.min()) ? null : histogram.min()));
60-
assertThat(parsed.max(), equalTo(Double.isNaN(histogram.max()) ? null : histogram.max()));
59+
assertThat(parsed.sum(), equalTo(histogram.valueCount() == 0 ? null : histogram.sum()));
60+
assertThat(parsed.min(), equalTo(Double.isNaN(histogram.min()) ? null : histogram.min()));
61+
assertThat(parsed.max(), equalTo(Double.isNaN(histogram.max()) ? null : histogram.max()));
62+
}
6163
}
6264

6365
public void testParseScaleMissing() {

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/ExponentialHistogramBlockTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@ public void testComponentAccess() {
9595
}
9696
}
9797
case SUM -> {
98-
assertThat(componentBlock.getValueCount(i), equalTo(1));
99-
int valueIndex = componentBlock.getFirstValueIndex(i);
100-
assertThat(((DoubleBlock) componentBlock).getDouble(valueIndex), equalTo(histo.sum()));
98+
if (histo.valueCount() == 0) {
99+
assertThat(componentBlock.isNull(i), equalTo(true));
100+
} else {
101+
assertThat(componentBlock.getValueCount(i), equalTo(1));
102+
int valueIndex = componentBlock.getFirstValueIndex(i);
103+
assertThat(((DoubleBlock) componentBlock).getDouble(valueIndex), equalTo(histo.sum()));
104+
}
101105
}
102106
case COUNT -> {
103107
assertThat(componentBlock.getValueCount(i), equalTo(1));

0 commit comments

Comments
 (0)