Search in sources :

Example 6 with KafkaJmxAuthenticationPasswordBuilder

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

the class KafkaConnectAssemblyOperatorTest method testCreateClusterWithJmxEnabled.

@Test
public void testCreateClusterWithJmxEnabled(VertxTestContext context) {
    String kcName = "foo";
    String kcNamespace = "test";
    KafkaConnect kc = ResourceUtils.createEmptyKafkaConnect(kcNamespace, kcName);
    kc.getMetadata().getAnnotations().put("strimzi.io/use-connector-resources", "true");
    kc.getSpec().setJmxOptions(new KafkaJmxOptionsBuilder().withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build()).build());
    createKafkaConnectCluster(context, kc, true);
}
Also used : KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) KafkaJmxAuthenticationPasswordBuilder(io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder) Test(org.junit.jupiter.api.Test)

Example 7 with KafkaJmxAuthenticationPasswordBuilder

use of io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder in project strimzi 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 8 with KafkaJmxAuthenticationPasswordBuilder

use of io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder in project strimzi 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 9 with KafkaJmxAuthenticationPasswordBuilder

use of io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder in project strimzi by strimzi.

the class KafkaClusterTest 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");
    Kafka kafka = new KafkaBuilder(kafkaAssembly).editSpec().editKafka().withJmxOptions(new KafkaJmxOptionsBuilder().withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build()).build()).withNewTemplate().withNewJmxSecret().withNewMetadata().withAnnotations(customAnnotations).withLabels(customLabels).endMetadata().endJmxSecret().endTemplate().endKafka().endSpec().build();
    KafkaCluster kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafka, VERSIONS);
    Secret jmxSecret = kc.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) KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) HashMap(java.util.HashMap) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Matchers.containsString(org.hamcrest.Matchers.containsString) KafkaJmxAuthenticationPasswordBuilder(io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder) Map(java.util.Map) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 10 with KafkaJmxAuthenticationPasswordBuilder

use of io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder in project strimzi by strimzi.

the class KafkaAssemblyOperatorTest method testUpdateClusterAuthenticationTrue.

@ParameterizedTest
@MethodSource("data")
public void testUpdateClusterAuthenticationTrue(Params params, VertxTestContext context) {
    setFields(params);
    Kafka kafkaAssembly = getKafkaAssembly("bar");
    KafkaJmxOptions kafkaJmxOptions = new KafkaJmxOptionsBuilder().withAuthentication(new KafkaJmxAuthenticationPasswordBuilder().build()).build();
    kafkaAssembly.getSpec().getKafka().setJmxOptions(kafkaJmxOptions);
    kafkaAssembly.getSpec().getZookeeper().setJmxOptions(kafkaJmxOptions);
    updateCluster(context, getKafkaAssembly("bar"), kafkaAssembly);
}
Also used : KafkaJmxOptionsBuilder(io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder) KafkaJmxOptions(io.strimzi.api.kafka.model.KafkaJmxOptions) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaJmxAuthenticationPasswordBuilder(io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

KafkaJmxAuthenticationPasswordBuilder (io.strimzi.api.kafka.model.KafkaJmxAuthenticationPasswordBuilder)20 KafkaJmxOptionsBuilder (io.strimzi.api.kafka.model.KafkaJmxOptionsBuilder)20 Secret (io.fabric8.kubernetes.api.model.Secret)12 Kafka (io.strimzi.api.kafka.model.Kafka)12 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)10 ParallelTest (io.strimzi.test.annotations.ParallelTest)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 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)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 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4