Fixed the flaky test testSerdeWithInputFormat by sorting the result #17325
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.
Fixed a flaky test in
org.apache.druid.indexing.kafka.supervisor.KafkaSupervisorSpecTest.testSerdeWithInputFormat
Steps to reproduce
To reproduce the problem, first build the module
kafka-indexing-service
:Then, run the regular test:
To identify the flaky test, execute the following nondex command:
Description
The testSerdeWithInputFormat was producing non-deterministic output because the JSON object used in the test did not include a parser that enforced a specific order, unlike other tests. Due to the inherent non-deterministic nature of JSON serialization, this resulted in inconsistent outputs. The fix involves sorting the serialized JSON to ensure a consistent order.
sortJsonNode
- This function is the sort function to sort the objectNode and arrayNode inside the Json object.sortArrayNode
- This function is called to sort the arrayNode.sortJsonString
- Deserializes JsonString to JsonNode , sorts it and serializes it back to JsonString.The sortJsonString function can now be directly used to sort the serialized Json ,which will ensure a deterministic order for all tests where the serialized Json gives a non deterministic order.
Functions added in this PR
sortJsonNode
sortArrayNode
sortJsonString
This PR has: