Skip to content

[fix][test] Fix flaky ManagedLedgerTest.testNoRetention#25467

Merged
nodece merged 1 commit intoapache:masterfrom
merlimat:fix/flaky-ManagedLedgerTest-testNoRetention
Apr 7, 2026
Merged

[fix][test] Fix flaky ManagedLedgerTest.testNoRetention#25467
nodece merged 1 commit intoapache:masterfrom
merlimat:fix/flaky-ManagedLedgerTest-testNoRetention

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

@merlimat merlimat commented Apr 3, 2026

Motivation

ManagedLedgerTest.testNoRetention is flaky because it relies on Thread.sleep(1000) for the async ledger trimming to complete, which is not always sufficient.

Stack trace

ManagedLedgerTest > testNoRetention FAILED
    java.lang.AssertionError: expected [true] but found [false]
        at org.testng.Assert.fail(Assert.java:110)
        at org.testng.Assert.failNotEquals(Assert.java:1577)
        at org.testng.Assert.assertTrue(Assert.java:56)
        at org.testng.Assert.assertTrue(Assert.java:66)
        at ManagedLedgerTest.testNoRetention(ManagedLedgerTest.java:2316)

Modifications

Replace Thread.sleep(1000) with explicit trimConsumedLedgersInBackground(CompletableFuture) + join() to deterministically wait for ledger trimming to complete before asserting.

Documentation

  • doc-not-needed

Replace unreliable Thread.sleep(1000) with explicit
trimConsumedLedgersInBackground + CompletableFuture.join() to
deterministically wait for ledger trimming to complete.
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 3, 2026
@nodece nodece merged commit 8d9d497 into apache:master Apr 7, 2026
44 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/test doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants