use of io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients in project strimzi-kafka-operator by strimzi.
the class HttpBridgeIsolatedST method testSendSimpleMessage.
@ParallelTest
void testSendSimpleMessage(ExtensionContext extensionContext) {
final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
final String producerName = "producer-" + new Random().nextInt(Integer.MAX_VALUE);
final BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withProducerName(producerName).withBootstrapAddress(KafkaBridgeResources.serviceName(httpBridgeClusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withPort(Constants.HTTP_BRIDGE_DEFAULT_PORT).withDelayMs(1000).withPollInterval(1000).withNamespaceName(INFRA_NAMESPACE).build();
// Create topic
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(httpBridgeClusterName, topicName).editMetadata().withNamespace(INFRA_NAMESPACE).endMetadata().build());
resourceManager.createResource(extensionContext, kafkaBridgeClientJob.producerStrimziBridge());
ClientUtils.waitForClientSuccess(producerName, INFRA_NAMESPACE, MESSAGE_COUNT);
InternalKafkaClient internalKafkaClient = new InternalKafkaClient.Builder().withTopicName(topicName).withNamespaceName(INFRA_NAMESPACE).withClusterName(httpBridgeClusterName).withMessageCount(MESSAGE_COUNT).withKafkaUsername(USER_NAME).withUsingPodName(kafkaClientsPodName).withListenerName(Constants.PLAIN_LISTENER_DEFAULT_NAME).build();
assertThat(internalKafkaClient.receiveMessagesPlain(), is(MESSAGE_COUNT));
// Checking labels for Kafka Bridge
verifyLabelsOnPods(INFRA_NAMESPACE, httpBridgeClusterName, "my-bridge", "KafkaBridge");
verifyLabelsForService(INFRA_NAMESPACE, httpBridgeClusterName, "my-bridge", "KafkaBridge");
}
use of io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients 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);
}
use of io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients in project strimzi by strimzi.
the class HttpBridgeTlsST method testReceiveSimpleMessageTls.
@ParallelTest
void testReceiveSimpleMessageTls(ExtensionContext extensionContext) {
String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
BridgeClients kafkaBridgeClientJobConsume = new BridgeClientsBuilder(kafkaBridgeClientJob).withTopicName(topicName).build();
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(httpBridgeTlsClusterName, topicName).editMetadata().withNamespace(namespace).endMetadata().build());
resourceManager.createResource(extensionContext, kafkaBridgeClientJobConsume.consumerStrimziBridge());
// Send messages to Kafka
InternalKafkaClient internalKafkaClient = new InternalKafkaClient.Builder().withTopicName(topicName).withNamespaceName(namespace).withClusterName(httpBridgeTlsClusterName).withMessageCount(MESSAGE_COUNT).withSecurityProtocol(SecurityProtocol.SSL).withKafkaUsername(sharedKafkaUserName).withUsingPodName(kafkaClientsPodName).withListenerName(Constants.TLS_LISTENER_DEFAULT_NAME).build();
assertThat(internalKafkaClient.sendMessagesTls(), is(MESSAGE_COUNT));
ClientUtils.waitForClientSuccess(consumerName, namespace, MESSAGE_COUNT);
}
use of io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients in project strimzi by strimzi.
the class HttpBridgeIsolatedST method testSendSimpleMessage.
@ParallelTest
void testSendSimpleMessage(ExtensionContext extensionContext) {
final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
final String producerName = "producer-" + new Random().nextInt(Integer.MAX_VALUE);
final BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withProducerName(producerName).withBootstrapAddress(KafkaBridgeResources.serviceName(httpBridgeClusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withPort(Constants.HTTP_BRIDGE_DEFAULT_PORT).withDelayMs(1000).withPollInterval(1000).withNamespaceName(INFRA_NAMESPACE).build();
// Create topic
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(httpBridgeClusterName, topicName).editMetadata().withNamespace(INFRA_NAMESPACE).endMetadata().build());
resourceManager.createResource(extensionContext, kafkaBridgeClientJob.producerStrimziBridge());
ClientUtils.waitForClientSuccess(producerName, INFRA_NAMESPACE, MESSAGE_COUNT);
InternalKafkaClient internalKafkaClient = new InternalKafkaClient.Builder().withTopicName(topicName).withNamespaceName(INFRA_NAMESPACE).withClusterName(httpBridgeClusterName).withMessageCount(MESSAGE_COUNT).withKafkaUsername(USER_NAME).withUsingPodName(kafkaClientsPodName).withListenerName(Constants.PLAIN_LISTENER_DEFAULT_NAME).build();
assertThat(internalKafkaClient.receiveMessagesPlain(), is(MESSAGE_COUNT));
// Checking labels for Kafka Bridge
verifyLabelsOnPods(INFRA_NAMESPACE, httpBridgeClusterName, "my-bridge", "KafkaBridge");
verifyLabelsForService(INFRA_NAMESPACE, httpBridgeClusterName, "my-bridge", "KafkaBridge");
}
use of io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients in project strimzi by strimzi.
the class HttpBridgeIsolatedST method testReceiveSimpleMessage.
@ParallelTest
void testReceiveSimpleMessage(ExtensionContext extensionContext) {
final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
final String consumerName = "consumer-" + new Random().nextInt(Integer.MAX_VALUE);
resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(httpBridgeClusterName, topicName).editMetadata().withNamespace(INFRA_NAMESPACE).endMetadata().build());
final BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withConsumerName(consumerName).withBootstrapAddress(KafkaBridgeResources.serviceName(httpBridgeClusterName)).withTopicName(topicName).withMessageCount(MESSAGE_COUNT).withPort(Constants.HTTP_BRIDGE_DEFAULT_PORT).withDelayMs(1000).withPollInterval(1000).withNamespaceName(INFRA_NAMESPACE).build();
resourceManager.createResource(extensionContext, kafkaBridgeClientJob.consumerStrimziBridge());
// Send messages to Kafka
InternalKafkaClient internalKafkaClient = new InternalKafkaClient.Builder().withTopicName(topicName).withNamespaceName(INFRA_NAMESPACE).withClusterName(httpBridgeClusterName).withMessageCount(MESSAGE_COUNT).withKafkaUsername(USER_NAME).withUsingPodName(kafkaClientsPodName).withListenerName(Constants.PLAIN_LISTENER_DEFAULT_NAME).build();
assertThat(internalKafkaClient.sendMessagesPlain(), is(MESSAGE_COUNT));
ClientUtils.waitForClientSuccess(consumerName, INFRA_NAMESPACE, MESSAGE_COUNT);
}
Aggregations