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

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


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

commit b0ce575b537d495b157cf651153f8845b72cce3d
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)
---
 .../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 896bf32ad37..2e73080b60d 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
@@ -23,6 +23,7 @@ import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.opentelemetry.api.OpenTelemetry;
 import java.util.Collections;
+import java.util.concurrent.TimeUnit;
 import lombok.Cleanup;
 import org.apache.bookkeeper.mledger.ManagedLedger;
 import org.apache.bookkeeper.mledger.ManagedLedgerFactory;
@@ -56,6 +57,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);
@@ -67,15 +75,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 < num; i++) {
+        for (int i = 1; i < num; i++) {
             producer.send("Hello-" + i);
         }
 
         for (int i = 0; i < num; 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