Search in sources :

Example 1 with BRIDGE

use of io.strimzi.systemtest.Constants.BRIDGE in project strimzi by strimzi.

the class HttpBridgeIsolatedST method testCustomBridgeLabelsAreProperlySet.

@ParallelTest
void testCustomBridgeLabelsAreProperlySet(ExtensionContext extensionContext) {
    final String bridgeName = "bridge-" + mapWithClusterNames.get(extensionContext.getDisplayName());
    resourceManager.createResource(extensionContext, KafkaBridgeTemplates.kafkaBridge(bridgeName, KafkaResources.plainBootstrapAddress(httpBridgeClusterName), 1).editMetadata().withNamespace(INFRA_NAMESPACE).endMetadata().build());
    // get service with custom labels
    final Service kafkaBridgeService = kubeClient(INFRA_NAMESPACE).getService(INFRA_NAMESPACE, KafkaBridgeResources.serviceName(bridgeName));
    // filter only app-bar service
    final Map<String, String> filteredActualKafkaBridgeCustomLabels = kafkaBridgeService.getMetadata().getLabels().entrySet().stream().filter(item -> item.getKey().equals("app") && item.getValue().equals("bar")).collect(Collectors.toMap(item -> item.getKey(), item -> item.getValue()));
    final Map<String, String> filteredActualKafkaBridgeCustomAnnotations = kafkaBridgeService.getMetadata().getAnnotations().entrySet().stream().filter(item -> item.getKey().equals("bar") && item.getValue().equals("app")).collect(Collectors.toMap(item -> item.getKey(), item -> item.getValue()));
    // verify phase: that inside KafkaBridge we can find 'exceptedKafkaBridgeCustomLabels' and 'exceptedKafkaBridgeCustomAnnotations' previously defined
    assertThat(filteredActualKafkaBridgeCustomLabels.size(), is(Collections.singletonMap("app", "bar").size()));
    assertThat(filteredActualKafkaBridgeCustomAnnotations.size(), is(Collections.singletonMap("bar", "app").size()));
    assertThat(filteredActualKafkaBridgeCustomLabels, is(Collections.singletonMap("app", "bar")));
    assertThat(filteredActualKafkaBridgeCustomAnnotations, is(Collections.singletonMap("bar", "app")));
}
Also used : ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Arrays(java.util.Arrays) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Random(java.util.Random) INFRA_NAMESPACE(io.strimzi.systemtest.Constants.INFRA_NAMESPACE) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) StUtils(io.strimzi.systemtest.utils.StUtils) BeforeAllOnce(io.strimzi.systemtest.BeforeAllOnce) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) KafkaBridgeResource(io.strimzi.systemtest.resources.crd.KafkaBridgeResource) Logger(org.apache.logging.log4j.Logger) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) AbstractST(io.strimzi.systemtest.AbstractST) Environment(io.strimzi.systemtest.Environment) KafkaClientsTemplates(io.strimzi.systemtest.templates.crd.KafkaClientsTemplates) CoreMatchers.not(org.hamcrest.CoreMatchers.not) HashMap(java.util.HashMap) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) LinkedHashMap(java.util.LinkedHashMap) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) DeploymentStrategy(io.strimzi.api.kafka.model.template.DeploymentStrategy) Service(io.fabric8.kubernetes.api.model.Service) KafkaBridgeUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaBridgeUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Ready(io.strimzi.systemtest.enums.CustomResourceStatus.Ready) InternalKafkaClient(io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient) Constants(io.strimzi.systemtest.Constants) SetupClusterOperator(io.strimzi.systemtest.resources.operator.SetupClusterOperator) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) KafkaBridgeStatus(io.strimzi.api.kafka.model.status.KafkaBridgeStatus) JsonArray(io.vertx.core.json.JsonArray) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) Service(io.fabric8.kubernetes.api.model.Service) Matchers.containsString(org.hamcrest.Matchers.containsString) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 2 with BRIDGE

use of io.strimzi.systemtest.Constants.BRIDGE in project strimzi-kafka-operator by strimzi.

the class HttpBridgeIsolatedST method testCustomBridgeLabelsAreProperlySet.

@ParallelTest
void testCustomBridgeLabelsAreProperlySet(ExtensionContext extensionContext) {
    final String bridgeName = "bridge-" + mapWithClusterNames.get(extensionContext.getDisplayName());
    resourceManager.createResource(extensionContext, KafkaBridgeTemplates.kafkaBridge(bridgeName, KafkaResources.plainBootstrapAddress(httpBridgeClusterName), 1).editMetadata().withNamespace(INFRA_NAMESPACE).endMetadata().build());
    // get service with custom labels
    final Service kafkaBridgeService = kubeClient(INFRA_NAMESPACE).getService(INFRA_NAMESPACE, KafkaBridgeResources.serviceName(bridgeName));
    // filter only app-bar service
    final Map<String, String> filteredActualKafkaBridgeCustomLabels = kafkaBridgeService.getMetadata().getLabels().entrySet().stream().filter(item -> item.getKey().equals("app") && item.getValue().equals("bar")).collect(Collectors.toMap(item -> item.getKey(), item -> item.getValue()));
    final Map<String, String> filteredActualKafkaBridgeCustomAnnotations = kafkaBridgeService.getMetadata().getAnnotations().entrySet().stream().filter(item -> item.getKey().equals("bar") && item.getValue().equals("app")).collect(Collectors.toMap(item -> item.getKey(), item -> item.getValue()));
    // verify phase: that inside KafkaBridge we can find 'exceptedKafkaBridgeCustomLabels' and 'exceptedKafkaBridgeCustomAnnotations' previously defined
    assertThat(filteredActualKafkaBridgeCustomLabels.size(), is(Collections.singletonMap("app", "bar").size()));
    assertThat(filteredActualKafkaBridgeCustomAnnotations.size(), is(Collections.singletonMap("bar", "app").size()));
    assertThat(filteredActualKafkaBridgeCustomLabels, is(Collections.singletonMap("app", "bar")));
    assertThat(filteredActualKafkaBridgeCustomAnnotations, is(Collections.singletonMap("bar", "app")));
}
Also used : ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Arrays(java.util.Arrays) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Random(java.util.Random) INFRA_NAMESPACE(io.strimzi.systemtest.Constants.INFRA_NAMESPACE) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) StUtils(io.strimzi.systemtest.utils.StUtils) BeforeAllOnce(io.strimzi.systemtest.BeforeAllOnce) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) KafkaBridgeResource(io.strimzi.systemtest.resources.crd.KafkaBridgeResource) Logger(org.apache.logging.log4j.Logger) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) AbstractST(io.strimzi.systemtest.AbstractST) Environment(io.strimzi.systemtest.Environment) KafkaClientsTemplates(io.strimzi.systemtest.templates.crd.KafkaClientsTemplates) CoreMatchers.not(org.hamcrest.CoreMatchers.not) HashMap(java.util.HashMap) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) LinkedHashMap(java.util.LinkedHashMap) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) DeploymentStrategy(io.strimzi.api.kafka.model.template.DeploymentStrategy) Service(io.fabric8.kubernetes.api.model.Service) KafkaBridgeUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaBridgeUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Ready(io.strimzi.systemtest.enums.CustomResourceStatus.Ready) InternalKafkaClient(io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient) Constants(io.strimzi.systemtest.Constants) SetupClusterOperator(io.strimzi.systemtest.resources.operator.SetupClusterOperator) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) KafkaBridgeStatus(io.strimzi.api.kafka.model.status.KafkaBridgeStatus) JsonArray(io.vertx.core.json.JsonArray) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) Service(io.fabric8.kubernetes.api.model.Service) Matchers.containsString(org.hamcrest.Matchers.containsString) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 3 with BRIDGE

use of io.strimzi.systemtest.Constants.BRIDGE in project strimzi by strimzi.

the class HttpBridgeKafkaExternalListenersST method testWeirdUsername.

