Search in sources :

Example 11 with ConfigEntry

use of org.apache.kafka.clients.admin.ConfigEntry in project apache-kafka-on-k8s by banzaicloud.

the class InternalTopicManagerTest method shouldCreateRequiredTopics.

@Test
public void shouldCreateRequiredTopics() throws Exception {
    final InternalTopicConfig topicConfig = new RepartitionTopicConfig(topic, Collections.<String, String>emptyMap());
    topicConfig.setNumberOfPartitions(1);
    final InternalTopicConfig topicConfig2 = new UnwindowedChangelogTopicConfig(topic2, Collections.<String, String>emptyMap());
    topicConfig2.setNumberOfPartitions(1);
    final InternalTopicConfig topicConfig3 = new WindowedChangelogTopicConfig(topic3, Collections.<String, String>emptyMap());
    topicConfig3.setNumberOfPartitions(1);
    internalTopicManager.makeReady(Collections.singletonMap(topic, topicConfig));
    internalTopicManager.makeReady(Collections.singletonMap(topic2, topicConfig2));
    internalTopicManager.makeReady(Collections.singletonMap(topic3, topicConfig3));
    assertEquals(Utils.mkSet(topic, topic2, topic3), mockAdminClient.listTopics().names().get());
    assertEquals(new TopicDescription(topic, false, new ArrayList<TopicPartitionInfo>() {

        {
            add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
        }
    }), mockAdminClient.describeTopics(Collections.singleton(topic)).values().get(topic).get());
    assertEquals(new TopicDescription(topic2, false, new ArrayList<TopicPartitionInfo>() {

        {
            add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
        }
    }), mockAdminClient.describeTopics(Collections.singleton(topic2)).values().get(topic2).get());
    assertEquals(new TopicDescription(topic3, false, new ArrayList<TopicPartitionInfo>() {

        {
            add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.<Node>emptyList()));
        }
    }), mockAdminClient.describeTopics(Collections.singleton(topic3)).values().get(topic3).get());
    ConfigResource resource = new ConfigResource(ConfigResource.Type.TOPIC, topic);
    ConfigResource resource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2);
    ConfigResource resource3 = new ConfigResource(ConfigResource.Type.TOPIC, topic3);
    assertEquals(new ConfigEntry(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_DELETE), mockAdminClient.describeConfigs(Collections.singleton(resource)).values().get(resource).get().get(TopicConfig.CLEANUP_POLICY_CONFIG));
    assertEquals(new ConfigEntry(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_COMPACT), mockAdminClient.describeConfigs(Collections.singleton(resource2)).values().get(resource2).get().get(TopicConfig.CLEANUP_POLICY_CONFIG));
    assertEquals(new ConfigEntry(TopicConfig.CLEANUP_POLICY_CONFIG, TopicConfig.CLEANUP_POLICY_COMPACT + "," + TopicConfig.CLEANUP_POLICY_DELETE), mockAdminClient.describeConfigs(Collections.singleton(resource3)).values().get(resource3).get().get(TopicConfig.CLEANUP_POLICY_CONFIG));
}
Also used : ConfigEntry(org.apache.kafka.clients.admin.ConfigEntry) TopicPartitionInfo(org.apache.kafka.common.TopicPartitionInfo) Node(org.apache.kafka.common.Node) ArrayList(java.util.ArrayList) TopicDescription(org.apache.kafka.clients.admin.TopicDescription) ConfigResource(org.apache.kafka.common.config.ConfigResource) Test(org.junit.Test)

Aggregations

ConfigEntry (org.apache.kafka.clients.admin.ConfigEntry)11 Config (org.apache.kafka.clients.admin.Config)7 ConfigResource (org.apache.kafka.common.config.ConfigResource)7 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 TopicDescription (org.apache.kafka.clients.admin.TopicDescription)4 Node (org.apache.kafka.common.Node)4 TopicConfig (org.apache.kafka.common.config.TopicConfig)4 HashMap (java.util.HashMap)3 NewTopic (org.apache.kafka.clients.admin.NewTopic)3 Lists (com.google.common.collect.Lists)2 KafkaResponseGetFailedException (io.confluent.ksql.exception.KafkaResponseGetFailedException)2 KafkaTopicException (io.confluent.ksql.exception.KafkaTopicException)2 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Objects (java.util.Objects)2 Set (java.util.Set)2