fix: Fix three nondeterministic tests caused by shard processing and JSON key ordering #1537
+7
−5
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.
📢 Type of change
📜 Description
This pull request updates three tests that were failing under NonDex due to relying on ordering that is not guaranteed:
KinesisMessageDrivenChannelAdapterTests.resharding: The test previously assumed a specific shard key, which depended on the order in which shards were processed. Under NonDex, this ordering can change. The assertion is updated to accept either of the two expected shard keys (closedEmptyShard5,closedShard4).SnsBodyBuilderTests.snsBodyBuilder: The test previously asserted equality against a concrete JSON string. When the JSON object fields are emitted in a different order (e.g.,"sms"before"default"), the string changes. The assertion is updated to check structure and required fields without enforcing key order.SnsMessageHandlerTests.snsMessageHandler: Similar toSnsBodyBuilderTests.snsBodyBuilder, this test previously asserted exact string equality on the JSON body. The assertion is updated to verify content while allowing either key order.💡 Motivation and Context
These three tests were relying on ordering that is not guaranteed by the underlying platform, which NonDex exposes as non-deterministic behavior.
In
KinesisMessageDrivenChannelAdapterTests.resharding, the test assumed a single shard key, even though the resharding logic can legitimately end with either of two closed shards depending on iteration order. This caused intermittent failures under NonDex despite both outcomes being correct.In
SnsBodyBuilderTests.snsBodyBuilderandSnsMessageHandlerTests.snsMessageHandler, the assertions compared JSON payloads using exact string equality. Since JSON object key order is not guaranteed, the tests failed when"sms"appeared before"default", even though the message content was identical.By:
"default"and"sms"fields (without enforcing key order),this PR removes hidden ordering assumptions and makes the tests deterministic while still validating the intended behavior.
💚 How did you test it?
Run NonDex on
<ModulePath>using the following commands:Replace
<ModulePath>with the correspondingpackageName.ClassName#methodName:📝 Checklist
🔮 Next steps