opensearch-project/OpenSearch

[Feature Request] support tolerance in yaml rest test

Open

#18.213 geöffnet am 6. Mai 2025

Auf GitHub ansehen
 (4 Kommentare) (1 Reaktion) (1 zugewiesene Person)Java (1.505 Forks)batch import
Otherenhancementgood first issue

Repository-Metriken

Stars
 (8.123 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5T 9h) (266 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide