You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by zi...@apache.org on 2026/09/23 07:59:52 UTC

(pulsar) branch master updated: [fix][test] Fix flaky RawReaderTest.testPauseAndResumeWithUnloading (#26690)

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

nodece 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 769ce7f51c6f [fix][test] Fix flaky RawReaderTest.testPauseAndResumeWithUnloading (#26690)
769ce7f51c6f is described below

commit 769ce7f51c6f04bbd0b2043fd5bd54b16476df69
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Wed Sep 23 00:59:44 2026 -0700

    [fix][test] Fix flaky RawReaderTest.testPauseAndResumeWithUnloading (#26690)
---
 .../java/org/apache/pulsar/client/impl/RawReaderTest.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java
index 1c7add8bb626..4be215cb06b5 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/RawReaderTest.java
@@ -723,6 +723,7 @@ public class RawReaderTest extends MockedPulsarServiceBaseTest {
         consumerConfiguration.setSubscriptionType(SubscriptionType.Exclusive);
         consumerConfiguration.setReceiverQueueSize(receiverQueueSize);
         RawReader reader = RawReader.create(pulsarClient, consumerConfiguration, true, true).get();
+        waitForInitialPermits(topic, subscription, receiverQueueSize);
 
         Producer<byte[]> producer = pulsarClient.newProducer()
                 .topic(topic)
@@ -786,6 +787,7 @@ public class RawReaderTest extends MockedPulsarServiceBaseTest {
         consumerConfiguration.setSubscriptionType(SubscriptionType.Exclusive);
         consumerConfiguration.setReceiverQueueSize(receiverQueueSize);
         RawReader reader = RawReader.create(pulsarClient, consumerConfiguration, true, true).get();
+        waitForInitialPermits(topicName, subName, receiverQueueSize);
 
         reader.pause();
 
@@ -827,4 +829,14 @@ public class RawReaderTest extends MockedPulsarServiceBaseTest {
         reader.closeAsync();
         producer.close();
     }
+
+    /**
+     * The subscribe future completes before the client sends the initial flow permits, so pausing right after
+     * {@link RawReader#create} can suppress that flow and the paused reader would never receive its first
+     * {@code receiverQueueSize} messages. Wait until the broker has registered the initial permits.
+     */
+    private void waitForInitialPermits(String topic, String subscription, int permits) {
+        Awaitility.await().untilAsserted(() -> assertEquals(admin.topics().getStats(topic).getSubscriptions()
+                .get(subscription).getConsumers().get(0).getAvailablePermits(), permits));
+    }
 }