use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator 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.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testExternalConfigurationConfigVolumesWithDots.
@ParallelTest
public void testExternalConfigurationConfigVolumesWithDots() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my.volume").withConfigMap(new ConfigMapVolumeSourceBuilder().withName("my.map").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).getConfigMap(), is(volume.getConfigMap()));
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"));
}
use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testExternalConfigurationConfigVolumes.
@ParallelTest
public void testExternalConfigurationConfigVolumes() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my-volume").withConfigMap(new ConfigMapVolumeSourceBuilder().withName("my-map").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().equals(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selected.get(0).getName(), is(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selected.get(0).getConfigMap(), is(volume.getConfigMap()));
List<VolumeMount> volumeMounts = dep.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts();
List<VolumeMount> selectedVolumeMounts = volumeMounts.stream().filter(vol -> vol.getName().equals(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selectedVolumeMounts.get(0).getName(), is(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selectedVolumeMounts.get(0).getMountPath(), is(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_MOUNT_BASE_PATH + "my-volume"));
}
use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testGenerateDeploymentWithTlsSameSecret.
@ParallelTest
public void testGenerateDeploymentWithTlsSameSecret() {
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().editOrNewTls().addToTrustedCertificates(new CertSecretSourceBuilder().withSecretName("my-secret").withCertificate("cert.crt").build()).endTls().withAuthentication(new KafkaClientAuthenticationTlsBuilder().withNewCertificateAndKey().withSecretName("my-secret").withCertificate("user.crt").withKey("user.key").endCertificateAndKey().build()).endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
// 3 = 1 temp volume + 1 volume from logging/metrics + just 1 from above certs Secret
assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().size(), is(3));
assertThat(dep.getSpec().getTemplate().getSpec().getVolumes().get(2).getName(), is("my-secret"));
}
use of io.strimzi.api.kafka.model.KafkaConnectBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testNetworkPolicyWithConnectorOperatorWithNamespaceLabels.
@ParallelTest
public void testNetworkPolicyWithConnectorOperatorWithNamespaceLabels() {
KafkaConnect resource = new KafkaConnectBuilder(this.resourceWithMetrics).build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
NetworkPolicy np = kc.generateNetworkPolicy(true, "operator-namespace", Labels.fromMap(Collections.singletonMap("nsLabelKey", "nsLabelValue")));
assertThat(np.getMetadata().getName(), is(kc.getName()));
assertThat(np.getSpec().getPodSelector().getMatchLabels(), is(kc.getSelectorLabels().toMap()));
assertThat(np.getSpec().getIngress().size(), is(2));
assertThat(np.getSpec().getIngress().get(0).getPorts().size(), is(1));
assertThat(np.getSpec().getIngress().get(0).getPorts().get(0).getPort().getIntVal(), is(KafkaConnectCluster.REST_API_PORT));
assertThat(np.getSpec().getIngress().get(0).getFrom().size(), is(2));
assertThat(np.getSpec().getIngress().get(0).getFrom().get(0).getPodSelector().getMatchLabels(), is(kc.getSelectorLabels().toMap()));
assertThat(np.getSpec().getIngress().get(0).getFrom().get(0).getNamespaceSelector(), is(nullValue()));
assertThat(np.getSpec().getIngress().get(0).getFrom().get(1).getPodSelector().getMatchLabels(), is(singletonMap(Labels.STRIMZI_KIND_LABEL, "cluster-operator")));
assertThat(np.getSpec().getIngress().get(0).getFrom().get(1).getNamespaceSelector().getMatchLabels(), is(Collections.singletonMap("nsLabelKey", "nsLabelValue")));
assertThat(np.getSpec().getIngress().get(1).getPorts().size(), is(1));
assertThat(np.getSpec().getIngress().get(1).getPorts().get(0).getPort().getIntVal(), is(KafkaConnectCluster.METRICS_PORT));
}
Aggregations