[fix][test] Fix flaky ConsumedLedgersTrimTest.testAdminTrimLedgers#25360
Merged
lhotari merged 1 commit intoapache:masterfrom Mar 19, 2026
Merged
Conversation
Two issues causing flakiness: 1. Fixed producer name "producer-name" causes timeout when running with invocationCount>1 because the previous invocation's partitioned producer may not have fully disconnected yet. Fix: remove the fixed producerName so each invocation gets a unique auto-generated name. 2. The assertion expects exactly 1 ledger after trim, but with maxEntriesPerLedger=2, if partition-0 receives an even number of messages, the last ledger is full and a new empty active ledger is created. After trimming, 2 ledgers remain: one with the last confirmed entry and the empty active ledger. Fix: assert <= 2 instead of == 1. 3. The trim operation is async. The admin.topics().trimTopic() call returns immediately but the actual ledger deletion happens in the background. The mark-delete position may not be persisted yet when the first trim runs. Fix: re-trigger trimConsumedLedgersInBackground() inside the Awaitility loop.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #25360 +/- ##
============================================
+ Coverage 72.73% 72.75% +0.02%
+ Complexity 34264 33876 -388
============================================
Files 1954 1954
Lines 154792 154792
Branches 17731 17731
============================================
+ Hits 112586 112622 +36
+ Misses 33170 33157 -13
+ Partials 9036 9013 -23
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
lhotari
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Flaky test failure
Also reproduces as producer timeout when running with invocationCount>1.
Summary
Follow-up to #25342. Three issues causing flakiness:
Fixed producer name
"producer-name"causes 30s timeout when running withinvocationCount>1because the previous invocation's partitioned producer (3 sub-producers) may not have fully disconnected yet, and the new producer with the same name waits for the old one.producerNameso each invocation gets a unique auto-generated name.Assertion too strict — expects exactly 1 ledger after trim, but with
maxEntriesPerLedger=2, if partition-0 receives an even number of messages, the last ledger is full and a new empty active ledger is created. After trimming, 2 ledgers remain.<= 2instead of== 1.Trim is async —
admin.topics().trimTopic()returns immediately but the actual ledger deletion happens in the background. The mark-delete position may not be persisted yet when the first trim runs.trimConsumedLedgersInBackground()inside the Awaitility loop.Documentation
doc-not-needed(Your PR doesn't need any doc update)
Matching PR in forked repository
No response
Tip
Add the labels
ready-to-testandarea/testto trigger the CI.