@SuppressWarnings({ "checkstyle:MethodLength" })
private void testWeirdUsername(ExtensionContext extensionContext, String weirdUserName, KafkaListenerAuthentication auth, KafkaBridgeSpec spec, SecurityProtocol securityProtocol) {
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3, 1).editMetadata().withNamespace(namespace).endMetadata().editSpec().editKafka().withListeners(new GenericKafkaListenerBuilder().withName(Constants.TLS_LISTENER_DEFAULT_NAME).withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).withAuth(auth).build(), new GenericKafkaListenerBuilder().withName(Constants.EXTERNAL_LISTENER_DEFAULT_NAME).withPort(9094).withType(KafkaListenerType.NODEPORT).withTls(true).withAuth(auth).build()).endKafka().endSpec().build());
    BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withProducerName(clusterName + "-" + producerName).withConsumerName(clusterName + "-" + consumerName).withBootstrapAddress(KafkaBridgeResources.serviceName(clusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withPort(Constants.HTTP_BRIDGE_DEFAULT_PORT).withNamespaceName(namespace).build();
    // Create topic
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(clusterName, topicName).editMetadata().withNamespace(namespace).endMetadata().build());
    // Create user
    if (auth.getType().equals(Constants.TLS_LISTENER_DEFAULT_NAME)) {
        resourceManager.createResource(extensionContext, KafkaUserTemplates.tlsUser(clusterName, weirdUserName).editMetadata().withNamespace(namespace).endMetadata().build());
    } else {
        resourceManager.createResource(extensionContext, KafkaUserTemplates.scramShaUser(clusterName, weirdUserName).editMetadata().withNamespace(namespace).endMetadata().build());
    }
    final String kafkaClientsName = mapWithKafkaClientNames.get(extensionContext.getDisplayName());
    resourceManager.createResource(extensionContext, KafkaClientsTemplates.kafkaClients(namespace, true, kafkaClientsName).build());
    // Deploy http bridge
    resourceManager.createResource(extensionContext, KafkaBridgeTemplates.kafkaBridge(clusterName, KafkaResources.tlsBootstrapAddress(clusterName), 1).editMetadata().withNamespace(namespace).endMetadata().withNewSpecLike(spec).withBootstrapServers(KafkaResources.tlsBootstrapAddress(clusterName)).withNewHttp(Constants.HTTP_BRIDGE_DEFAULT_PORT).withNewConsumer().addToConfig(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest").endConsumer().endSpec().build());
    final Service service = KafkaBridgeUtils.createBridgeNodePortService(clusterName, namespace, BRIDGE_EXTERNAL_SERVICE);
    ServiceResource.createServiceResource(extensionContext, service, namespace);
    resourceManager.createResource(extensionContext, kafkaBridgeClientJob.consumerStrimziBridge());
    final String kafkaProducerExternalName = "kafka-producer-external" + new Random().nextInt(Integer.MAX_VALUE);
    final List<ListenerStatus> listenerStatusList = KafkaResource.kafkaClient().inNamespace(namespace).withName(clusterName).get().getStatus().getListeners();
    final String externalBootstrapServers = listenerStatusList.stream().filter(listener -> listener.getType().equals(Constants.EXTERNAL_LISTENER_DEFAULT_NAME)).findFirst().orElseThrow(RuntimeException::new).getBootstrapServers();
    final KafkaClients externalKafkaProducer = new KafkaClientsBuilder().withProducerName(kafkaProducerExternalName).withBootstrapAddress(externalBootstrapServers).withNamespaceName(namespace).withTopicName(topicName).withMessageCount(100).build();
    if (auth.getType().equals(Constants.TLS_LISTENER_DEFAULT_NAME)) {
        // tls producer
        resourceManager.createResource(extensionContext, externalKafkaProducer.producerTlsStrimzi(clusterName, weirdUserName));
    } else {
        // scram-sha producer
        resourceManager.createResource(extensionContext, externalKafkaProducer.producerScramShaStrimzi(clusterName, weirdUserName));
    }
    ClientUtils.waitForClientSuccess(kafkaProducerExternalName, namespace, MESSAGE_COUNT);
    // delete kafka producer job
    JobUtils.deleteJobWithWait(namespace, kafkaProducerExternalName);
    ClientUtils.waitForClientSuccess(clusterName + "-" + consumerName, namespace, MESSAGE_COUNT);
}
Also used : AbstractST(io.strimzi.systemtest.AbstractST) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) KafkaClientsTemplates(io.strimzi.systemtest.templates.crd.KafkaClientsTemplates) ParallelSuite(io.strimzi.systemtest.annotations.ParallelSuite) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KafkaListenerAuthentication(io.strimzi.api.kafka.model.listener.KafkaListenerAuthentication) Random(java.util.Random) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) SecurityProtocol(org.apache.kafka.common.security.auth.SecurityProtocol) KafkaListenerAuthenticationTls(io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationTls) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) Service(io.fabric8.kubernetes.api.model.Service) KafkaBridgeUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaBridgeUtils) Tag(org.junit.jupiter.api.Tag) KafkaListenerAuthenticationScramSha512(io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512) NODEPORT_SUPPORTED(io.strimzi.systemtest.Constants.NODEPORT_SUPPORTED) ServiceResource(io.strimzi.systemtest.resources.kubernetes.ServiceResource) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) KafkaBridgeSpecBuilder(io.strimzi.api.kafka.model.KafkaBridgeSpecBuilder) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) CertSecretSource(io.strimzi.api.kafka.model.CertSecretSource) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) JobUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.JobUtils) Constants(io.strimzi.systemtest.Constants) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) EXTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.EXTERNAL_CLIENTS_USED) KafkaBridgeSpec(io.strimzi.api.kafka.model.KafkaBridgeSpec) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) ListenerStatus(io.strimzi.api.kafka.model.status.ListenerStatus) List(java.util.List) Logger(org.apache.logging.log4j.Logger) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) LogManager(org.apache.logging.log4j.LogManager) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) ListenerStatus(io.strimzi.api.kafka.model.status.ListenerStatus) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) Random(java.util.Random) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Service(io.fabric8.kubernetes.api.model.Service) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients)

