Technoboy- commented on code in PR #20983:
URL: https://github.com/apache/pulsar/pull/20983#discussion_r1292788638
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -1218,6 +1220,56 @@ public void
testConcurrentLoadTopicExceedLimitShouldNotBeAutoCreated() throws Ex
}
}
+ @Test
+ public void
testCheckInactiveSubscriptionsShouldNotDeleteCompactionCursor() throws
Exception {
+ String namespace = "prop/test";
+
+ // set up broker disable auto create and set concurrent load to 1 qps.
+ cleanup();
+ conf.setBrokerServiceCompactionThresholdInBytes(8);
+ setup();
+
+ try {
+ admin.namespaces().createNamespace(namespace);
+ } catch (PulsarAdminException.ConflictException e) {
+ // Ok.. (if test fails intermittently and namespace is already
created)
+ }
+
+ String compactionInactiveTestTopic =
"persistent://prop/test/testCompactionCursorShouldNotDelete";
+
+ admin.topics().createNonPartitionedTopic(compactionInactiveTestTopic);
+
+ CompletableFuture<Optional<Topic>> topicCf =
+
pulsar.getBrokerService().getTopic(compactionInactiveTestTopic, true);
+
+ Optional<Topic> topicOptional = topicCf.get();
+ assertTrue(topicOptional.isPresent());
+
+ PersistentTopic topic = (PersistentTopic) topicOptional.get();
+
+ PersistentSubscription sub = (PersistentSubscription)
topic.getSubscription(Compactor.COMPACTION_SUBSCRIPTION);
+ assertNotNull(sub);
+
+ topic.checkCompaction();
+
+ Field currentCompaction =
PersistentTopic.class.getDeclaredField("currentCompaction");
+ currentCompaction.setAccessible(true);
+ CompletableFuture<Long> compactionFuture =
(CompletableFuture<Long>)currentCompaction.get(topic);
+
+ compactionFuture.get();
+
+ Thread.sleep(2000);
+
+ // this operation is async delete
+ topic.checkInactiveSubscriptionsWithExpirationTime(1000);
+
+ // wait for async delete finish
+ Thread.sleep(2000);
Review Comment:
Better to use `Awaitility`
--
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]