[Issue 12672][test] Reduce unnecessary message send in testPeekWithSubscriptionNameNotExist
* 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.
@@ -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();
}
