Search in sources :

Example 21 with BridgeClients

use of io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients in project strimzi-kafka-operator by strimzi.

the class OauthPlainIsolatedST method testProducerConsumerBridge.

@Description("As a oauth bridge, I should be able to send messages to bridge endpoint.")
@ParallelTest
@Tag(BRIDGE)
void testProducerConsumerBridge(ExtensionContext extensionContext) {
    String kafkaClientsName = mapWithKafkaClientNames.get(extensionContext.getDisplayName());
    String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    String producerName = OAUTH_PRODUCER_NAME + "-" + clusterName;
    String consumerName = OAUTH_CONSUMER_NAME + "-" + clusterName;
    String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
    KafkaOauthClients oauthExampleClients = new KafkaOauthClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(producerName).withConsumerName(consumerName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(oauthClusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withOauthClientId(OAUTH_CLIENT_NAME).withOauthClientSecret(OAUTH_CLIENT_SECRET).withOauthTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri()).build();
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(oauthClusterName, topicName, INFRA_NAMESPACE).build());
    resourceManager.createResource(extensionContext, oauthExampleClients.producerStrimziOauthPlain());
    ClientUtils.waitForClientSuccess(producerName, INFRA_NAMESPACE, MESSAGE_COUNT);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, producerName);
    resourceManager.createResource(extensionContext, oauthExampleClients.consumerStrimziOauthPlain());
    ClientUtils.waitForClientSuccess(consumerName, INFRA_NAMESPACE, MESSAGE_COUNT);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, consumerName);
    resourceManager.createResource(extensionContext, KafkaClientsTemplates.kafkaClients(INFRA_NAMESPACE, false, kafkaClientsName).build());
    // needed for a verification of oauth configuration
    InlineLogging ilDebug = new InlineLogging();
    ilDebug.setLoggers(Map.of("rootLogger.level", "DEBUG"));
    resourceManager.createResource(extensionContext, KafkaBridgeTemplates.kafkaBridge(oauthClusterName, KafkaResources.plainBootstrapAddress(oauthClusterName), 1).editMetadata().withNamespace(INFRA_NAMESPACE).endMetadata().editSpec().withNewKafkaClientAuthenticationOAuth().withTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri()).withClientId("kafka-bridge").withNewClientSecret().withSecretName(BRIDGE_OAUTH_SECRET).withKey(OAUTH_KEY).endClientSecret().withConnectTimeoutSeconds(CONNECT_TIMEOUT_S).withReadTimeoutSeconds(READ_TIMEOUT_S).endKafkaClientAuthenticationOAuth().withLogging(ilDebug).endSpec().build());
    final String kafkaBridgePodName = kubeClient(INFRA_NAMESPACE).listPods(INFRA_NAMESPACE, oauthClusterName, Labels.STRIMZI_KIND_LABEL, KafkaBridge.RESOURCE_KIND).get(0).getMetadata().getName();
    final String kafkaBridgeLogs = KubeClusterResource.cmdKubeClient(INFRA_NAMESPACE).execInCurrentNamespace(Level.DEBUG, "logs", kafkaBridgePodName).out();
    verifyOauthConfiguration(kafkaBridgeLogs);
    String bridgeProducerName = "bridge-producer-" + clusterName;
    BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(bridgeProducerName).withBootstrapAddress(KafkaBridgeResources.serviceName(oauthClusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withPort(HTTP_BRIDGE_DEFAULT_PORT).withDelayMs(1000).withPollInterval(1000).build();
    resourceManager.createResource(extensionContext, kafkaBridgeClientJob.producerStrimziBridge());
    ClientUtils.waitForClientSuccess(bridgeProducerName, INFRA_NAMESPACE, MESSAGE_COUNT);
    JobUtils.deleteJobWithWait(INFRA_NAMESPACE, bridgeProducerName);
}
Also used : KafkaOauthClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClientsBuilder) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) InlineLogging(io.strimzi.api.kafka.model.InlineLogging) KafkaOauthClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClients) Description(io.vertx.core.cli.annotations.Description) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

Example 22 with BridgeClients

use of io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients in project strimzi-kafka-operator by strimzi.

