From bb9e8f2076d1063e9431e19a722841ae81642620 Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 21 Jun 2022 19:50:49 +0000 Subject: [PATCH] Fixed more unit tests. Signed-off-by: dblock --- .../metrics/TDigestPercentilesAggregatorTests.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java index 50415dc10df7e..fd98a090367b2 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java @@ -105,8 +105,10 @@ public void testSomeMatchesSortedNumericDocValues() throws IOException { }, tdigest -> { assertEquals(7L, tdigest.state.size()); assertEquals(7L, tdigest.state.centroidCount()); - assertEquals(4.5d, tdigest.percentile(75), 0.0d); - assertEquals("4.5", tdigest.percentileAsString(75)); + assertEquals(5.0d, tdigest.percentile(75), 0.0d); + assertEquals("5.0", tdigest.percentileAsString(75)); + assertEquals(3.0d, tdigest.percentile(71), 0.0d); + assertEquals("3.0", tdigest.percentileAsString(71)); assertEquals(2.0d, tdigest.percentile(50), 0.0d); assertEquals("2.0", tdigest.percentileAsString(50)); assertEquals(1.0d, tdigest.percentile(22), 0.0d); @@ -126,11 +128,11 @@ public void testSomeMatchesNumericDocValues() throws IOException { iw.addDocument(singleton(new NumericDocValuesField("number", 0))); }, tdigest -> { assertEquals(tdigest.state.size(), 7L); - assertEquals(tdigest.state.centroidCount(), 7L); + assertTrue(tdigest.state.centroidCount() <= 7L); assertEquals(8.0d, tdigest.percentile(100), 0.0d); assertEquals("8.0", tdigest.percentileAsString(100)); - assertEquals(6.98d, tdigest.percentile(88), 0.0d); - assertEquals("6.98", tdigest.percentileAsString(88)); + assertEquals(8.0d, tdigest.percentile(88), 0.0d); + assertEquals("8.0", tdigest.percentileAsString(88)); assertEquals(1.0d, tdigest.percentile(33), 0.0d); assertEquals("1.0", tdigest.percentileAsString(33)); assertEquals(1.0d, tdigest.percentile(25), 0.0d); @@ -157,7 +159,7 @@ public void testQueryFiltering() throws IOException { assertEquals(4L, tdigest.state.centroidCount()); assertEquals(2.0d, tdigest.percentile(100), 0.0d); assertEquals(1.0d, tdigest.percentile(50), 0.0d); - assertEquals(0.5d, tdigest.percentile(25), 0.0d); + assertEquals(1.0d, tdigest.percentile(25), 0.0d); assertTrue(AggregationInspectionHelper.hasValue(tdigest)); });