sijie commented on a change in pull request #9083:
URL: https://github.com/apache/pulsar/pull/9083#discussion_r550131324



##########
File path: 
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
##########
@@ -2140,6 +2141,28 @@ void testIndividuallyDeletedMessages3(boolean 
useOpenRangeSet) throws Exception
         assertTrue(c1.isIndividuallyDeletedEntriesEmpty());
     }
 
+    @Test(timeOut = 20000)
+    void testFindNewestMatchingAfterLedgerRollover() throws Exception {
+        ManagedLedgerImpl ledger = (ManagedLedgerImpl) 
factory.open("my_test_ledger");
+        ManagedCursorImpl c1 = (ManagedCursorImpl) ledger.openCursor("c1");
+        ledger.addEntry("expired".getBytes(Encoding));
+        ledger.addEntry("expired".getBytes(Encoding));
+        ledger.addEntry("expired".getBytes(Encoding));
+        ledger.addEntry("expired".getBytes(Encoding));
+        Position last = ledger.addEntry("expired".getBytes(Encoding));
+
+        // roll a new ledger
+        int numLedgersBefore = ledger.getLedgersInfo().size();
+        ledger.getConfig().setMaxEntriesPerLedger(1);
+        ledger.rollCurrentLedgerIfFull();
+        Awaitility.await().atMost(20, TimeUnit.SECONDS)
+                .until(() -> ledger.getLedgersInfo().size() > 
numLedgersBefore);
+
+        assertEquals(last,
+                c1.findNewestMatching(entry -> 
Arrays.equals(entry.getDataAndRelease(), "expired".getBytes(Encoding))));

Review comment:
       But you can't tell if "expired" message is the last message. Because all 
the messages have the same content.




----------------------------------------------------------------
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.

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


Reply via email to