jiazhai commented on a change in pull request #2025: [WiP] Allow non-pesistent
topics to be retrieved along with persistent ones from the
"GetTopicsOfNamespace" method
URL: https://github.com/apache/incubator-pulsar/pull/2025#discussion_r207756903
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PatternTopicsConsumerImplTest.java
##########
@@ -207,15 +213,106 @@ public void testBinaryProtoToGetTopicsOfNamespace()
throws Exception {
producer1.close();
producer2.close();
producer3.close();
+ producer4.close();
+ }
+
+ // verify consumer create success, and works well.
+ @Test(timeOut = testTimeout)
+ public void testBinaryProtoToGetTopicsOfNamespaceNonPersistent() throws
Exception {
+ String key = "BinaryProtoToGetTopics";
+ String subscriptionName = "my-ex-subscription-" + key;
+ String topicName1 = "persistent://my-property/my-ns/pattern-topic-1-"
+ key;
+ String topicName2 = "persistent://my-property/my-ns/pattern-topic-2-"
+ key;
+ String topicName3 = "persistent://my-property/my-ns/pattern-topic-3-"
+ key;
+ String topicName4 =
"non-persistent://my-property/my-ns/pattern-topic-4-" + key;
+ Pattern pattern =
Pattern.compile("non-persistent://my-property/my-ns/pattern-topic.*");
+
+ // 1. create partition
+ admin.tenants().createTenant("prop", new TenantInfo());
+ admin.topics().createPartitionedTopic(topicName2, 2);
+ admin.topics().createPartitionedTopic(topicName3, 3);
+
+ // 2. create producer
+ String messagePredicate = "my-message-" + key + "-";
+ int totalMessages = 40;
+
+ Producer<byte[]> producer1 =
pulsarClient.newProducer().topic(topicName1)
+ .enableBatching(false)
+ .messageRoutingMode(MessageRoutingMode.SinglePartition)
+ .create();
+ Producer<byte[]> producer2 =
pulsarClient.newProducer().topic(topicName2)
+ .enableBatching(false)
+
.messageRoutingMode(org.apache.pulsar.client.api.MessageRoutingMode.RoundRobinPartition)
+ .create();
+ Producer<byte[]> producer3 =
pulsarClient.newProducer().topic(topicName3)
+ .enableBatching(false)
+
.messageRoutingMode(org.apache.pulsar.client.api.MessageRoutingMode.RoundRobinPartition)
+ .create();
+ Producer<byte[]> producer4 =
pulsarClient.newProducer().topic(topicName4)
+ .enableBatching(false)
+ .create();
+
+ Consumer<byte[]> consumer = pulsarClient.newConsumer()
+ .topicsPattern(pattern)
+ .patternAutoDiscoveryPeriod(2)
+ .subscriptionName(subscriptionName)
+ .subscriptionType(SubscriptionType.Shared)
+ .ackTimeout(ackTimeOutMillis, TimeUnit.MILLISECONDS)
+ .subscribe();
+
+ // 4. verify consumer get methods, to get right number of partitions
and topics.
+ assertSame(pattern, ((PatternMultiTopicsConsumerImpl<?>)
consumer).getPattern());
+ List<String> topics = ((PatternMultiTopicsConsumerImpl<?>)
consumer).getPartitionedTopics();
+ List<ConsumerImpl<byte[]>> consumers =
((PatternMultiTopicsConsumerImpl<byte[]>) consumer).getConsumers();
+
+ assertEquals(topics.size(), 1);
Review comment:
Test failed at here.
Before patternconsumer created, the producer had been created. By design,
it should have 7 topics (1+2+3+1)?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services