Search in sources :

Example 36 with GenericKafkaListenerConfigurationBrokerBuilder

use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder in project strimzi by strimzi.

the class ListenersST method testOverrideNodePortConfiguration.

@ParallelNamespaceTest
@Tag(NODEPORT_SUPPORTED)
@Tag(EXTERNAL_CLIENTS_USED)
void testOverrideNodePortConfiguration(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(clusterOperator.getDeploymentNamespace(), extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
    final int brokerNodePort = 32000;
    final int brokerId = 0;
    final int clusterBootstrapNodePort = 32100;
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3, 1).editSpec().editKafka().withListeners(new GenericKafkaListenerBuilder().withType(KafkaListenerType.INTERNAL).withName(Constants.TLS_LISTENER_DEFAULT_NAME).withPort(9099).withTls(true).build(), new GenericKafkaListenerBuilder().withType(KafkaListenerType.NODEPORT).withName(Constants.EXTERNAL_LISTENER_DEFAULT_NAME).withPort(9100).withTls(false).withNewConfiguration().withNewBootstrap().withNodePort(clusterBootstrapNodePort).endBootstrap().withBrokers(new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(brokerId).withNodePort(brokerNodePort).build()).endConfiguration().build()).endKafka().endSpec().build());
    LOGGER.info("Checking nodePort to {} for bootstrap service {}", clusterBootstrapNodePort, KafkaResources.externalBootstrapServiceName(clusterName));
    assertThat(kubeClient(namespaceName).getService(namespaceName, KafkaResources.externalBootstrapServiceName(clusterName)).getSpec().getPorts().get(0).getNodePort(), is(clusterBootstrapNodePort));
    String firstExternalService = clusterName + "-kafka-" + Constants.EXTERNAL_LISTENER_DEFAULT_NAME + "-" + 0;
    LOGGER.info("Checking nodePort to {} for kafka-broker service {}", brokerNodePort, firstExternalService);
    assertThat(kubeClient(namespaceName).getService(namespaceName, firstExternalService).getSpec().getPorts().get(0).getNodePort(), is(brokerNodePort));
    ExternalKafkaClient externalKafkaClient = new ExternalKafkaClient.Builder().withTopicName(topicName).withNamespaceName(namespaceName).withClusterName(clusterName).withMessageCount(MESSAGE_COUNT).withListenerName(Constants.EXTERNAL_LISTENER_DEFAULT_NAME).build();
    externalKafkaClient.verifyProducedAndConsumedMessages(externalKafkaClient.sendMessagesPlain(), externalKafkaClient.receiveMessagesPlain());
}
Also used : ExternalKafkaClient(io.strimzi.systemtest.kafkaclients.externalClients.ExternalKafkaClient) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) GenericKafkaListenerConfigurationBrokerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder) ContainerEnvVarBuilder(io.strimzi.api.kafka.model.ContainerEnvVarBuilder) GenericKafkaListenerConfigurationBrokerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) Tag(org.junit.jupiter.api.Tag)

Example 37 with GenericKafkaListenerConfigurationBrokerBuilder

use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder in project strimzi by strimzi.

the class KafkaListenerReconcilerIngressV1Beta1Test method testIngressV1.

