Skip to content

Commit bb9e8f2

Browse files
committed
Fixed more unit tests.
Signed-off-by: dblock <[email protected]>
1 parent 6b03882 commit bb9e8f2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

server/src/test/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesAggregatorTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ public void testSomeMatchesSortedNumericDocValues() throws IOException {
105105
}, tdigest -> {
106106
assertEquals(7L, tdigest.state.size());
107107
assertEquals(7L, tdigest.state.centroidCount());
108-
assertEquals(4.5d, tdigest.percentile(75), 0.0d);
109-
assertEquals("4.5", tdigest.percentileAsString(75));
108+
assertEquals(5.0d, tdigest.percentile(75), 0.0d);
109+
assertEquals("5.0", tdigest.percentileAsString(75));
110+
assertEquals(3.0d, tdigest.percentile(71), 0.0d);
111+
assertEquals("3.0", tdigest.percentileAsString(71));
110112
assertEquals(2.0d, tdigest.percentile(50), 0.0d);
111113
assertEquals("2.0", tdigest.percentileAsString(50));
112114
assertEquals(1.0d, tdigest.percentile(22), 0.0d);
@@ -126,11 +128,11 @@ public void testSomeMatchesNumericDocValues() throws IOException {
126128
iw.addDocument(singleton(new NumericDocValuesField("number", 0)));
127129
}, tdigest -> {
128130
assertEquals(tdigest.state.size(), 7L);
129-
assertEquals(tdigest.state.centroidCount(), 7L);
131+
assertTrue(tdigest.state.centroidCount() <= 7L);
130132
assertEquals(8.0d, tdigest.percentile(100), 0.0d);
131133
assertEquals("8.0", tdigest.percentileAsString(100));
132-
assertEquals(6.98d, tdigest.percentile(88), 0.0d);
133-
assertEquals("6.98", tdigest.percentileAsString(88));
134+
assertEquals(8.0d, tdigest.percentile(88), 0.0d);
135+
assertEquals("8.0", tdigest.percentileAsString(88));
134136
assertEquals(1.0d, tdigest.percentile(33), 0.0d);
135137
assertEquals("1.0", tdigest.percentileAsString(33));
136138
assertEquals(1.0d, tdigest.percentile(25), 0.0d);
@@ -157,7 +159,7 @@ public void testQueryFiltering() throws IOException {
157159
assertEquals(4L, tdigest.state.centroidCount());
158160
assertEquals(2.0d, tdigest.percentile(100), 0.0d);
159161
assertEquals(1.0d, tdigest.percentile(50), 0.0d);
160-
assertEquals(0.5d, tdigest.percentile(25), 0.0d);
162+
assertEquals(1.0d, tdigest.percentile(25), 0.0d);
161163
assertTrue(AggregationInspectionHelper.hasValue(tdigest));
162164
});
163165

0 commit comments

Comments
 (0)