codelipenghui commented on code in PR #18368:
URL: https://github.com/apache/pulsar/pull/18368#discussion_r1020061126
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/InactiveTopicDeleteTest.java:
##########
@@ -314,30 +315,50 @@ public void testDeleteWhenNoBacklogs() throws Exception {
super.baseSetup();
final String topic =
"persistent://prop/ns-abc/testDeleteWhenNoBacklogs";
-
+ final String topic2 =
"persistent://prop/ns-abc/testDeleteWhenNoBacklogsB";
Producer<byte[]> producer = pulsarClient.newProducer()
.topic(topic)
.create();
+ Producer<byte[]> producer2 = pulsarClient.newProducer()
+ .topic(topic2)
+ .create();
Consumer<byte[]> consumer = pulsarClient.newConsumer()
.topic(topic)
.subscriptionName("sub")
.subscribe();
- for (int i = 0; i < 10; i++) {
+ Consumer<byte[]> consumer2 = pulsarClient.newConsumer()
+ .topicsPattern("persistent://prop/ns-abc/test.*")
+ .subscriptionName("sub2")
+ .subscribe();
+
+ int producedCount = 10;
+ for (int i = 0; i < producedCount; i++) {
producer.send("Pulsar".getBytes());
+ producer2.send("Pulsar".getBytes());
}
producer.close();
+ producer2.close();
+ int receivedCount = 0;
+ Message<byte[]> msg;
+ while((msg = consumer2.receive(1, TimeUnit.SECONDS)) != null) {
+ consumer2.acknowledge(msg);
+ receivedCount ++;
+ }
+ assertEquals(producedCount * 2, receivedCount);
Thread.sleep(2000);
- Assert.assertTrue(admin.topics().getList("prop/ns-abc")
- .contains(topic));
+
Assert.assertTrue(admin.topics().getList("prop/ns-abc").contains(topic));
admin.topics().skipAllMessages(topic, "sub");
- Awaitility.await()
- .untilAsserted(() ->
Assert.assertFalse(admin.topics().getList("prop/ns-abc").contains(topic)));
+ Awaitility.await().untilAsserted(() -> {
+
Assert.assertFalse(admin.topics().getList("prop/ns-abc").contains(topic));
+
Assert.assertFalse(admin.topics().getList("prop/ns-abc").contains(topic2));
+ });
consumer.close();
+ consumer2.close();
Review Comment:
We should check that consumer2 has no internal consumers eventually or we
can say all the internal consumers are closed due to the topic being deleted.
--
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]