@Test
public void testIngressV1(VertxTestContext context) {
    Kafka kafka = new KafkaBuilder().withNewMetadata().withName(NAME).withNamespace(NAMESPACE).endMetadata().withNewSpec().withNewKafka().withReplicas(3).withListeners(new GenericKafkaListenerBuilder().withName("ingress").withPort(9094).withTls(true).withType(KafkaListenerType.INGRESS).withNewConfiguration().withNewBootstrap().withHost("bootstrap.mydomain.tld").endBootstrap().withBrokers(new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(0).withHost("broker-0.mydomain.tld").build(), new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(1).withHost("broker-1.mydomain.tld").build(), new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(2).withHost("broker-2.mydomain.tld").build()).endConfiguration().build()).withNewEphemeralStorage().endEphemeralStorage().endKafka().withNewZookeeper().withReplicas(3).withNewEphemeralStorage().endEphemeralStorage().endZookeeper().withNewEntityOperator().withNewUserOperator().endUserOperator().withNewTopicOperator().endTopicOperator().endEntityOperator().endSpec().build();
    KafkaCluster kafkaCluster = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafka, VERSIONS);
    ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
    // Mock ingress v1beta1 ops
    IngressV1Beta1Operator mockIngressV1Beta1ops = supplier.ingressV1Beta1Operations;
    ArgumentCaptor<io.fabric8.kubernetes.api.model.networking.v1beta1.Ingress> ingressV1Beta1Captor = ArgumentCaptor.forClass(io.fabric8.kubernetes.api.model.networking.v1beta1.Ingress.class);
    when(mockIngressV1Beta1ops.listAsync(eq(NAMESPACE), any(Labels.class))).thenReturn(Future.succeededFuture(emptyList()));
    when(mockIngressV1Beta1ops.reconcile(any(), anyString(), anyString(), ingressV1Beta1Captor.capture())).thenReturn(Future.succeededFuture(ReconcileResult.created(new io.fabric8.kubernetes.api.model.networking.v1beta1.Ingress())));
    when(mockIngressV1Beta1ops.hasIngressAddress(any(), eq(NAMESPACE), any(), anyLong(), anyLong())).thenReturn(Future.succeededFuture());
    // Mock ingress v1 ops
    IngressOperator mockIngressOps = supplier.ingressOperations;
    ArgumentCaptor<Ingress> ingressCaptor = ArgumentCaptor.forClass(Ingress.class);
    when(mockIngressOps.listAsync(eq(NAMESPACE), any(Labels.class))).thenReturn(Future.succeededFuture(emptyList()));
    when(mockIngressOps.reconcile(any(), anyString(), anyString(), ingressCaptor.capture())).thenReturn(Future.succeededFuture(ReconcileResult.created(new Ingress())));
    when(mockIngressOps.hasIngressAddress(any(), eq(NAMESPACE), any(), anyLong(), anyLong())).thenReturn(Future.succeededFuture());
    MockKafkaListenersReconciler reconciler = new MockKafkaListenersReconciler(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, NAME), kafkaCluster, new PlatformFeaturesAvailability(false, KubernetesVersion.V1_22), supplier.secretOperations, supplier.serviceOperations, supplier.routeOperations, supplier.ingressOperations, supplier.ingressV1Beta1Operations);
    Checkpoint async = context.checkpoint();
    reconciler.reconcile().onComplete(context.succeeding(v -> context.verify(() -> {
        assertThat(ingressCaptor.getAllValues().size(), is(4));
        assertThat(ingressV1Beta1Captor.getAllValues().size(), is(0));
        verify(mockIngressV1Beta1ops, never()).list(any(), any());
        verify(mockIngressV1Beta1ops, never()).reconcile(any(), any(), any(), any());
        verify(mockIngressV1Beta1ops, never()).hasIngressAddress(any(), any(), any(), anyLong(), anyLong());
        async.flag();
    })));
}
Also used : VertxTestContext(io.vertx.junit5.VertxTestContext) CoreMatchers.is(org.hamcrest.CoreMatchers.is) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IngressV1Beta1Operator(io.strimzi.operator.common.operator.resource.IngressV1Beta1Operator) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) IngressOperator(io.strimzi.operator.common.operator.resource.IngressOperator) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) GenericKafkaListenerConfigurationBrokerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ServiceOperator(io.strimzi.operator.common.operator.resource.ServiceOperator) ArgumentCaptor(org.mockito.ArgumentCaptor) KafkaCluster(io.strimzi.operator.cluster.model.KafkaCluster) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) KafkaVersionTestUtils(io.strimzi.operator.cluster.KafkaVersionTestUtils) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) ReconcileResult(io.strimzi.operator.common.operator.resource.ReconcileResult) ResourceUtils(io.strimzi.operator.cluster.ResourceUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Collections.emptyList(java.util.Collections.emptyList) KubernetesVersion(io.strimzi.operator.KubernetesVersion) KafkaVersion(io.strimzi.operator.cluster.model.KafkaVersion) SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Mockito.when(org.mockito.Mockito.when) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) Reconciliation(io.strimzi.operator.common.Reconciliation) Mockito.never(org.mockito.Mockito.never) Labels(io.strimzi.operator.common.model.Labels) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) RouteOperator(io.strimzi.operator.common.operator.resource.RouteOperator) Checkpoint(io.vertx.junit5.Checkpoint) Kafka(io.strimzi.api.kafka.model.Kafka) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) KafkaCluster(io.strimzi.operator.cluster.model.KafkaCluster) Kafka(io.strimzi.api.kafka.model.Kafka) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Reconciliation(io.strimzi.operator.common.Reconciliation) IngressV1Beta1Operator(io.strimzi.operator.common.operator.resource.IngressV1Beta1Operator) GenericKafkaListenerConfigurationBrokerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) Labels(io.strimzi.operator.common.model.Labels) IngressOperator(io.strimzi.operator.common.operator.resource.IngressOperator) Checkpoint(io.vertx.junit5.Checkpoint) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) Test(org.junit.jupiter.api.Test)

