Fix flaky test in testApproximateRangeWithSizeOverDefault by adjusting totalHits assertion logic#16433
Closed
inpink wants to merge 2 commits into
Closed
Fix flaky test in testApproximateRangeWithSizeOverDefault by adjusting totalHits assertion logic#16433inpink wants to merge 2 commits into
inpink wants to merge 2 commits into
Conversation
…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.
Contributor
Author
|
I have reopened this under #16434. |
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses an issue in the
testApproximateRangeWithSizeOverDefaultmethod ofApproximatePointRangeQueryTests, where the test would occasionally fail due to how Lucene handles total hits.By default,
search()in Lucene'sIndexSearcherprovides 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 whenGREATER_THAN_OR_EQUAL_TOoccurred during the search.Changes:
EQUAL_TO, the test checks for an exact count of 11000.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
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.