This is an automated email from the ASF dual-hosted git repository.
linlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new f24b489 [Issue 12672][test] Reduce unnecessary message send in
testPeekWithSubscriptionNameNotExist (#12685)
f24b489 is described below
commit f24b4890c278f72a67fe30e7bf22dc36d71aac6a
Author: JiangHaiting <[email protected]>
AuthorDate: Wed Nov 10 16:42:59 2021 +0800
[Issue 12672][test] Reduce unnecessary message send in
testPeekWithSubscriptionNameNotExist (#12685)
* Fix issue 12672
* Change to new namespaces.
Reduce unnecessary message send in testPeekWithSubscriptionNameNotExist.
Something messed up with replicator.
Changed this topic to another tenant and namespace, this entire test class
can pass now.
Co-authored-by: Jiang Haiting <[email protected]>
---
.../pulsar/broker/admin/PersistentTopicsTest.java | 27 ++++++++++------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
index 2cb2d57..904a06c 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
@@ -668,29 +668,26 @@ public class PersistentTopicsTest extends
MockedPulsarServiceBaseTest {
@Test
public void testPeekWithSubscriptionNameNotExist() throws Exception {
- final String topicName = "testTopic";
- final TopicName topic = TopicName.get(
- TopicDomain.persistent.value(),
- testTenant,
- testNamespace,
- topicName);
- final String subscriptionName = "sub";
-
+ TenantInfoImpl tenantInfo = new
TenantInfoImpl(Sets.newHashSet("role1", "role2"), Sets.newHashSet("test"));
+ admin.tenants().createTenant("tenant-xyz", tenantInfo);
+ admin.namespaces().createNamespace("tenant-xyz/ns-abc",
Sets.newHashSet("test"));
RetentionPolicies retention = new RetentionPolicies(10,10);
- admin.namespaces().setRetention(topic.getNamespace(), retention);
- ((TopicsImpl)
admin.topics()).createPartitionedTopicAsync(topic.toString(), 3, true).get();
+ admin.namespaces().setRetention("tenant-xyz/ns-abc", retention);
+ final String topic =
"persistent://tenant-xyz/ns-abc/topic-testPeekWithSubscriptionNameNotExist";
+ final String subscriptionName = "sub";
+ ((TopicsImpl) admin.topics()).createPartitionedTopicAsync(topic, 3,
true).get();
final String partitionedTopic = topic + "-partition-0";
- Producer<String> producer =
pulsarClient.newProducer(Schema.STRING).topic(topic.toString()).create();
- for (int i = 0; i < 100; ++i) {
+ Producer<String> producer =
pulsarClient.newProducer(Schema.STRING).enableBatching(false).topic(topic).create();
+
+ for (int i = 0; i < 10; ++i) {
producer.send("test" + i);
}
- List<Message<byte[]>> messages = admin.topics()
- .peekMessages(partitionedTopic, subscriptionName, 5);
+ List<Message<byte[]>> messages =
admin.topics().peekMessages(partitionedTopic, subscriptionName, 3);
- Assert.assertEquals(messages.size(), 5);
+ Assert.assertEquals(messages.size(), 3);
producer.close();
}