Example 38 with GenericKafkaListenerConfigurationBrokerBuilder

use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder in project strimzi by strimzi.

the class KafkaReconcilerStatusTest method testKafkaReconcilerStatusWithNodePortsAndOverrides.

@Test
public void testKafkaReconcilerStatusWithNodePortsAndOverrides(VertxTestContext context) {
    GenericKafkaListenerConfigurationBroker broker0 = new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(0).withAdvertisedHost("my-address-0").build();
    GenericKafkaListenerConfigurationBroker broker1 = new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(1).withAdvertisedHost("my-address-1").build();
    Kafka kafka = new KafkaBuilder(KAFKA).editOrNewSpec().editOrNewKafka().withListeners(new GenericKafkaListenerBuilder().withName("external").withPort(9094).withType(KafkaListenerType.NODEPORT).withTls(true).withNewConfiguration().withBrokers(broker0, broker1).endConfiguration().build()).endKafka().endSpec().build();
    ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
    // Mock the secrets needed for Kafka client
    SecretOperator mockSecretOps = supplier.secretOperations;
    Secret secret = new Secret();
    when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.clusterCaCertificateSecretName(CLUSTER_NAME)))).thenReturn(Future.succeededFuture(secret));
    when(mockSecretOps.getAsync(eq(NAMESPACE), eq(ClusterOperator.secretName(CLUSTER_NAME)))).thenReturn(Future.succeededFuture(secret));
    // Mock Kafka broker pods
    Pod pod0 = new PodBuilder().withNewMetadata().withName(CLUSTER_NAME + "-kafka-" + 0).endMetadata().withNewStatus().withHostIP("10.0.0.1").endStatus().build();
    Pod pod1 = new PodBuilder().withNewMetadata().withName(CLUSTER_NAME + "-kafka-" + 1).endMetadata().withNewStatus().withHostIP("10.0.0.25").endStatus().build();
    Pod pod2 = new PodBuilder().withNewMetadata().withName(CLUSTER_NAME + "-kafka-" + 2).endMetadata().withNewStatus().withHostIP("10.0.0.13").endStatus().build();
    List<Pod> pods = new ArrayList<>();
    pods.add(pod0);
    pods.add(pod1);
    pods.add(pod2);
    PodOperator mockPodOps = supplier.podOperations;
    when(mockPodOps.listAsync(eq(NAMESPACE), any(Labels.class))).thenReturn(Future.succeededFuture(pods));
    // Mock Kubernetes worker nodes
    NodeOperator mockNodeOps = supplier.nodeOperator;
    when(mockNodeOps.listAsync(any(Labels.class))).thenReturn(Future.succeededFuture(kubernetesWorkerNodes()));
    // Run the test
    KafkaReconciler reconciler = new MockKafkaReconcilerStatusTasks(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME), supplier, kafka);
    KafkaStatus status = new KafkaStatus();
    Checkpoint async = context.checkpoint();
    reconciler.reconcile(status, Date::new).onComplete(res -> context.verify(() -> {
        assertThat(res.succeeded(), is(true));
        // Check listener status
        assertThat(status.getListeners().size(), is(1));
        assertThat(status.getListeners().get(0).getName(), is("external"));
        assertThat(status.getListeners().get(0).getType(), is("external"));
        assertThat(status.getListeners().get(0).getBootstrapServers(), is("my-address-0:31234,5.124.16.8:31234,my-address-1:31234"));
        assertThat(status.getListeners().get(0).getAddresses().size(), is(3));
        assertThat(status.getListeners().get(0).getAddresses().get(0).getPort(), is(31234));
        assertThat(status.getListeners().get(0).getAddresses().get(0).getHost(), is("my-address-0"));
        assertThat(status.getListeners().get(0).getAddresses().get(1).getPort(), is(31234));
        assertThat(status.getListeners().get(0).getAddresses().get(1).getHost(), is("5.124.16.8"));
        assertThat(status.getListeners().get(0).getAddresses().get(2).getPort(), is(31234));
        assertThat(status.getListeners().get(0).getAddresses().get(2).getHost(), is("my-address-1"));
        async.flag();
    }));
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) GenericKafkaListenerConfigurationBrokerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder) PodOperator(io.strimzi.operator.common.operator.resource.PodOperator) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) ArrayList(java.util.ArrayList) GenericKafkaListenerConfigurationBroker(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBroker) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) Labels(io.strimzi.operator.common.model.Labels) SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) Secret(io.fabric8.kubernetes.api.model.Secret) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) Checkpoint(io.vertx.junit5.Checkpoint) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Reconciliation(io.strimzi.operator.common.Reconciliation) NodeOperator(io.strimzi.operator.common.operator.resource.NodeOperator) KafkaStatus(io.strimzi.api.kafka.model.status.KafkaStatus) Test(org.junit.jupiter.api.Test)

