Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests] Test utils update to fix IT tests for serverless #2869

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

manasvinibs
Copy link
Member

@manasvinibs manasvinibs commented Jul 29, 2024

Description

  1. Rounding difference between test results when run with different sources - added 2 digit precision round of for the failing tests. Sample test failure -
Expected: (a collection containing [-6.12])
     but: a collection containing [-6.12] mismatches were: [was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>, was <[-6.119999999999999]>]
	at __randomizedtesting.SeedInfo.seed([B1A9C07A3606A61E:6E333FC43A7C1CD3]:0)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at org.opensearch.sql.util.MatcherUtils.verifySome(MatcherUtils.java:192)
	at org.opensearch.sql.sql.AggregationIT.testAvgDoubleInMemory(AggregationIT.java:461)
  1. Score Differences between test results when run with different data sources if one of the data source contains multiple shards and OpenSearch assumes to be run against single shard - skipped asserting on score part of the address array in the response as results can be different for different data sources and is expected behavior.
java.lang.AssertionError: 
Expected: iterable with items [[305 Powell Street, 6.501515]] in any order
     but: not matched: <["305 Powell Street",4.414816]>
	at __randomizedtesting.SeedInfo.seed([B1A9C07A3606A61E:726F6D646D7EFC49]:0)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at org.opensearch.sql.util.MatcherUtils.verify(MatcherUtils.java:173)
	at org.opensearch.sql.util.MatcherUtils.verifyDataRows(MatcherUtils.java:149)
	at org.opensearch.sql.sql.ScoreQueryCloudNativeIT.scoreQueryDefaultBoostQueryTest(ScoreQueryIT.java:106)
  1. Retrying the index creation without refresh policy in the request URL for tests when it is not supported by API. Tests shouldn't fail as it is expected behavior.
java.lang.IllegalStateException: Failed to perform request
	at __randomizedtesting.SeedInfo.seed([B1A9C07A3606A61E:D3800B42483A3073]:0)
	at org.opensearch.sql.util.TestUtils.performRequest(TestUtils.java:124)
	at org.opensearch.sql.sql.IdentifierIT$Index.addDocHelper(IdentifierIT.java:287)
	at org.opensearch.sql.sql.IdentifierIT.createIndexWithOneDoc(IdentifierIT.java:242)
	at org.opensearch.sql.sql.IdentifierIT.testIndexNames(IdentifierIT.java:34)

at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.opensearch.client.ResponseException: method [PUT], host [https://ruh7jos10anqd6bsp844.beta-us-east-1.aoss.amazonaws.com], URI [/logs/_doc/1?refresh=true], status line [HTTP/1.1 400 Bad Request]
{"error":{"root_cause":[{"type":"status_exception","reason":"true refresh policy is not supported."}],"type":"status_exception","reason":"true refresh policy is not supported."},"status":400}
	at app//org.opensearch.client.RestClient.convertResponse(RestClient.java:376)

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@@ -772,6 +779,29 @@ public static String getResponseBody(Response response, boolean retainNewLines)
return sb.toString();
}

// TODO: this is temporary fix for fixing serverless tests to pass with 2 digit precision value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any thoughts on what should be long term fix for this and other temp fixes? Also, should we create issues to track long term fix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya I can check with serverless team on this and see if we need a issue to track the long term fix.

rupal-bq
rupal-bq previously approved these changes Aug 1, 2024
@@ -123,6 +118,18 @@ public static Response performRequest(RestClient client, Request request) {
}
return response;
} catch (IOException e) {
if (e instanceof ResponseException
&& ((ResponseException) e).getResponse().getStatusLine().getStatusCode() == 400
&& e.getMessage().contains("true refresh policy is not supported.")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it safe to match with message? If there is no other way, that's fine as it is test code, but error message tends to be easily changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into specific exception we get for refresh policy related error. But today its wrapped as ResponseException. I think I need to have this check to make sure I'm retrying exactly for the refresh issue only. As it is a test code, if there are message updates on the exception, tests would fail and we might have to adjust the message here for that in future.

@@ -123,6 +118,18 @@ public static Response performRequest(RestClient client, Request request) {
}
return response;
} catch (IOException e) {
if (e instanceof ResponseException
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we remove the refresh policy when it is requesting collection from the beginning?

Copy link
Member Author

@manasvinibs manasvinibs Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the URL with refresh policy token is set during @before setup or during client connection. I see we have few tests which adds this token within test files before submitting query like this: https://github.com/opensearch-project/sql/blob/main/integ-test/src/test/java/org/opensearch/sql/sql/IdentifierIT.java#L245 All those tests rely on this test util function, so I thought of adding the retry here.

Signed-off-by: Manasvini B S <manasvis@amazon.com>
@ykmr1224 ykmr1224 merged commit 7e73f12 into opensearch-project:main Aug 5, 2024
14 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 5, 2024
Signed-off-by: Manasvini B S <manasvis@amazon.com>
(cherry picked from commit 7e73f12)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
manasvinibs added a commit to manasvinibs/sql that referenced this pull request Aug 14, 2024
…2869)

Signed-off-by: Manasvini B S <manasvis@amazon.com>
jzonthemtn pushed a commit to jzonthemtn/sql that referenced this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants