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

Fix flaky test in testApproximateRangeWithSizeOverDefault by adjusting totalHits assertion logic #16433

Closed
wants to merge 2 commits into from

Conversation

inpink
Copy link
Contributor

@inpink inpink commented Oct 22, 2024

Description

This PR addresses an issue in the testApproximateRangeWithSizeOverDefault method of ApproximatePointRangeQueryTests, where the test would occasionally fail due to how Lucene handles total hits.
By default, search() in Lucene's IndexSearcher provides an accurate count for up to 1000 hits.
Beyond this threshold, Lucene may return a lower bound using GREATER_THAN_OR_EQUAL_TO for performance reasons (refer to the Lucene IndexSearcher documentation.)

In testApproximateRangeWithSizeOverDefault, the search range includes 12,001 documents, and the test would sometimes fail when GREATER_THAN_OR_EQUAL_TO occurred during the search.

Changes:

  • If totalHits.relation is EQUAL_TO, the test checks for an exact count of 11000.
  • If totalHits.relation is GREATER_THAN_OR_EQUAL_TO, the test ensures the hits are no less than 11000 and within the upper bound (maxHits).

This issue is similar to OpenSearch PR #4270. I resolved it in a similar way. Special thanks to @dbwiddis for the valuable guidance.

Related Issues

Related #15807

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

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.

…tasks index (opensearch-project#16060)

- Fixed issue where `.tasks` index failed to update due to StrictDynamicMappingException when a task was cancelled.
- Added missing `cancellation_time_millis` and `resource_stats` fields to `task-index-mapping.json`.
- Ensured proper task result storage by updating the mappings.
- Changed the version in the meta field from 4 to 5 to reflect the updated mappings.

Signed-off-by: inpink <inpink@kakao.com>
…ing totalHits assertion logic

- Updated the test to account for Lucene's behavior where `IndexSearcher.search()` may return `GREATER_THAN_OR_EQUAL_TO` for totalHits when the number of matches exceeds 1000.
- Added logic to check if `totalHits.relation` is `EQUAL_TO`. If so, assert that the count is exactly 11000. Otherwise, ensure the count is at least 11000 and within the allowed upper limit (`maxHits`).
- This change prevents intermittent test failures caused by Lucene’s performance optimizations.
@inpink
Copy link
Contributor Author

inpink commented Oct 22, 2024

I have reopened this under #16434.

Copy link
Contributor

❌ Gradle check result for ac01491: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant