merlimat opened a new pull request, #25561:
URL: https://github.com/apache/pulsar/pull/25561
### Motivation
`OffloadPrefixTest.testPositionOnEdgeOfLedger` is flaky. The test writes
exactly 20 entries with `maxEntriesPerLedger=10`, which fills two ledgers. Once
the second ledger is full, it is closed and a third (empty) ledger starts being
created asynchronously on the managed-ledger executor. The test's next line
asserts that only 2 ledgers exist — this races with the async rollover and the
test intermittently fails with a third ledger already present.
#### Example failure
```
Gradle suite > Gradle test >
org.apache.bookkeeper.mledger.impl.OffloadPrefixTest >
testPositionOnEdgeOfLedger FAILED
java.lang.AssertionError: expected [2] but found [3]
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.OffloadPrefixTest.testPositionOnEdgeOfLedger(OffloadPrefixTest.java:237)
```
- Failure scan:
https://scans.gradle.com/s/5uzx6ammf6lko/tests/task/:managed-ledger:test/details/org.apache.bookkeeper.mledger.impl.OffloadPrefixTest/testPositionOnEdgeOfLedger/2/output
- Failure scan:
https://scans.gradle.com/s/lqkj2fztrznro/tests/task/:managed-ledger:test/details/org.apache.bookkeeper.mledger.impl.OffloadPrefixTest/testPositionOnEdgeOfLedger/2/output
### Modifications
Replace the hard-coded `assertEquals(size, 2)` with an `Awaitility.await()`
that waits for the 3-ledger steady state (l1 full, l2 full, l3 empty). The rest
of the test (`getLastConfirmedEntry` returning the last entry of l2, then
`addEntry("entry-blah")` being stored in l3, then the two `offloadPrefix`
calls) already works correctly against this stable state, so no other changes
are required.
### Verifying this change
- [x] Make sure that the change passes the CI checks.
This change is already covered by existing tests, such as
`OffloadPrefixTest.testPositionOnEdgeOfLedger`.
### 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]