You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/04/09 17:44:25 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #6700: Improve backlogSize stats in the topic.

merlimat commented on a change in pull request #6700: Improve backlogSize stats in the topic.
URL: https://github.com/apache/pulsar/pull/6700#discussion_r406370954
 
 

 ##########
 File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminApiTest.java
 ##########
 @@ -2424,4 +2424,30 @@ public void testTopicStatsLastExpireTimestampForSubscription() throws PulsarAdmi
 
         Assert.assertTrue(admin.topics().getStats(topic).subscriptions.values().iterator().next().lastExpireTimestamp > 0L);
     }
+
+    @Test
+    public void testBacklogSizeShouldBeZeroWhenConsumerAckedAllMessages() throws Exception {
+        final String topic = "persistent://prop-xyz/ns1/testBacklogSizeShouldBeZeroWhenConsumerAckedAllMessages";
+        Consumer<byte[]> consumer = pulsarClient.newConsumer()
+                .topic(topic)
+                .subscriptionName("sub-1")
+                .subscribe();
+        Producer<byte[]> producer = pulsarClient.newProducer()
+                .topic(topic)
+                .create();
+
+        for (int i = 0; i < 33; i++) {
+            producer.send(new byte[1024 * i * 5]);
+        }
+
+        for (int i = 0; i < 33; i++) {
+            consumer.acknowledgeCumulative(consumer.receive());
+        }
+
+        // Wait ack send
+        Thread.sleep(1000);
+
+        TopicStats topicStats = admin.topics().getStats(topic);
+        System.out.println(topicStats.backlogSize);
 
 Review comment:
   The test should assert here instead of printing. Also make sure it's more robust against race conditions

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services