oneby-wang opened a new pull request, #25144:
URL: https://github.com/apache/pulsar/pull/25144

   ### Motivation
   
   Fix `ManagedLedgerTest.testLockReleaseWhenTrimLedger()` flaky test.
   
   This test has the following problems:
   1. The test doesn't wait for new ledger created, so 
`assertEquals(ledger.ledgers.size() - 1, entries)` or 
`assertEquals(ledger.ledgerCache.size() - 1, entries - 1)` may be flaky, see 
code comments.
   
   ```
   java.lang.AssertionError:
   Expected :10
   Actual   :9
   <Click to see difference>
        at org.testng.Assert.fail(Assert.java:110)
        at org.testng.Assert.failNotEquals(Assert.java:1577)
        at org.testng.Assert.assertEqualsImpl(Assert.java:149)
        at org.testng.Assert.assertEquals(Assert.java:131)
        at org.testng.Assert.assertEquals(Assert.java:1418)
        at org.testng.Assert.assertEquals(Assert.java:1382)
        at org.testng.Assert.assertEquals(Assert.java:1428)
        at 
org.apache.bookkeeper.mledger.impl.ManagedLedgerTest.testLockReleaseWhenTrimLedger(ManagedLedgerTest.java:3982)
   ```
   
   2. The test spies an instance that contains volatile fields, which also 
cause flakiness, see PR comments below.
   
   ### Modifications
   
   1. Waiting for new ledger created to avoid flaky test.
   2. Use overriding instead of spying to avoid flaky test.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] 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
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/oneby-wang/pulsar/pull/24


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to