Search in sources :

Example 1 with TopicNameUtils

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TopicNameUtils(io.streamnative.pulsar.handlers.kop.utils.TopicNameUtils) HashMap(java.util.HashMap) Properties(java.util.Properties) Cleanup(lombok.Cleanup) AdminClient(org.apache.kafka.clients.admin.AdminClient) Test(org.testng.annotations.Test)

Example 2 with TopicNameUtils

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TopicNameUtils(io.streamnative.pulsar.handlers.kop.utils.TopicNameUtils) HashMap(java.util.HashMap) Properties(java.util.Properties) Cleanup(lombok.Cleanup) AdminClient(org.apache.kafka.clients.admin.AdminClient) Test(org.testng.annotations.Test)

Aggregations

TopicNameUtils (io.streamnative.pulsar.handlers.kop.utils.TopicNameUtils)2 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Cleanup (lombok.Cleanup)2 AdminClient (org.apache.kafka.clients.admin.AdminClient)2 Test (org.testng.annotations.Test)2