use of io.streamnative.pulsar.handlers.kop.utils.TopicNameUtils in project starlight-for-kafka by datastax.
the class KafkaRequestHandlerTest method testDeleteTopicsAndCheckChildPath.
@Test(timeOut = 10000)
public void testDeleteTopicsAndCheckChildPath() throws Exception {
Properties props = new Properties();
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:" + getKafkaBrokerPort());
@Cleanup AdminClient kafkaAdmin = AdminClient.create(props);
Map<String, Integer> topicToNumPartitions = new HashMap<String, Integer>() {
{
put("testCreateTopics-0", 1);
put("testCreateTopics-1", 3);
put("my-tenant/my-ns/testCreateTopics-2", 1);
put("persistent://my-tenant/my-ns/testCreateTopics-3", 5);
}
};
// create
createTopicsByKafkaAdmin(kafkaAdmin, topicToNumPartitions);
verifyTopicsCreatedByPulsarAdmin(topicToNumPartitions);
// delete
deleteTopicsByKafkaAdmin(kafkaAdmin, topicToNumPartitions.keySet());
verifyTopicsDeletedByPulsarAdmin(topicToNumPartitions);
// check deleted topics path
Set<String> deletedTopics = handler.getPulsarService().getBrokerService().getPulsar().getLocalMetadataStore().getChildren(KopEventManager.getDeleteTopicsPath()).join().stream().map((TopicNameUtils::getTopicNameWithUrlDecoded)).collect(Collectors.toSet());
assertEquals(topicToNumPartitions.keySet(), deletedTopics);
}
use of io.streamnative.pulsar.handlers.kop.utils.TopicNameUtils in project kop by streamnative.
the class KafkaRequestHandlerTest method testDeleteTopicsAndCheckChildPath.
@Test(timeOut = 10000)
public void testDeleteTopicsAndCheckChildPath() throws Exception {
Properties props = new Properties();
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:" + getKafkaBrokerPort());
@Cleanup AdminClient kafkaAdmin = AdminClient.create(props);
Map<String, Integer> topicToNumPartitions = new HashMap<String, Integer>() {
{
put("testCreateTopics-0", 1);
put("testCreateTopics-1", 3);
put("my-tenant/my-ns/testCreateTopics-2", 1);
put("persistent://my-tenant/my-ns/testCreateTopics-3", 5);
}
};
// create
createTopicsByKafkaAdmin(kafkaAdmin, topicToNumPartitions);
verifyTopicsCreatedByPulsarAdmin(topicToNumPartitions);
// delete
deleteTopicsByKafkaAdmin(kafkaAdmin, topicToNumPartitions.keySet());
verifyTopicsDeletedByPulsarAdmin(topicToNumPartitions);
// check deleted topics path
Set<String> deletedTopics = handler.getPulsarService().getBrokerService().getPulsar().getLocalMetadataStore().getChildren(KopEventManager.getDeleteTopicsPath()).join().stream().map((TopicNameUtils::getTopicNameWithUrlDecoded)).collect(Collectors.toSet());
assertEquals(topicToNumPartitions.keySet(), deletedTopics);
}
Aggregations