opensearch-project/OpenSearch

[Feature Request] support tolerance in yaml rest test

Open

#18 213 ouverte le 6 mai 2025

Voir sur GitHub
 (4 commentaires) (1 réaction) (1 assigné)Java (1 505 forks)batch import
Otherenhancementgood first issue

Métriques du dépôt

Stars
 (8 123 stars)
Métriques de merge PR
 (Merge moyen 5j 9h) (266 PRs mergées en 30 j)

Description

Is your feature request related to a problem? Please describe

It would be better if we can support tolerance/delta when matching a value in yaml rest test

For example, to add a delta on this match

  • match: {aggregations.mfs.fields.2.correlation.val2: 0.9569513137793205}

I need to write in this way

  • gte: {aggregations.mfs.fields.2.correlation.val2: 0.956951313779319}
  • lte: {aggregations.mfs.fields.2.correlation.val2: 0.956951313779321}

https://github.com/opensearch-project/OpenSearch/commit/4a92aa4e14f9db8887499b11765e0c5b375cfc20

Describe the solution you'd like

I see JUnit provides this assertEquals(double expected, double actual, double delta), so we probably can do similar thing in yaml rest test

  • match: {<matching_field>: <match_value>, epsilon: <delta_value>}

In my previous example, this will be

  • match: {aggregations.mfs.fields.2.correlation.val2: 0.9569513137793205, epsilon: 0.000000000000001}

This syntax is better to understand the real intention. Related class to enhance is MatchAssertion.java

Related component

Other

Describe alternatives you've considered

No response

Additional context

No response

Guide contributeur