opensearch-project/OpenSearch

[Feature Request] support tolerance in yaml rest test

Aperta

#18.213 aperta il 6 mag 2025

 (4 commenti) (1 reazione) (1 assegnatario)Java (1505 fork)batch import
Otherenhancementgood first issue

Metriche repository

Star
 (8123 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor