Search in sources :

Example 26 with KafkaBridge

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

the class KafkaBridgeClusterTest method testDefaultGracePeriod.

@ParallelTest
public void testDefaultGracePeriod() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getTerminationGracePeriodSeconds(), is(Long.valueOf(30)));
}
Also used : KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 27 with KafkaBridge

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

the class KafkaBridgeClusterTest method testGenerateDeploymentWithOAuthWithMissingClientSecret.

@ParallelTest
public void testGenerateDeploymentWithOAuthWithMissingClientSecret() {
    assertThrows(InvalidResourceException.class, () -> {
        KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withAuthentication(new KafkaClientAuthenticationOAuthBuilder().withClientId("my-client-id").withTokenEndpointUri("http://my-oauth-server").build()).endSpec().build();
        KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    });
}
Also used : KafkaClientAuthenticationOAuthBuilder(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationOAuthBuilder) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 28 with KafkaBridge

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

the class KafkaBridgeClusterTest method testGenerateDeploymentWithScramSha512Auth.

@ParallelTest
public void testGenerateDeploymentWithScramSha512Auth() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewKafkaClientAuthenticationScramSha512().withUsername("user1").withNewPasswordSecret().withSecretName("user1-secret").withPassword("password").endPasswordSecret().endKafkaClientAuthenticationScramSha512().endSpec().build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, null);
    assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(2).getName(), is("user1-secret"));
    List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
    assertThat(containers.get(0).getVolumeMounts().get(2).getMountPath(), is(KafkaBridgeCluster.PASSWORD_VOLUME_MOUNT + "user1-secret"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_SASL_PASSWORD_FILE), is("user1-secret/password"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_SASL_USERNAME), is("user1"));
    assertThat(AbstractModel.containerEnvVars(containers.get(0)).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_SASL_MECHANISM), is("scram-sha-512"));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 29 with KafkaBridge

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

the class KafkaBridgeClusterTest method testImagePullSecretsBoth.

@ParallelTest
public void testImagePullSecretsBoth() {
    LocalObjectReference secret1 = new LocalObjectReference("some-pull-secret");
    LocalObjectReference secret2 = new LocalObjectReference("some-other-pull-secret");
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewTemplate().withNewPod().withImagePullSecrets(secret2).endPod().endTemplate().endSpec().build();
    KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kbc.generateDeployment(emptyMap(), true, null, singletonList(secret1));
    assertThat(dep.getSpec().getTemplate().getSpec().getImagePullSecrets().size(), is(1));
    assertThat(dep.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret1), is(false));
    assertThat(dep.getSpec().getTemplate().getSpec().getImagePullSecrets().contains(secret2), is(true));
}
Also used : KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) LocalObjectReference(io.fabric8.kubernetes.api.model.LocalObjectReference) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 30 with KafkaBridge

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

the class KafkaBridgeClusterTest method testProbeConfiguration.

@ParallelTest
public void testProbeConfiguration() {
    KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewLivenessProbe().withInitialDelaySeconds(20).withPeriodSeconds(21).withTimeoutSeconds(22).endLivenessProbe().withNewReadinessProbe().withInitialDelaySeconds(30).withPeriodSeconds(31).withTimeoutSeconds(32).endReadinessProbe().endSpec().build();
    KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
    Deployment dep = kb.generateDeployment(new HashMap<String, String>(), true, null, null);
    Container cont = dep.getSpec().getTemplate().getSpec().getContainers().get(0);
    assertThat(cont.getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(20)));
    assertThat(cont.getLivenessProbe().getPeriodSeconds(), is(Integer.valueOf(21)));
    assertThat(cont.getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(22)));
    assertThat(cont.getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(30)));
    assertThat(cont.getReadinessProbe().getPeriodSeconds(), is(Integer.valueOf(31)));
    assertThat(cont.getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(32)));
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaBridgeBuilder(io.strimzi.api.kafka.model.KafkaBridgeBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

KafkaBridge (io.strimzi.api.kafka.model.KafkaBridge)88 KafkaBridgeBuilder (io.strimzi.api.kafka.model.KafkaBridgeBuilder)82 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)70 ParallelTest (io.strimzi.test.annotations.ParallelTest)62 Service (io.fabric8.kubernetes.api.model.Service)38 PodDisruptionBudget (io.fabric8.kubernetes.api.model.policy.v1.PodDisruptionBudget)38 HashMap (java.util.HashMap)38 KafkaBridgeResources (io.strimzi.api.kafka.model.KafkaBridgeResources)36 Collections (java.util.Collections)36 List (java.util.List)36 Container (io.fabric8.kubernetes.api.model.Container)34 Reconciliation (io.strimzi.operator.common.Reconciliation)34 Labels (io.strimzi.operator.common.model.Labels)34 Map (java.util.Map)34 CoreMatchers.is (org.hamcrest.CoreMatchers.is)34 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)34 KafkaBridgeHttpConfig (io.strimzi.api.kafka.model.KafkaBridgeHttpConfig)32 KafkaVersionTestUtils (io.strimzi.operator.cluster.KafkaVersionTestUtils)32 ResourceUtils (io.strimzi.operator.cluster.ResourceUtils)32 TestUtils (io.strimzi.test.TestUtils)32