use of io.strimzi.api.kafka.model.KafkaConnect in project strimzi by strimzi.
the class KafkaConnectClusterTest method testKafkaConnectInitContainerSectionIsConfigurable.
@ParallelTest
public void testKafkaConnectInitContainerSectionIsConfigurable() {
Map<String, Quantity> limits = new HashMap<>();
limits.put("cpu", Quantity.parse("1"));
limits.put("memory", Quantity.parse("256Mi"));
Map<String, Quantity> requirements = new HashMap<>();
requirements.put("cpu", Quantity.parse("100m"));
requirements.put("memory", Quantity.parse("128Mi"));
ResourceRequirements resourceReq = new ResourceRequirementsBuilder().withLimits(limits).withRequests(requirements).build();
KafkaConnect kafkaConnect = new KafkaConnectBuilder(this.resource).editSpec().withResources(resourceReq).withNewRack().withTopologyKey("rack-key").endRack().endSpec().build();
KafkaConnectCluster kcc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaConnect, VERSIONS);
ResourceRequirements initContainersResources = kcc.getInitContainers(ImagePullPolicy.IFNOTPRESENT).get(0).getResources();
assertThat(initContainersResources.getRequests(), is(requirements));
assertThat(initContainersResources.getLimits(), is(limits));
}
use of io.strimzi.api.kafka.model.KafkaConnect in project strimzi by strimzi.
the class KafkaConnectClusterTest method testNullClusterRoleBinding.
@ParallelTest
public void testNullClusterRoleBinding() {
String testNamespace = "other-namespace";
KafkaConnect kafkaConnect = new KafkaConnectBuilder(this.resource).editOrNewMetadata().withNamespace(testNamespace).endMetadata().build();
KafkaConnectCluster kafkaConnectCluster = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaConnect, VERSIONS);
ClusterRoleBinding crb = kafkaConnectCluster.generateClusterRoleBinding();
assertThat(crb, is(nullValue()));
}
use of io.strimzi.api.kafka.model.KafkaConnect in project strimzi by strimzi.
the class KafkaConnectClusterTest method testGenerateDeploymentWithPlainAuthAndTLSSameSecret.
/**
* This test uses the same secret to hold the certs for TLS and the credentials for plain client authentication. It checks that
* the volumes and volume mounts that reference the secret are correctly created and that each volume name is only created once - volumes
* with duplicate names will cause Kubernetes to reject the deployment.
*/
@ParallelTest
public void testGenerateDeploymentWithPlainAuthAndTLSSameSecret() {
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret").withCertificate("cert.crt").build()).endTls().withNewKafkaClientAuthenticationPlain().withUsername("user1").withNewPasswordSecret().withSecretName("my-secret").withPassword("user1.password").endPasswordSecret().endKafkaClientAuthenticationPlain().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().size(), is(3));
assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(0).getName(), is(AbstractModel.STRIMZI_TMP_DIRECTORY_DEFAULT_VOLUME_NAME));
assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(1).getName(), is("kafka-metrics-and-logging"));
assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(2).getName(), is("my-secret"));
List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
assertThat(containers.get(0).getVolumeMounts().size(), is(4));
assertThat(containers.get(0).getVolumeMounts().get(0).getName(), is(AbstractModel.STRIMZI_TMP_DIRECTORY_DEFAULT_VOLUME_NAME));
assertThat(containers.get(0).getVolumeMounts().get(0).getMountPath(), is(AbstractModel.STRIMZI_TMP_DIRECTORY_DEFAULT_MOUNT_PATH));
assertThat(containers.get(0).getVolumeMounts().get(1).getName(), is("kafka-metrics-and-logging"));
assertThat(containers.get(0).getVolumeMounts().get(1).getMountPath(), is("/opt/kafka/custom-config/"));
assertThat(containers.get(0).getVolumeMounts().get(2).getName(), is("my-secret"));
assertThat(containers.get(0).getVolumeMounts().get(2).getMountPath(), is(KafkaConnectCluster.TLS_CERTS_BASE_VOLUME_MOUNT + "my-secret"));
assertThat(containers.get(0).getVolumeMounts().get(3).getName(), is("my-secret"));
assertThat(containers.get(0).getVolumeMounts().get(3).getMountPath(), is(KafkaConnectCluster.PASSWORD_VOLUME_MOUNT + "my-secret"));
assertThat(AbstractModel.containerEnvVars(containers.get(0)), hasEntry(KafkaConnectCluster.ENV_VAR_KAFKA_CONNECT_SASL_PASSWORD_FILE, "my-secret/user1.password"));
assertThat(AbstractModel.containerEnvVars(containers.get(0)), hasEntry(KafkaConnectCluster.ENV_VAR_KAFKA_CONNECT_SASL_USERNAME, "user1"));
assertThat(AbstractModel.containerEnvVars(containers.get(0)), hasEntry(KafkaConnectCluster.ENV_VAR_KAFKA_CONNECT_SASL_MECHANISM, "plain"));
assertThat(AbstractModel.containerEnvVars(containers.get(0)), hasEntry(KafkaConnectCluster.ENV_VAR_KAFKA_CONNECT_TLS, "true"));
}
use of io.strimzi.api.kafka.model.KafkaConnect in project strimzi by strimzi.
the class KafkaConnectClusterTest method testGracePeriod.
@ParallelTest
public void testGracePeriod() {
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withNewTemplate().withNewPod().withTerminationGracePeriodSeconds(123).endPod().endTemplate().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
assertThat(dep.getSpec().getTemplate().getSpec().getTerminationGracePeriodSeconds(), is(Long.valueOf(123)));
}
use of io.strimzi.api.kafka.model.KafkaConnect in project strimzi by strimzi.
the class KafkaConnectBuildTest method testValidationPluginsExist.
@ParallelTest
public void testValidationPluginsExist() {
KafkaConnect kc = new KafkaConnectBuilder().withNewMetadata().withName(cluster).withNamespace(namespace).endMetadata().withNewSpec().withBootstrapServers("my-kafka:9092").withNewBuild().withNewDockerOutput().withImage("my-image:latest").withPushSecret("my-docker-credentials").endDockerOutput().endBuild().endSpec().build();
assertThrows(InvalidResourceException.class, () -> {
KafkaConnectBuild.fromCrd(new Reconciliation("test", kc.getKind(), kc.getMetadata().getNamespace(), kc.getMetadata().getName()), kc, VERSIONS);
});
}
Aggregations