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 2021/05/27 07:43:19 UTC

[GitHub] [pulsar] eolivelli opened a new pull request #10723: Add explicit test case for NonDurable Subscriptions and Broker restart

eolivelli opened a new pull request #10723:
URL: https://github.com/apache/pulsar/pull/10723


   Add new tests cases that cover broker restart and Non Durable Subscriptions:
   - test all subscription types with NonDurable subscription mode
   - test the case of broker restart


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



[GitHub] [pulsar] sijie commented on a change in pull request #10723: Add explicit test case for NonDurable Subscriptions and Broker restart

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #10723:
URL: https://github.com/apache/pulsar/pull/10723#discussion_r640891367



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
##########
@@ -126,4 +129,63 @@ public void testDeleteInactiveNonPersistentSubscription() throws Exception {
         assertNull(nonPersistentSubscription);
 
     }
+
+    @DataProvider(name = "subscriptionTypes")
+    public static Object[][] subscriptionTypes() {
+        Object[][] result = new Object[SubscriptionType.values().length][];
+        int i = 0;
+        for (SubscriptionType type : SubscriptionType.values()) {
+            result[i++] = new Object[] {type};
+        }
+        return result;
+    }
+
+    @Test(dataProvider = "subscriptionTypes")
+    public void testNonDurableSubscriptionRecovery(SubscriptionType subscriptionType) throws Exception {
+        log.info("testing {}", subscriptionType);
+        String topicName = "persistent://my-property/my-ns/nonDurable-sub-recorvery-"+subscriptionType;
+        // 1 setup producer、consumer
+        @Cleanup
+        Producer<String> producer = pulsarClient.newProducer(Schema.STRING).topic(topicName)
+                .create();
+        @Cleanup
+        Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topicName)
+                .subscriptionMode(SubscriptionMode.NonDurable)
+                .subscriptionType(subscriptionType)
+                .subscriptionName("my-nonDurable-subscriber")
+                .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
+                .subscribe();
+        // 2 send messages
+        int messageNum = 15;
+        for (int i = 0; i < messageNum; i++) {
+            producer.send("message" + i);
+        }
+        // 3 receive the first 5 messages
+        for (int i = 0; i < 5; i++) {
+            Message<String> message = consumer.receive(1, TimeUnit.SECONDS);

Review comment:
       any reason why we can't use `receive`?

##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
##########
@@ -126,4 +129,63 @@ public void testDeleteInactiveNonPersistentSubscription() throws Exception {
         assertNull(nonPersistentSubscription);
 
     }
+
+    @DataProvider(name = "subscriptionTypes")
+    public static Object[][] subscriptionTypes() {
+        Object[][] result = new Object[SubscriptionType.values().length][];
+        int i = 0;
+        for (SubscriptionType type : SubscriptionType.values()) {
+            result[i++] = new Object[] {type};
+        }
+        return result;
+    }
+
+    @Test(dataProvider = "subscriptionTypes")
+    public void testNonDurableSubscriptionRecovery(SubscriptionType subscriptionType) throws Exception {
+        log.info("testing {}", subscriptionType);
+        String topicName = "persistent://my-property/my-ns/nonDurable-sub-recorvery-"+subscriptionType;
+        // 1 setup producer、consumer
+        @Cleanup
+        Producer<String> producer = pulsarClient.newProducer(Schema.STRING).topic(topicName)
+                .create();
+        @Cleanup
+        Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topicName)
+                .subscriptionMode(SubscriptionMode.NonDurable)
+                .subscriptionType(subscriptionType)
+                .subscriptionName("my-nonDurable-subscriber")
+                .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
+                .subscribe();
+        // 2 send messages
+        int messageNum = 15;
+        for (int i = 0; i < messageNum; i++) {
+            producer.send("message" + i);
+        }
+        // 3 receive the first 5 messages
+        for (int i = 0; i < 5; i++) {
+            Message<String> message = consumer.receive(1, TimeUnit.SECONDS);
+            assertNotNull(message);
+            Assert.assertEquals(message.getValue(), "message" + i);
+            consumer.acknowledge(message);
+        }
+        // 4 trigger reconnect
+        ((ConsumerImpl)consumer).getClientCnx().close();
+
+        // 5 for non-durable we are going to restart from the next entry
+        for (int i = 5; i < 10; i++) {
+            Message<String> message = consumer.receive(3, TimeUnit.SECONDS);

Review comment:
       same comment as above.




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



[GitHub] [pulsar] eolivelli commented on a change in pull request #10723: Add explicit test case for NonDurable Subscriptions and Broker restart

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #10723:
URL: https://github.com/apache/pulsar/pull/10723#discussion_r641899014



##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java
##########
@@ -126,4 +129,63 @@ public void testDeleteInactiveNonPersistentSubscription() throws Exception {
         assertNull(nonPersistentSubscription);
 
     }
+
+    @DataProvider(name = "subscriptionTypes")
+    public static Object[][] subscriptionTypes() {
+        Object[][] result = new Object[SubscriptionType.values().length][];
+        int i = 0;
+        for (SubscriptionType type : SubscriptionType.values()) {
+            result[i++] = new Object[] {type};
+        }
+        return result;
+    }
+
+    @Test(dataProvider = "subscriptionTypes")
+    public void testNonDurableSubscriptionRecovery(SubscriptionType subscriptionType) throws Exception {
+        log.info("testing {}", subscriptionType);
+        String topicName = "persistent://my-property/my-ns/nonDurable-sub-recorvery-"+subscriptionType;
+        // 1 setup producer、consumer
+        @Cleanup
+        Producer<String> producer = pulsarClient.newProducer(Schema.STRING).topic(topicName)
+                .create();
+        @Cleanup
+        Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topicName)
+                .subscriptionMode(SubscriptionMode.NonDurable)
+                .subscriptionType(subscriptionType)
+                .subscriptionName("my-nonDurable-subscriber")
+                .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
+                .subscribe();
+        // 2 send messages
+        int messageNum = 15;
+        for (int i = 0; i < messageNum; i++) {
+            producer.send("message" + i);
+        }
+        // 3 receive the first 5 messages
+        for (int i = 0; i < 5; i++) {
+            Message<String> message = consumer.receive(1, TimeUnit.SECONDS);

Review comment:
       I have copy/pasted the test above.
   
   let me address your comment




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



[GitHub] [pulsar] sijie merged pull request #10723: Add explicit test case for NonDurable Subscriptions and Broker restart

Posted by GitBox <gi...@apache.org>.
sijie merged pull request #10723:
URL: https://github.com/apache/pulsar/pull/10723


   


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