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 tests in DocumentTest #3617

Open
wants to merge 1 commit 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

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