BewareMyPower commented on code in PR #21187:
URL: https://github.com/apache/pulsar/pull/21187#discussion_r1455312306


##########
pulsar-broker/src/test/java/org/apache/pulsar/compaction/CompactionTest.java:
##########
@@ -1985,4 +1985,55 @@ public void testCompactionDuplicate() throws Exception {
             }
         }
     }
+
+    @Test(timeOut = 100000)
+    public void testAcknowledge() throws Exception {
+        final String topicName = 
"persistent://my-property/use/my-ns/testAcknowledge" + UUID.randomUUID();
+        final String subName = "my-sub";
+        @Cleanup
+        PulsarClient client = newPulsarClient(lookupUrl.toString(), 100);
+        Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
+                .enableBatching(false).topic(topicName).create();
+
+        
pulsarClient.newConsumer().topic(topicName).subscriptionName(subName).readCompacted(true).subscribe().close();
+
+        Map<String, String> expected = new HashMap<>();
+        for (int i = 0; i < 10; i++) {
+            
producer.newMessage().key(String.valueOf(i)).value(String.valueOf(i)).send();
+            expected.put(String.valueOf(i), String.valueOf(i));
+        }
+        producer.flush();
+
+        admin.topics().triggerCompaction(topicName);
+
+        Awaitility.await().untilAsserted(() -> {
+            assertEquals(admin.topics().compactionStatus(topicName).status,
+                    LongRunningProcessStatus.Status.SUCCESS);
+        });
+
+        ConsumerImpl<String> consumer = (ConsumerImpl<String>) 
client.newConsumer(Schema.STRING)
+                
.topic(topicName).readCompacted(true).receiverQueueSize(1).subscriptionName(subName)
+                .isAckReceiptEnabled(true)
+                .subscribe();
+
+        for (int i = 0; i < 10; i++) {
+            Message<String> message = consumer.receive(3, TimeUnit.SECONDS);
+            if (message == null) {
+                break;
+            }
+
+            consumer.acknowledge(message);
+            String remove = expected.remove(message.getKey());
+            Assert.assertEquals(remove, message.getValue());
+        }
+
+        // Make consumer reconnect to broker

Review Comment:
   @coderzc This comment seems not addressed.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to