use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testJvmOptions.
@ParallelTest
public void testJvmOptions() {
Map<String, String> xx = new HashMap<>(2);
xx.put("UseG1GC", "true");
xx.put("MaxGCPauseMillis", "20");
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withNewJvmOptions().withXms("512m").withXmx("1024m").withXx(xx).endJvmOptions().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment dep = kc.generateDeployment(Collections.EMPTY_MAP, true, null, null);
Container cont = dep.getSpec().getTemplate().getSpec().getContainers().get(0);
assertThat(cont.getEnv().stream().filter(env -> "KAFKA_JVM_PERFORMANCE_OPTS".equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").contains("-XX:+UseG1GC"), is(true));
assertThat(cont.getEnv().stream().filter(env -> "KAFKA_JVM_PERFORMANCE_OPTS".equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").contains("-XX:MaxGCPauseMillis=20"), is(true));
assertThat(cont.getEnv().stream().filter(env -> "KAFKA_HEAP_OPTS".equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").contains("-Xmx1024m"), is(true));
assertThat(cont.getEnv().stream().filter(env -> "KAFKA_HEAP_OPTS".equals(env.getName())).map(EnvVar::getValue).findFirst().orElse("").contains("-Xms512m"), is(true));
}
use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testClusterRoleBindingRack.
@ParallelTest
public void testClusterRoleBindingRack() {
String testNamespace = "other-namespace";
KafkaConnect kafkaConnect = new KafkaConnectBuilder(this.resource).editOrNewMetadata().withNamespace(testNamespace).endMetadata().editOrNewSpec().withNewRack("my-topology-label").endSpec().build();
KafkaConnectCluster kafkaConnectCluster = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaConnect, VERSIONS);
ClusterRoleBinding crb = kafkaConnectCluster.generateClusterRoleBinding();
assertThat(crb.getMetadata().getName(), is(KafkaConnectResources.initContainerClusterRoleBindingName(cluster, testNamespace)));
assertThat(crb.getMetadata().getNamespace(), is(nullValue()));
assertThat(crb.getSubjects().get(0).getNamespace(), is(testNamespace));
assertThat(crb.getSubjects().get(0).getName(), is(kafkaConnectCluster.getServiceAccountName()));
}
use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testGenerateDeploymentWithOAuthWithMissingUri.
@ParallelTest
public void testGenerateDeploymentWithOAuthWithMissingUri() {
assertThrows(InvalidResourceException.class, () -> {
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withAuthentication(new KafkaClientAuthenticationOAuthBuilder().withClientId("my-client-id").withNewClientSecret().withSecretName("my-secret-secret").withKey("my-secret-key").endClientSecret().build()).endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
});
}
use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testMetricsParsingFromConfigMap.
@ParallelTest
public void testMetricsParsingFromConfigMap() {
MetricsConfig metrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(new ConfigMapKeySelectorBuilder().withName("my-metrics-configuration").withKey("config.yaml").build()).endValueFrom().build();
KafkaConnect kafkaConnect = new KafkaConnectBuilder(this.resource).editSpec().withMetricsConfig(metrics).endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaConnect, VERSIONS);
assertThat(kc.isMetricsEnabled(), is(true));
assertThat(kc.getMetricsConfigInCm(), is(metrics));
}
use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testExternalConfigurationSecretVolumesWithDots.
@ParallelTest
public void testExternalConfigurationSecretVolumesWithDots() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my.volume").withSecret(new SecretVolumeSourceBuilder().withSecretName("my.secret").build()).build();
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withNewExternalConfiguration().withVolumes(volume).endExternalConfiguration().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
List<Volume> volumes = dep.getSpec().getTemplate().getSpec().getVolumes();
List<Volume> selected = volumes.stream().filter(vol -> vol.getName().startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selected.get(0).getName(), startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selected.get(0).getSecret(), is(volume.getSecret()));
List<VolumeMount> volumeMounts = dep.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts();
List<VolumeMount> selectedVolumeMounts = volumeMounts.stream().filter(vol -> vol.getName().startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selectedVolumeMounts.get(0).getName(), startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selectedVolumeMounts.get(0).getMountPath(), is(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_MOUNT_BASE_PATH + "my.volume"));
}
Aggregations