diff --git a/muted-tests.yml b/muted-tests.yml index 8d88797f11ae9..1e720de27a3e0 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -435,15 +435,9 @@ tests: - class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT method: test {csv-spec:spatial_shapes.ConvertFromStringParseError} issue: https://github.com/elastic/elasticsearch/issues/134254 -- class: org.elasticsearch.xpack.esql.expression.function.scalar.score.DecayTests - method: "testEvaluateBlockWithNulls {TestCase=, , , <_source> #11}" - issue: https://github.com/elastic/elasticsearch/issues/134447 - class: org.elasticsearch.action.admin.cluster.state.TransportClusterStateActionTests method: testGetClusterStateWithDefaultProjectOnly issue: https://github.com/elastic/elasticsearch/issues/134450 -- class: org.elasticsearch.xpack.esql.expression.function.scalar.score.DecayTests - method: "testEvaluateBlockWithNulls {TestCase=, , , <_source> #11}" - issue: https://github.com/elastic/elasticsearch/issues/134509 - class: org.elasticsearch.xpack.esql.plugin.CanMatchIT method: testAliasFilters issue: https://github.com/elastic/elasticsearch/issues/134512 @@ -468,9 +462,6 @@ tests: - class: org.elasticsearch.aggregations.bucket.AggregationReductionCircuitBreakingIT method: testCBTrippingOnReduction issue: https://github.com/elastic/elasticsearch/issues/134667 -- class: org.elasticsearch.xpack.esql.expression.function.scalar.score.DecayTests - method: "testEvaluateBlockWithNulls {TestCase=, , , <_source> #2}" - issue: https://github.com/elastic/elasticsearch/issues/134679 - class: org.elasticsearch.xpack.esql.ccq.MultiClusterSpecIT method: test {csv-spec:fork.ForkBeforeStatsByWithWhere} issue: https://github.com/elastic/elasticsearch/issues/134817 @@ -522,12 +513,6 @@ tests: - class: org.elasticsearch.search.sort.FieldSortIT method: testSortMixedFieldTypes issue: https://github.com/elastic/elasticsearch/issues/129445 -- class: org.elasticsearch.xpack.esql.expression.function.scalar.score.DecayTests - method: "testEvaluateInManyThreads {TestCase=, , , <_source> #17}" - issue: https://github.com/elastic/elasticsearch/issues/135357 -- class: org.elasticsearch.xpack.esql.expression.function.scalar.score.DecayTests - method: "testEvaluateBlockWithoutNulls {TestCase=, , , <_source> #12}" - issue: https://github.com/elastic/elasticsearch/issues/135394 - class: org.elasticsearch.gradle.TestClustersPluginFuncTest method: override jdk usage via ES_JAVA_HOME for known jdk os incompatibilities issue: https://github.com/elastic/elasticsearch/issues/135413 diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java index c68896b13884d..4c99021c450d6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java @@ -21,8 +21,11 @@ import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase; import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier; +import org.hamcrest.Matcher; import org.junit.BeforeClass; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; @@ -666,7 +669,7 @@ private static List intRandomTestCases() { ), startsWith("DecayIntEvaluator["), DataType.DOUBLE, - closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult)) + decayValueMatcher(scoreScriptNumericResult) ); })); } @@ -740,7 +743,7 @@ private static List longRandomTestCases() { ), startsWith("DecayLongEvaluator["), DataType.DOUBLE, - equalTo(scoreScriptNumericResult) + decayValueMatcher(scoreScriptNumericResult) ); })); } @@ -810,7 +813,7 @@ private static List doubleRandomTestCases() { ), startsWith("DecayDoubleEvaluator["), DataType.DOUBLE, - closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult)) + decayValueMatcher(scoreScriptNumericResult) ); })); } @@ -908,7 +911,7 @@ private static List geoPointRandomTestCases() { ), startsWith("DecayGeoPointEvaluator["), DataType.DOUBLE, - closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult)) + decayValueMatcher(scoreScriptNumericResult) ); })); } @@ -1087,7 +1090,7 @@ private static List datetimeRandomTestCases() { ), startsWith("DecayDatetimeEvaluator["), DataType.DOUBLE, - closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult)) + decayValueMatcher(scoreScriptNumericResult) ); })); } @@ -1174,7 +1177,7 @@ private static List dateNanosRandomTestCases() { ), startsWith("DecayDateNanosEvaluator["), DataType.DOUBLE, - closeTo(scoreScriptNumericResult, 1e-10) + decayValueMatcher(scoreScriptNumericResult) ); }) ); @@ -1229,4 +1232,12 @@ private static MapExpression createOptionsMap(Object offset, Double decay, Strin return new MapExpression(Source.EMPTY, keyValuePairs); } + + private static Matcher decayValueMatcher(Double value) { + if (value == Double.POSITIVE_INFINITY || value == Double.NEGATIVE_INFINITY) { + return equalTo(value); + } + + return closeTo(BigDecimal.valueOf(value).setScale(4, RoundingMode.CEILING).doubleValue(), 0.001); + } }