Skip to content

Commit ffa7d8f

Browse files
committed
[fix][broker] Add ManagedCursorTest.testMarkDeletePreviousLacManyTimesInRolloverScenario test
1 parent 6304ffc commit ffa7d8f

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6170,6 +6170,31 @@ public void markDeleteComplete(Object ctx) {
61706170
}
61716171
}
61726172

6173+
@Test(timeOut = 20000)
6174+
void testMarkDeletePreviousLacManyTimesInRolloverScenario() throws Exception {
6175+
ManagedLedgerConfig config = new ManagedLedgerConfig();
6176+
config.setMaxEntriesPerLedger(1);
6177+
// Set retention in order to not trim ledger.
6178+
config.setRetentionTime(20, TimeUnit.SECONDS);
6179+
config.setRetentionSizeInMB(1);
6180+
6181+
ManagedLedgerImpl ledger =
6182+
(ManagedLedgerImpl) factory.open("testMarkDeletePreviousLacManyTimesInRolloverScenario", config);
6183+
ManagedCursorImpl cursor = (ManagedCursorImpl) ledger.openCursor("c1");
6184+
6185+
Position position = ledger.addEntry("entry1".getBytes(Encoding));
6186+
6187+
// Wait for new ledger created.
6188+
Awaitility.await().untilAsserted(() -> assertThat(ledger.getLedgersInfo().size()).isEqualTo(2));
6189+
6190+
int markDeleteTimes = 10;
6191+
for (int i = 0; i < markDeleteTimes; i++) {
6192+
cursor.markDelete(position);
6193+
}
6194+
6195+
assertThat(cursor.getMarkDeletedPosition()).isGreaterThan(position);
6196+
}
6197+
61736198
class TestPulsarMockBookKeeper extends PulsarMockBookKeeper {
61746199
Map<Long, Integer> ledgerErrors = new HashMap<>();
61756200

0 commit comments

Comments
 (0)