This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new fe84bdb3f32 [fix][test] Stabilize SequenceIdWithErrorTest by fencing 
after first publish to avoid empty-ledger deletion and send timeout (#24861)
fe84bdb3f32 is described below

commit fe84bdb3f325d1ee22e2cb961d100fc59bad1b83
Author: sinan liu <[email protected]>
AuthorDate: Fri Oct 17 17:11:04 2025 +0800

    [fix][test] Stabilize SequenceIdWithErrorTest by fencing after first 
publish to avoid empty-ledger deletion and send timeout (#24861)
    
    (cherry picked from commit b0ce575b537d495b157cf651153f8845b72cce3d)
---
 .../pulsar/client/impl/SequenceIdWithErrorTest.java       | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/SequenceIdWithErrorTest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/SequenceIdWithErrorTest.java
index 7d330bb82ad..67cd2a58007 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/SequenceIdWithErrorTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/SequenceIdWithErrorTest.java
@@ -22,6 +22,7 @@ import static org.testng.Assert.assertEquals;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import java.util.Collections;
+import java.util.concurrent.TimeUnit;
 import lombok.Cleanup;
 import org.apache.bookkeeper.mledger.ManagedLedger;
 import org.apache.bookkeeper.mledger.ManagedLedgerFactory;
@@ -55,6 +56,13 @@ public class SequenceIdWithErrorTest extends 
BkEnsemblesTestBase {
         Consumer<String> consumer = 
client.newConsumer(Schema.STRING).topic(topicName).subscriptionName("sub")
                 .subscribe();
 
+        // Create a producer
+        Producer<String> producer = 
client.newProducer(Schema.STRING).topic(topicName).create();
+        // Move the fence timing to after the first message is successfully 
written
+        // The current ledger is not empty, the Broker recovery will not take 
the abnormal path of
+        // "deleting empty ledger + unable to find old ledger"
+        producer.send("Hello-0");
+
         // Fence the topic by opening the ManagedLedger for the topic outside 
the Pulsar broker. This will cause the
         // broker to fail subsequent send operation and it will trigger a 
recover
         EventLoopGroup eventLoopGroup = new NioEventLoopGroup(1);
@@ -66,15 +74,12 @@ public class SequenceIdWithErrorTest extends 
BkEnsemblesTestBase {
         ml.close();
         clientFactory.close();
 
-        // Create a producer
-        Producer<String> producer = 
client.newProducer(Schema.STRING).topic(topicName).create();
-
-        for (int i = 0; i < N; i++) {
+        for (int i = 1; i < N; i++) {
             producer.send("Hello-" + i);
         }
 
         for (int i = 0; i < N; i++) {
-            Message<String> msg = consumer.receive();
+            Message<String> msg = consumer.receive(10, TimeUnit.SECONDS);
             assertEquals(msg.getValue(), "Hello-" + i);
             assertEquals(msg.getSequenceId(), i);
             consumer.acknowledge(msg);

Reply via email to