Example 4 with BRIDGE

use of io.strimzi.systemtest.Constants.BRIDGE in project strimzi-kafka-operator by strimzi.

the class HttpBridgeKafkaExternalListenersST method testWeirdUsername.

@SuppressWarnings({ "checkstyle:MethodLength" })
private void testWeirdUsername(ExtensionContext extensionContext, String weirdUserName, KafkaListenerAuthentication auth, KafkaBridgeSpec spec, SecurityProtocol securityProtocol) {
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3, 1).editMetadata().withNamespace(namespace).endMetadata().editSpec().editKafka().withListeners(new GenericKafkaListenerBuilder().withName(Constants.TLS_LISTENER_DEFAULT_NAME).withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).withAuth(auth).build(), new GenericKafkaListenerBuilder().withName(Constants.EXTERNAL_LISTENER_DEFAULT_NAME).withPort(9094).withType(KafkaListenerType.NODEPORT).withTls(true).withAuth(auth).build()).endKafka().endSpec().build());
    BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withProducerName(clusterName + "-" + producerName).withConsumerName(clusterName + "-" + consumerName).withBootstrapAddress(KafkaBridgeResources.serviceName(clusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withPort(Constants.HTTP_BRIDGE_DEFAULT_PORT).withNamespaceName(namespace).build();
    // Create topic
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(clusterName, topicName).editMetadata().withNamespace(namespace).endMetadata().build());
    // Create user
    if (auth.getType().equals(Constants.TLS_LISTENER_DEFAULT_NAME)) {
        resourceManager.createResource(extensionContext, KafkaUserTemplates.tlsUser(clusterName, weirdUserName).editMetadata().withNamespace(namespace).endMetadata().build());
    } else {
        resourceManager.createResource(extensionContext, KafkaUserTemplates.scramShaUser(clusterName, weirdUserName).editMetadata().withNamespace(namespace).endMetadata().build());
    }
    final String kafkaClientsName = mapWithKafkaClientNames.get(extensionContext.getDisplayName());
    resourceManager.createResource(extensionContext, KafkaClientsTemplates.kafkaClients(namespace, true, kafkaClientsName).build());
    // Deploy http bridge
    resourceManager.createResource(extensionContext, KafkaBridgeTemplates.kafkaBridge(clusterName, KafkaResources.tlsBootstrapAddress(clusterName), 1).editMetadata().withNamespace(namespace).endMetadata().withNewSpecLike(spec).withBootstrapServers(KafkaResources.tlsBootstrapAddress(clusterName)).withNewHttp(Constants.HTTP_BRIDGE_DEFAULT_PORT).withNewConsumer().addToConfig(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest").endConsumer().endSpec().build());
    final Service service = KafkaBridgeUtils.createBridgeNodePortService(clusterName, namespace, BRIDGE_EXTERNAL_SERVICE);
    ServiceResource.createServiceResource(extensionContext, service, namespace);
    resourceManager.createResource(extensionContext, kafkaBridgeClientJob.consumerStrimziBridge());
    final String kafkaProducerExternalName = "kafka-producer-external" + new Random().nextInt(Integer.MAX_VALUE);
    final List<ListenerStatus> listenerStatusList = KafkaResource.kafkaClient().inNamespace(namespace).withName(clusterName).get().getStatus().getListeners();
    final String externalBootstrapServers = listenerStatusList.stream().filter(listener -> listener.getType().equals(Constants.EXTERNAL_LISTENER_DEFAULT_NAME)).findFirst().orElseThrow(RuntimeException::new).getBootstrapServers();
    final KafkaClients externalKafkaProducer = new KafkaClientsBuilder().withProducerName(kafkaProducerExternalName).withBootstrapAddress(externalBootstrapServers).withNamespaceName(namespace).withTopicName(topicName).withMessageCount(100).build();
    if (auth.getType().equals(Constants.TLS_LISTENER_DEFAULT_NAME)) {
        // tls producer
        resourceManager.createResource(extensionContext, externalKafkaProducer.producerTlsStrimzi(clusterName, weirdUserName));
    } else {
        // scram-sha producer
        resourceManager.createResource(extensionContext, externalKafkaProducer.producerScramShaStrimzi(clusterName, weirdUserName));
    }
    ClientUtils.waitForClientSuccess(kafkaProducerExternalName, namespace, MESSAGE_COUNT);
    // delete kafka producer job
    JobUtils.deleteJobWithWait(namespace, kafkaProducerExternalName);
    ClientUtils.waitForClientSuccess(clusterName + "-" + consumerName, namespace, MESSAGE_COUNT);
}
Also used : AbstractST(io.strimzi.systemtest.AbstractST) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) KafkaClientsTemplates(io.strimzi.systemtest.templates.crd.KafkaClientsTemplates) ParallelSuite(io.strimzi.systemtest.annotations.ParallelSuite) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KafkaListenerAuthentication(io.strimzi.api.kafka.model.listener.KafkaListenerAuthentication) Random(java.util.Random) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) SecurityProtocol(org.apache.kafka.common.security.auth.SecurityProtocol) KafkaListenerAuthenticationTls(io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationTls) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) Service(io.fabric8.kubernetes.api.model.Service) KafkaBridgeUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaBridgeUtils) Tag(org.junit.jupiter.api.Tag) KafkaListenerAuthenticationScramSha512(io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationScramSha512) NODEPORT_SUPPORTED(io.strimzi.systemtest.Constants.NODEPORT_SUPPORTED) ServiceResource(io.strimzi.systemtest.resources.kubernetes.ServiceResource) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) KafkaBridgeSpecBuilder(io.strimzi.api.kafka.model.KafkaBridgeSpecBuilder) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) CertSecretSource(io.strimzi.api.kafka.model.CertSecretSource) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) JobUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.JobUtils) Constants(io.strimzi.systemtest.Constants) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) EXTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.EXTERNAL_CLIENTS_USED) KafkaBridgeSpec(io.strimzi.api.kafka.model.KafkaBridgeSpec) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) ListenerStatus(io.strimzi.api.kafka.model.status.ListenerStatus) List(java.util.List) Logger(org.apache.logging.log4j.Logger) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) LogManager(org.apache.logging.log4j.LogManager) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) ListenerStatus(io.strimzi.api.kafka.model.status.ListenerStatus) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) Random(java.util.Random) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Service(io.fabric8.kubernetes.api.model.Service) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients)