the class TracingST method testKafkaBridgeService.

@Tag(BRIDGE)
@ParallelNamespaceTest
void testKafkaBridgeService(ExtensionContext extensionContext) {
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(storageMap.get(extensionContext).getClusterName(), 3, 1).build());
    // Deploy http bridge
    resourceManager.createResource(extensionContext, KafkaBridgeTemplates.kafkaBridge(storageMap.get(extensionContext).getClusterName(), KafkaResources.plainBootstrapAddress(storageMap.get(extensionContext).getClusterName()), 1).editSpec().withNewJaegerTracing().endJaegerTracing().withNewTemplate().withNewBridgeContainer().addNewEnv().withName("JAEGER_SERVICE_NAME").withValue(JAEGER_KAFKA_BRIDGE_SERVICE).endEnv().addNewEnv().withName("JAEGER_AGENT_HOST").withValue(JAEGER_AGENT_NAME).endEnv().addNewEnv().withName("JAEGER_SAMPLER_TYPE").withValue(JAEGER_SAMPLER_TYPE).endEnv().addNewEnv().withName("JAEGER_SAMPLER_PARAM").withValue(JAEGER_SAMPLER_PARAM).endEnv().endBridgeContainer().endTemplate().endSpec().build());
    String bridgeProducer = "bridge-producer";
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(storageMap.get(extensionContext).getClusterName(), storageMap.get(extensionContext).getTopicName()).build());
    BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withProducerName(bridgeProducer).withNamespaceName(storageMap.get(extensionContext).getNamespaceName()).withBootstrapAddress(KafkaBridgeResources.serviceName(storageMap.get(extensionContext).getClusterName())).withTopicName(storageMap.get(extensionContext).getTopicName()).withMessageCount(MESSAGE_COUNT).withPort(Constants.HTTP_BRIDGE_DEFAULT_PORT).withDelayMs(1000).withPollInterval(1000).build();
    resourceManager.createResource(extensionContext, kafkaBridgeClientJob.producerStrimziBridge());
    resourceManager.createResource(extensionContext, ((KafkaTracingClients) storageMap.get(extensionContext).retrieveFromTestStorage(KAFKA_TRACING_CLIENT_KEY)).consumerWithTracing());
    ClientUtils.waitForClientSuccess(bridgeProducer, storageMap.get(extensionContext).getNamespaceName(), MESSAGE_COUNT);
    TracingUtils.verify(storageMap.get(extensionContext).getNamespaceName(), JAEGER_KAFKA_BRIDGE_SERVICE, storageMap.get(extensionContext).retrieveFromTestStorage(Constants.KAFKA_CLIENTS_POD_KEY).toString(), JAEGER_QUERY_SERVICE);
}
Also used : BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) Tag(org.junit.jupiter.api.Tag)

Aggregations

BridgeClients (io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients)22 BridgeClientsBuilder (io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder)22 ParallelTest (io.strimzi.systemtest.annotations.ParallelTest)20 InternalKafkaClient (io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient)12 Tag (org.junit.jupiter.api.Tag)10 Random (java.util.Random)6 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)4 KafkaOauthClients (io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClients)4 KafkaOauthClientsBuilder (io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClientsBuilder)4 Description (io.vertx.core.cli.annotations.Description)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Service (io.fabric8.kubernetes.api.model.Service)2 CertSecretSource (io.strimzi.api.kafka.model.CertSecretSource)2 CertSecretSourceBuilder (io.strimzi.api.kafka.model.CertSecretSourceBuilder)2 KafkaBridgeResources (io.strimzi.api.kafka.model.KafkaBridgeResources)2 KafkaBridgeSpec (io.strimzi.api.kafka.model.KafkaBridgeSpec)2 KafkaBridgeSpecBuilder (io.strimzi.api.kafka.model.KafkaBridgeSpecBuilder)2 KafkaResources (io.strimzi.api.kafka.model.KafkaResources)2 PasswordSecretSource (io.strimzi.api.kafka.model.PasswordSecretSource)2 KafkaListenerAuthentication (io.strimzi.api.kafka.model.listener.KafkaListenerAuthentication)2