You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lhotari (via GitHub)" <gi...@apache.org> on 2026/04/08 19:53:07 UTC

[PR] [fix][test] Fix flaky ManagedLedgerTest.testNoRetention and testInvalidateReadHandleWhenDeleteLedger [pulsar]

lhotari opened a new pull request, #25495:
URL: https://github.com/apache/pulsar/pull/25495

   Fixes #25109
   
   ### Motivation
   
   Fix two flaky tests in `ManagedLedgerTest`:
   
   - **`testNoRetention`**: The `trimConsumedLedgersInBackground` call may be deferred when the managed ledger is in `CreatingLedger` state (due to an ongoing ledger roll after `addEntry`). A single trim+join was not sufficient because the trim could complete as a no-op if deferred trimming hadn't finished yet.
   
   - **`testInvalidateReadHandleWhenDeleteLedger`**: With `maxEntriesPerLedger=1`, adding 3 entries triggers 3 ledger rolls. The last roll may not have completed by the time `readEntries` is called, causing the last entry to be read directly from `currentLedger` (not via `ledgerCache`). This results in `ledgerCache` having only 2 entries instead of the expected 3.
   
   ### Modifications
   
   - **`testNoRetention`**: Use Awaitility to repeatedly trigger trimming and verify the assertions, ensuring the test waits for the async trimming to fully complete regardless of ledger roll state.
   
   - **`testInvalidateReadHandleWhenDeleteLedger`**: Wait for all ledger rolls to complete (`ledger.ledgers.size() == 4`) before reading entries, so that all reads go through `ledgerCache` as expected.
   
   - Both tests include `@Test(invocationCount = 10)` to verify stability.
   
   ### Verifying this change
   
   This change is already covered by existing tests. Both tests were run with `invocationCount = 10` (20 total invocations) and passed consistently.
   
   ### Does this pull request potentially affect one of the following parts:
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix][test] Fix flaky ManagedLedgerTest.testNoRetention and testInvalidateReadHandleWhenDeleteLedger [pulsar]

Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat merged PR #25495:
URL: https://github.com/apache/pulsar/pull/25495


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org