KAFKA-19481: Fix flaky test testConsumerGroupHeartbeatWithRegex #20298
+4
−2
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.
Description
This change fixes the flaky test testConsumerGroupHeartbeatWithRegex, which fails with the following log. Develocity link
org.opentest4j.AssertionFailedError: Unexpected assignment ConsumerGroupHeartbeatResponseData(throttleTimeMs=0, errorCode=0, errorMessage=null, memberId='OGfeiEjOQbqUTsJgtGMCdQ', memberEpoch=1, heartbeatIntervalMs=5000, assignment=null) ==> expected: not <null>
I addressed the issue by using
TestUtils.tryUntilNoAssertionError()
to allow for retries.Root Cause:
The failure occurs because the test depends on an async operation,
refreshRegularExpressions
, withinGroupMetadataManager
, which may not complete running before assertion runs.memberEpoch=1
because when this test successful runsmemberEpoch=2
at end. Initially updated from epoch 0 -> 1 here. OncerefreshRegularExpressions
is done,handleRegularExpressionsResult
updates epoch from 1 -> 2 hererefreshRegularExpressions
is responsible for resolving regular expression based subscriptions to the current set of matching topic names in the cluster.Testing
for i in {1..100}; do echo "Run #$i"; ./gradlew :core:integrationTest --rerun-tasks --tests kafka.api.AuthorizerIntegrationTest.testConsumerGroupHeartbeatWithRegex; if [ $? -ne 0 ]; then echo "Test failed on run #$i"; exit 1; fi; done; echo "All 100 runs passed successfully."
Note:
I ran this 100 times locally, but was unable to reproduce the same error. Only way I was able to reproduce was by adding a sleep of a second to async call then got the same exact error.