[Fix] Fix flaky test OptionUtilTest.test
#5894
Merged
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.
Purpose of this pull request
The test case org.apache.seatunnel.api.configuration.util.OptionUtilTest.test fails due to the non-deterministic behavior of the function
https://github.com/ThugJudy/seatunnel/blob/b8c313045ea3301f3fa08bc46a9014a4ab9ac66f/seatunnel-api/src/main/java/org/apache/seatunnel/api/configuration/util/OptionUtil.java#L72 which does not guarantee the ordering of elements in the class object.
Due to this, the arrayList of options created does not have a definite order in every run.
I found and confirmed the flaky behavior using an open-source research tool NonDex, which shuffles implementations of nondeterminism operations.
Reproduce
The following command can be used to reproduce assertion failures and verify the fix:
Fix
Sorting the options list based on key ensures that the order of the elements is constant during the test run
https://github.com/ThugJudy/seatunnel/blob/b8c313045ea3301f3fa08bc46a9014a4ab9ac66f/seatunnel-api/src/test/java/org/apache/seatunnel/api/configuration/util/OptionUtilTest.java#L34
Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide
release-note
.