Skip to content

Fix flaky tests in DocumentTest #3617

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

219sansim
Copy link

Description

There are 2 tests in the DocumentTest.java class which call the DocumentTest.toString method, this method converts a Map object to a string, which is not in any particular order, the tests may pass or fail even though the code under test may be working as expected.
https://github.com/219sansim/jedis/blob/c1cc657e8b3a984aab8779f84aa0ff55c2b29118/src/main/java/redis/clients/jedis/search/Document.java#L23
To resolve the bug, I changed the code to check for both possible orderings.

Another possible fix could be to check if the string contains both the fields.

Reproduction of error

Run maven tests with NonDex tool

mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=redis.clients.jedis.modules.search.DocumentTest#toStringTest
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=redis.clients.jedis.modules.search.DocumentTest#serialize

Error Output
Showing error output of test serialize

[ERROR] Failures: 
[ERROR]   DocumentTest.serialize:45 expected:<...: 10.0, properties:[[string=c, float=12.0]]> but was:<...: 10.0, properties:[[float=12.0, string=c]]>

After making the changes, the tests pass with NonDex tool

@ggivo ggivo self-requested a review May 28, 2025 06:40
Copy link
Collaborator

@ggivo ggivo left a comment

Choose a reason for hiding this comment

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

Thanks for taking time reporting & fixing it
LGTM

ggivo
ggivo previously approved these changes May 28, 2025
@ggivo ggivo added this to the 6.1.0 milestone May 28, 2025
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.

2 participants