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/29 06:35:19 UTC

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

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