Aggregations

Service (io.fabric8.kubernetes.api.model.Service)4 KafkaBridgeResources (io.strimzi.api.kafka.model.KafkaBridgeResources)4 KafkaResources (io.strimzi.api.kafka.model.KafkaResources)4 AbstractST (io.strimzi.systemtest.AbstractST)4 Constants (io.strimzi.systemtest.Constants)4 BRIDGE (io.strimzi.systemtest.Constants.BRIDGE)4 REGRESSION (io.strimzi.systemtest.Constants.REGRESSION)4 ParallelTest (io.strimzi.systemtest.annotations.ParallelTest)4 BridgeClients (io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients)4 BridgeClientsBuilder (io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder)4 KafkaBridgeTemplates (io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates)4 KafkaClientsTemplates (io.strimzi.systemtest.templates.crd.KafkaClientsTemplates)4 KafkaTemplates (io.strimzi.systemtest.templates.crd.KafkaTemplates)4 KafkaTopicTemplates (io.strimzi.systemtest.templates.crd.KafkaTopicTemplates)4 ClientUtils (io.strimzi.systemtest.utils.ClientUtils)4 KafkaBridgeUtils (io.strimzi.systemtest.utils.kafkaUtils.KafkaBridgeUtils)4 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)2 CertSecretSource (io.strimzi.api.kafka.model.CertSecretSource)2 KafkaBridge (io.strimzi.api.kafka.model.KafkaBridge)2 KafkaBridgeSpec (io.strimzi.api.kafka.model.KafkaBridgeSpec)2