Example 39 with GenericKafkaListenerConfigurationBrokerBuilder

use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder in project strimzi-kafka-operator by strimzi.

the class KafkaReconcilerStatusTest method testKafkaReconcilerStatusWithNodePortsAndOverrides.

@Test
public void testKafkaReconcilerStatusWithNodePortsAndOverrides(VertxTestContext context) {
    GenericKafkaListenerConfigurationBroker broker0 = new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(0).withAdvertisedHost("my-address-0").build();
    GenericKafkaListenerConfigurationBroker broker1 = new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(1).withAdvertisedHost("my-address-1").build();
    Kafka kafka = new KafkaBuilder(KAFKA).editOrNewSpec().editOrNewKafka().withListeners(new GenericKafkaListenerBuilder().withName("external").withPort(9094).withType(KafkaListenerType.NODEPORT).withTls(true).withNewConfiguration().withBrokers(broker0, broker1).endConfiguration().build()).endKafka().endSpec().build();
    ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);
    // Mock the secrets needed for Kafka client
    SecretOperator mockSecretOps = supplier.secretOperations;
    Secret secret = new Secret();
    when(mockSecretOps.getAsync(eq(NAMESPACE), eq(KafkaResources.clusterCaCertificateSecretName(CLUSTER_NAME)))).thenReturn(Future.succeededFuture(secret));
    when(mockSecretOps.getAsync(eq(NAMESPACE), eq(ClusterOperator.secretName(CLUSTER_NAME)))).thenReturn(Future.succeededFuture(secret));
    // Mock Kafka broker pods
    Pod pod0 = new PodBuilder().withNewMetadata().withName(CLUSTER_NAME + "-kafka-" + 0).endMetadata().withNewStatus().withHostIP("10.0.0.1").endStatus().build();
    Pod pod1 = new PodBuilder().withNewMetadata().withName(CLUSTER_NAME + "-kafka-" + 1).endMetadata().withNewStatus().withHostIP("10.0.0.25").endStatus().build();
    Pod pod2 = new PodBuilder().withNewMetadata().withName(CLUSTER_NAME + "-kafka-" + 2).endMetadata().withNewStatus().withHostIP("10.0.0.13").endStatus().build();
    List<Pod> pods = new ArrayList<>();
    pods.add(pod0);
    pods.add(pod1);
    pods.add(pod2);
    PodOperator mockPodOps = supplier.podOperations;
    when(mockPodOps.listAsync(eq(NAMESPACE), any(Labels.class))).thenReturn(Future.succeededFuture(pods));
    // Mock Kubernetes worker nodes
    NodeOperator mockNodeOps = supplier.nodeOperator;
    when(mockNodeOps.listAsync(any(Labels.class))).thenReturn(Future.succeededFuture(kubernetesWorkerNodes()));
    // Run the test
    KafkaReconciler reconciler = new MockKafkaReconcilerStatusTasks(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME), supplier, kafka);
    KafkaStatus status = new KafkaStatus();
    Checkpoint async = context.checkpoint();
    reconciler.reconcile(status, Date::new).onComplete(res -> context.verify(() -> {
        assertThat(res.succeeded(), is(true));
        // Check listener status
        assertThat(status.getListeners().size(), is(1));
        assertThat(status.getListeners().get(0).getName(), is("external"));
        assertThat(status.getListeners().get(0).getType(), is("external"));
        assertThat(status.getListeners().get(0).getBootstrapServers(), is("my-address-0:31234,5.124.16.8:31234,my-address-1:31234"));
        assertThat(status.getListeners().get(0).getAddresses().size(), is(3));
        assertThat(status.getListeners().get(0).getAddresses().get(0).getPort(), is(31234));
        assertThat(status.getListeners().get(0).getAddresses().get(0).getHost(), is("my-address-0"));
        assertThat(status.getListeners().get(0).getAddresses().get(1).getPort(), is(31234));
        assertThat(status.getListeners().get(0).getAddresses().get(1).getHost(), is("5.124.16.8"));
        assertThat(status.getListeners().get(0).getAddresses().get(2).getPort(), is(31234));
        assertThat(status.getListeners().get(0).getAddresses().get(2).getHost(), is("my-address-1"));
        async.flag();
    }));
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) GenericKafkaListenerConfigurationBrokerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder) PodOperator(io.strimzi.operator.common.operator.resource.PodOperator) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) ArrayList(java.util.ArrayList) GenericKafkaListenerConfigurationBroker(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBroker) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) Labels(io.strimzi.operator.common.model.Labels) SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) Secret(io.fabric8.kubernetes.api.model.Secret) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) Checkpoint(io.vertx.junit5.Checkpoint) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Reconciliation(io.strimzi.operator.common.Reconciliation) NodeOperator(io.strimzi.operator.common.operator.resource.NodeOperator) KafkaStatus(io.strimzi.api.kafka.model.status.KafkaStatus) Test(org.junit.jupiter.api.Test)

Example 40 with GenericKafkaListenerConfigurationBrokerBuilder

use of io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder in project strimzi-kafka-operator by strimzi.

the class KafkaClusterTest method testExternalIngressMissingConfiguration.

@ParallelTest
public void testExternalIngressMissingConfiguration() {
    GenericKafkaListenerConfigurationBroker broker0 = new GenericKafkaListenerConfigurationBrokerBuilder().withBroker(0).build();
    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withListeners(new GenericKafkaListenerBuilder().withName("external").withPort(9094).withType(KafkaListenerType.INGRESS).withTls(true).withNewConfiguration().withIngressClass("nginx-internal").withNewBootstrap().withHost("my-kafka-bootstrap.com").withAnnotations(Collections.singletonMap("dns-annotation", "my-kafka-bootstrap.com")).endBootstrap().withBrokers(broker0).endConfiguration().build()).endKafka().endSpec().build();
    assertThrows(InvalidResourceException.class, () -> KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS));
}
Also used : GenericKafkaListenerConfigurationBrokerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) GenericKafkaListenerConfigurationBroker(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBroker) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)48 GenericKafkaListenerConfigurationBrokerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBrokerBuilder)48 ParallelTest (io.strimzi.test.annotations.ParallelTest)30 Kafka (io.strimzi.api.kafka.model.Kafka)26 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)24 GenericKafkaListenerConfigurationBroker (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBroker)22 GenericKafkaListener (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener)18 Labels (io.strimzi.operator.common.model.Labels)14 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)12 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)12 Reconciliation (io.strimzi.operator.common.Reconciliation)12 Checkpoint (io.vertx.junit5.Checkpoint)12 Test (org.junit.jupiter.api.Test)12 KafkaListenerType (io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType)10 CoreMatchers.is (org.hamcrest.CoreMatchers.is)10 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)10 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)9 KafkaCluster (io.strimzi.operator.cluster.model.KafkaCluster)9 GenericKafkaListenerConfigurationBootstrapBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerConfigurationBootstrapBuilder)7 KubernetesVersion (io.strimzi.operator.KubernetesVersion)7