You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "315157973 (via GitHub)" <gi...@apache.org> on 2023/06/27 11:36:46 UTC

[GitHub] [pulsar] 315157973 commented on a diff in pull request #20457: [fix][broker] Fix return the earliest position when query position by timestamp.

315157973 commented on code in PR #20457:
URL: https://github.com/apache/pulsar/pull/20457#discussion_r1243591933


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentMessageFinderTest.java:
##########
@@ -243,6 +243,43 @@ public void findEntryFailed(ManagedLedgerException exception, Optional<Position>
         factory.shutdown();
     }
 
+    @Test
+    void testPersistentMessageFinderWhenLastMessageDelete() throws Exception {
+        final String ledgerAndCursorName = "testPersistentMessageFinderWhenLastMessageDelete";
+
+        ManagedLedgerConfig config = new ManagedLedgerConfig();
+        config.setRetentionSizeInMB(10);
+        config.setMaxEntriesPerLedger(10);
+        config.setRetentionTime(1, TimeUnit.HOURS);
+        ManagedLedger ledger = factory.open(ledgerAndCursorName, config);
+        ManagedCursorImpl cursor = (ManagedCursorImpl) ledger.openCursor(ledgerAndCursorName);
+
+        ledger.addEntry(createMessageWrittenToLedger("msg1"));
+        Thread.sleep(100);
+        ledger.addEntry(createMessageWrittenToLedger("msg2"));
+        Thread.sleep(100);
+        ledger.addEntry(createMessageWrittenToLedger("msg3"));
+        Thread.sleep(100);

Review Comment:
   Why we need sleep here, and what we are waiting for ? How can you ensure that it was finished after 100 ms, if we can't, there will be a flaky test



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentMessageFinderTest.java:
##########
@@ -243,6 +243,43 @@ public void findEntryFailed(ManagedLedgerException exception, Optional<Position>
         factory.shutdown();
     }
 
+    @Test
+    void testPersistentMessageFinderWhenLastMessageDelete() throws Exception {
+        final String ledgerAndCursorName = "testPersistentMessageFinderWhenLastMessageDelete";
+
+        ManagedLedgerConfig config = new ManagedLedgerConfig();
+        config.setRetentionSizeInMB(10);
+        config.setMaxEntriesPerLedger(10);
+        config.setRetentionTime(1, TimeUnit.HOURS);
+        ManagedLedger ledger = factory.open(ledgerAndCursorName, config);
+        ManagedCursorImpl cursor = (ManagedCursorImpl) ledger.openCursor(ledgerAndCursorName);
+
+        ledger.addEntry(createMessageWrittenToLedger("msg1"));
+        Thread.sleep(100);
+        ledger.addEntry(createMessageWrittenToLedger("msg2"));
+        Thread.sleep(100);
+        ledger.addEntry(createMessageWrittenToLedger("msg3"));
+        Thread.sleep(100);

Review Comment:
   Why we need sleep here, and what we are waiting for ? How can you ensure that it was finished after 100 ms, if we can't, there will be a flaky test



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