fix(java): Stabilize async consumer group test#3697
Conversation
Handle transient `IggyResourceNotFoundException` during concurrent join/leave operations in `AsyncConsumerGroupsTest`. This adds bounded retry/backoff helpers and waits for the expected member count before asserting, reducing flakiness from eventually consistent consumer-group state.
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
|
/ready |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3697 +/- ##
=========================================
Coverage 74.34% 74.34%
Complexity 950 950
=========================================
Files 1303 1303
Lines 148712 148712
Branches 124225 124224 -1
=========================================
+ Hits 110562 110565 +3
Misses 34673 34673
+ Partials 3477 3474 -3
🚀 New features to boost your workflow:
|
slbotbm
left a comment
There was a problem hiding this comment.
other than one comment, lgtm, but let's wait for maciek to approve
| CompletableFuture.allOf( | ||
| client.consumerGroups().leaveConsumerGroup(STREAM_ID, TOPIC_ID, groupId), | ||
| secondClient.consumerGroups().leaveConsumerGroup(STREAM_ID, TOPIC_ID, groupId), | ||
| thirdClient.consumerGroups().leaveConsumerGroup(STREAM_ID, TOPIC_ID, groupId)) | ||
| .get(TIMEOUT_SECONDS * 2, TimeUnit.SECONDS); | ||
|
|
||
| // then | ||
| ConsumerGroupDetails afterLeave = client.consumerGroups() | ||
| .getConsumerGroup(STREAM_ID, TOPIC_ID, groupId) | ||
| .get(TIMEOUT_SECONDS, TimeUnit.SECONDS) | ||
| .get(); | ||
| assertThat(afterLeave.membersCount()).isEqualTo(0); | ||
| retryOnTransientNotFound( | ||
| () -> CompletableFuture.allOf( | ||
| client.consumerGroups().leaveConsumerGroup(STREAM_ID, TOPIC_ID, groupId), | ||
| secondClient.consumerGroups().leaveConsumerGroup(STREAM_ID, TOPIC_ID, groupId), | ||
| thirdClient.consumerGroups().leaveConsumerGroup(STREAM_ID, TOPIC_ID, groupId)) | ||
| .get(TIMEOUT_SECONDS * 2, TimeUnit.SECONDS), | ||
| TRANSIENT_RETRY_TIMEOUT, | ||
| TRANSIENT_RETRY_BACKOFF); | ||
| awaitMembersCount(groupId, 0); |
There was a problem hiding this comment.
Here, if one leave succeeds while another returns IggyResourceNotFoundException, retry resubmits all three leaves. Already-successful client now returns “member not found,” so every later attempt fails. Helper eventually times out even if member count reaches zero. This defeats exact flaky case being fixed.
fix: Treat “already left” as success, retry clients individually, or tolerate leave exceptions and use awaitMembersCount(groupId, 0) as final condition.
Fixes flakiness in the Java SDK async consumer-group integration test for concurrent join/leave operations. The change adds bounded retry handling for transient not-found errors and waits for the consumer-group membership count to converge before asserting, making the test more stable without changing its intent.
Handle transient
IggyResourceNotFoundExceptionduring concurrent join/leave operations inAsyncConsumerGroupsTest. This adds bounded retry/backoff helpers and waits for the expected member count before asserting, reducing flakiness from eventually consistent consumer-group state.Which issue does this PR address?
Closes # 3641
Relates to # pr=3515
Rationale
To address the flaky java tests.
What changed?
This PR stabilizes a flaky Java SDK integration test covering concurrent consumer-group join and leave operations.
The test previously asserted consumer-group state immediately after concurrent operations completed. In some runs, transient IggyResourceNotFoundException errors or short propagation delays caused intermittent failures even though the underlying behavior was correct.
Changes in this PR
add retry handling around concurrent joinConsumerGroup calls
add retry handling around concurrent leaveConsumerGroup calls
retry only for transient IggyResourceNotFoundException cases
wait until the consumer group reaches the expected member count before asserting
extract shared helper methods for retry and polling behavior
add reusable timeout and backoff constants for transient-state handling
Why
Concurrent async operations can briefly observe unstable or not-yet-visible consumer-group state. This PR makes the test robust to those short-lived conditions while preserving the original behavior being verified.
Impact
improves reliability of the Java SDK integration test suite
reduces intermittent failures in consumer-group concurrency coverage
limits scope to test code only
Reviewer-focused summary
Primary goal: eliminate flaky failures in AsyncConsumerGroupsTest
Approach: add bounded retry logic for transient not-found errors and poll for expected membership state
Scope: test-only change in the Java SDK
Risk: low, since production code is unchanged
Behavioral effect: assertions are now based on eventual stable state rather than immediate visibility after concurrent operations
Local Execution
AI Usage
If AI tools were used, please answer: