Fix nondeterministic behavior in Kafka, Kinesis, and TaskQueue-related tests #18691
+16
−4
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.
This PR fixes nondeterministic behavior in the following flaky tests:
org.apache.druid.data.input.kafkainput.KafkaInputFormatTest.testWithSchemaDiscoveryorg.apache.druid.data.input.kafkainput.KafkaInputFormatTest.testWithPartialDeclarationSchemaDiscoveryorg.apache.druid.indexing.kinesis.supervisor.KinesisSupervisorTest.testKillBadPartitionAssignmentorg.apache.druid.indexing.overlord.TaskQueueTest.testGetActiveTaskRedactsPasswordDescription
The
KafkaInputFormatTest.testWithSchemaDiscoveryandKafkaInputFormatTest.testWithPartialDeclarationSchemaDiscoverytests failed intermittently due to nondeterministic ordering of discovered schema dimensions.These tests check that Kafka input parsing discovers all schema fields. However, field names were collected from unordered structures, causing inconsistent dimension order and intermittent assertion failures.
Failure messages:
Proposed Changes:
The
KinesisSupervisorTest.testKillBadPartitionAssignmentfailed intermittently due to nondeterministic ordering of task entries.The test verifies that the Kinesis supervisor correctly identifies and terminates invalid task assignments. Since task metadata was stored in a
HashMap, iteration order varied between runs, causing inconsistent comparisons of task IDs and flaky assertions.Failure messages:
Proposed Changes:
The
TaskQueueTest.testGetActiveTaskRedactsPasswordfailed intermittently due to inconsistent JSON key ordering in serialized task payloads.The test ensures that sensitive information (like passwords) is properly redacted when serializing active task metadata. However, since JSON objects do not preserve field order, direct string comparison caused false failures when the same data appeared with keys in different order.
Failure messages:
Proposed Changes:
This PR has: