Search in sources :

Example 16 with KafkaJmxOptionsBuilder

use of io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder in project strimzi-kafka-operator by strimzi.

the class KafkaClusterTest method testGenerateHeadlessServiceWithJmxMetrics.

@ParallelTest
public void testGenerateHeadlessServiceWithJmxMetrics() {
    Kafka kafka = new KafkaBuilder(kafkaAssembly).editSpec().editKafka().withJmxOptions(new KafkaJmxOptionsBuilder().build()).endKafka().endSpec().build();
    KafkaCluster kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafka, VERSIONS);
    Service headless = kc.generateHeadlessService();
    assertThat(headless.getSpec().getType(), is("ClusterIP"));
    assertThat(headless.getSpec().getSelector(), is(expectedSelectorLabels()));
    assertThat(headless.getSpec().getPorts().size(), is(5));
    assertThat(headless.getSpec().getPorts().get(0).getName(), is(KafkaCluster.CONTROLPLANE_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(0).getPort(), is(Integer.valueOf(KafkaCluster.CONTROLPLANE_PORT)));
    assertThat(headless.getSpec().getPorts().get(0).getProtocol(), is("TCP"));
    assertThat(headless.getSpec().getPorts().get(1).getName(), is(KafkaCluster.REPLICATION_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(1).getPort(), is(Integer.valueOf(KafkaCluster.REPLICATION_PORT)));
    assertThat(headless.getSpec().getPorts().get(1).getProtocol(), is("TCP"));
    assertThat(headless.getSpec().getPorts().get(2).getName(), is(ListenersUtils.BACKWARDS_COMPATIBLE_PLAIN_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(2).getPort(), is(9092));
    assertThat(headless.getSpec().getPorts().get(2).getProtocol(), is("TCP"));
    assertThat(headless.getSpec().getPorts().get(3).getName(), is(ListenersUtils.BACKWARDS_COMPATIBLE_TLS_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(3).getPort(), is(9093));
    assertThat(headless.getSpec().getPorts().get(3).getProtocol(), is("TCP"));
    assertThat(headless.getSpec().getPorts().get(4).getName(), is(KafkaCluster.JMX_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(4).getPort(), is(Integer.valueOf(KafkaCluster.JMX_PORT)));
    assertThat(headless.getSpec().getPorts().get(4).getProtocol(), is("TCP"));
    assertThat(headless.getMetadata().getLabels().containsKey(Labels.STRIMZI_DISCOVERY_LABEL), is(false));
    checkOwnerReference(kc.createOwnerReference(), headless);
}
Also used : KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) Service(io.fabric8.kubernetes.api.model.Service) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 17 with KafkaJmxOptionsBuilder

use of io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder in project strimzi-kafka-operator by strimzi.

the class KafkaConnectClusterTest method testJmxSecretCustomLabelsAndAnnotations.

@ParallelTest
public void testJmxSecretCustomLabelsAndAnnotations() {
    Map<String, String> customLabels = new HashMap<>(2);
    customLabels.put("label1", "value1");
    customLabels.put("label2", "value2");
    Map<String, String> customAnnotations = new HashMap<>(2);
    customAnnotations.put("anno1", "value3");
    customAnnotations.put("anno2", "value4");
    KafkaConnect kafkaConnect = new KafkaConnectBuilder(this.resource).editSpec().withJmxOptions(new KafkaJmxOptionsBuilder().withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build()).build()).withNewTemplate().withNewJmxSecret().withNewMetadata().withAnnotations(customAnnotations).withLabels(customLabels).endMetadata().endJmxSecret().endTemplate().endSpec().build();
    KafkaConnectCluster kafkaConnectCluster = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaConnect, VERSIONS);
    Secret jmxSecret = kafkaConnectCluster.generateJmxSecret();
    for (Map.Entry<String, String> entry : customAnnotations.entrySet()) {
        assertThat(jmxSecret.getMetadata().getAnnotations(), hasEntry(entry.getKey(), entry.getValue()));
    }
    for (Map.Entry<String, String> entry : customLabels.entrySet()) {
        assertThat(jmxSecret.getMetadata().getLabels(), hasEntry(entry.getKey(), entry.getValue()));
    }
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) KafkaConnectBuilder(io.strimzi.api.kafka.model.KafkaConnectBuilder) KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) HashMap(java.util.HashMap) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) KafkaJmxAuthenticationPasswordBuilder(io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder) Map(java.util.Map) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 18 with KafkaJmxOptionsBuilder

use of io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder in project strimzi-kafka-operator by strimzi.

the class KafkaMirrorMaker2ClusterTest method testJmxSecretCustomLabelsAndAnnotations.

@ParallelTest
public void testJmxSecretCustomLabelsAndAnnotations() {
    Map<String, String> customLabels = new HashMap<>(2);
    customLabels.put("label1", "value1");
    customLabels.put("label2", "value2");
    Map<String, String> customAnnotations = new HashMap<>(2);
    customAnnotations.put("anno1", "value3");
    customAnnotations.put("anno2", "value4");
    KafkaMirrorMaker2 kafkaMirrorMaker2 = new KafkaMirrorMaker2Builder(this.resource).editSpec().withJmxOptions(new KafkaJmxOptionsBuilder().withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build()).build()).withNewTemplate().withNewJmxSecret().withNewMetadata().withAnnotations(customAnnotations).withLabels(customLabels).endMetadata().endJmxSecret().endTemplate().endSpec().build();
    KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaMirrorMaker2, VERSIONS);
    Secret jmxSecret = kmm2.generateJmxSecret();
    for (Map.Entry<String, String> entry : customAnnotations.entrySet()) {
        assertThat(jmxSecret.getMetadata().getAnnotations(), hasEntry(entry.getKey(), entry.getValue()));
    }
    for (Map.Entry<String, String> entry : customLabels.entrySet()) {
        assertThat(jmxSecret.getMetadata().getLabels(), hasEntry(entry.getKey(), entry.getValue()));
    }
}
Also used : KafkaMirrorMaker2Builder(io.strimzi.api.kafka.model.KafkaMirrorMaker2Builder) Secret(io.fabric8.kubernetes.api.model.Secret) KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) HashMap(java.util.HashMap) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) KafkaJmxAuthenticationPasswordBuilder(io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) Map(java.util.Map) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 19 with KafkaJmxOptionsBuilder

use of io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder in project strimzi-kafka-operator by strimzi.

the class ZookeeperClusterTest method testCreateClusterWithZookeeperJmxEnabled.

@ParallelTest
public void testCreateClusterWithZookeeperJmxEnabled() {
    Kafka kafka = new KafkaBuilder().withNewMetadata().withName(cluster).withNamespace(namespace).endMetadata().withNewSpec().withNewKafka().withReplicas(3).withNewEphemeralStorage().endEphemeralStorage().endKafka().withNewZookeeper().withJmxOptions(new KafkaJmxOptionsBuilder().withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build()).build()).withReplicas(3).withNewEphemeralStorage().endEphemeralStorage().endZookeeper().endSpec().build();
    ZookeeperCluster zookeeperCluster = ZookeeperCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafka, KafkaVersionTestUtils.getKafkaVersionLookup());
    Secret jmxSecret = zookeeperCluster.generateJmxSecret();
    assertThat(jmxSecret.getData(), hasKey("jmx-username"));
    assertThat(jmxSecret.getData(), hasKey("jmx-password"));
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) KafkaJmxAuthenticationPasswordBuilder(io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 20 with KafkaJmxOptionsBuilder

use of io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder in project strimzi-kafka-operator by strimzi.

the class ZookeeperClusterTest method testGenerateHeadlessServiceWithJmxMetrics.

@ParallelTest
public void testGenerateHeadlessServiceWithJmxMetrics() {
    Kafka kafka = new KafkaBuilder(ka).editSpec().editZookeeper().withJmxOptions(new KafkaJmxOptionsBuilder().build()).endZookeeper().endSpec().build();
    ZookeeperCluster zc = ZookeeperCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafka, VERSIONS);
    Service headless = zc.generateHeadlessService();
    assertThat(headless.getMetadata().getName(), is(ZookeeperCluster.headlessServiceName(cluster)));
    assertThat(headless.getSpec().getType(), is("ClusterIP"));
    assertThat(headless.getSpec().getClusterIP(), is("None"));
    assertThat(headless.getSpec().getSelector(), is(expectedSelectorLabels()));
    assertThat(headless.getSpec().getPorts().size(), is(4));
    assertThat(headless.getSpec().getPorts().get(0).getName(), is(ZookeeperCluster.CLIENT_TLS_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(0).getPort(), is(Integer.valueOf(ZookeeperCluster.CLIENT_TLS_PORT)));
    assertThat(headless.getSpec().getPorts().get(0).getProtocol(), is("TCP"));
    assertThat(headless.getSpec().getPorts().get(1).getName(), is(ZookeeperCluster.CLUSTERING_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(1).getPort(), is(Integer.valueOf(ZookeeperCluster.CLUSTERING_PORT)));
    assertThat(headless.getSpec().getPorts().get(2).getName(), is(ZookeeperCluster.LEADER_ELECTION_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(2).getPort(), is(Integer.valueOf(ZookeeperCluster.LEADER_ELECTION_PORT)));
    assertThat(headless.getSpec().getPorts().get(3).getName(), is(ZookeeperCluster.JMX_PORT_NAME));
    assertThat(headless.getSpec().getPorts().get(3).getPort(), is(Integer.valueOf(ZookeeperCluster.JMX_PORT)));
    assertThat(headless.getSpec().getPorts().get(3).getProtocol(), is("TCP"));
    assertThat(headless.getSpec().getIpFamilyPolicy(), is(nullValue()));
    assertThat(headless.getSpec().getIpFamilies(), is(emptyList()));
    checkOwnerReference(zc.createOwnerReference(), headless);
}
Also used : KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) Service(io.fabric8.kubernetes.api.model.Service) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

KafkaJmxOptionsBuilder (io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder)24 KafkaJmxAuthenticationPasswordBuilder (io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder)20 Kafka (io.strimzi.api.kafka.model.Kafka)16 ParallelTest (io.strimzi.test.annotations.ParallelTest)14 Secret (io.fabric8.kubernetes.api.model.Secret)12 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)10 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)8 Collections.emptyMap (java.util.Collections.emptyMap)8 Collections.singletonMap (java.util.Collections.singletonMap)8 Service (io.fabric8.kubernetes.api.model.Service)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)5 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)4 KafkaConnect (io.strimzi.api.kafka.model.KafkaConnect)4 KafkaJmxOptions (io.strimzi.api.kafka.model.KafkaJmxOptions)4 KafkaMirrorMaker2 (io.strimzi.api.kafka.model.KafkaMirrorMaker2)4 Test (org.junit.jupiter.api.Test)4