use of io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder in project strimzi-kafka-operator by strimzi.
the class ThrottlingQuotaST method testThrottlingQuotasCreateTopic.
/**
* Test checks for throttling quotas set for user
* on creation & deletion of topics and create partition operations.
*/
@ParallelTest
void testThrottlingQuotasCreateTopic(ExtensionContext extensionContext) {
final String kafkaUsername = mapWithTestUsers.get(extensionContext.getDisplayName());
final String createAdminName = "create-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
final String topicNamePrefix = classTopicPrefix + "-create";
int topicsCountOverQuota = 500;
setupKafkaUserInNamespace(extensionContext, kafkaUsername);
KafkaAdminClients adminClientJob = new KafkaAdminClientsBuilder().withAdminName(createAdminName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withTopicName(topicNamePrefix).withTopicCount(topicsCountOverQuota).withNamespaceName(namespace).withTopicOperation(AdminClientOperations.CREATE_TOPICS.toString()).withAdditionalConfig(KafkaAdminClients.getAdminClientScramConfig(namespace, kafkaUsername, 240000)).build();
resourceManager.createResource(extensionContext, adminClientJob.defaultAdmin());
String createPodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", createAdminName).get(0);
PodUtils.waitUntilMessageIsInPodLogs(namespace, createPodName, "org.apache.kafka.common.errors.ThrottlingQuotaExceededException: The throttling quota has been exceeded.", GLOBAL_TIMEOUT);
JobUtils.deleteJobWithWait(namespace, createAdminName);
// Teardown delete created topics
KafkaTopicUtils.deleteAllKafkaTopicsWithPrefix(namespace, topicNamePrefix);
}
use of io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder in project strimzi by strimzi.
the class ThrottlingQuotaST method testKafkaAdminTopicOperations.
@ParallelTest
void testKafkaAdminTopicOperations(ExtensionContext extensionContext) {
final String kafkaUsername = mapWithTestUsers.get(extensionContext.getDisplayName());
final String createAdminName = "create-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
final String deleteAdminName = "delete-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
final String listAdminName = "list-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
final String topicNamePrefix = classTopicPrefix + "-simple";
int topicsCountBelowQuota = 100;
setupKafkaUserInNamespace(extensionContext, kafkaUsername);
// Create 'topicsCountBelowQuota' topics
KafkaAdminClients adminClientJob = new KafkaAdminClientsBuilder().withAdminName(createAdminName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withTopicName(topicNamePrefix).withTopicCount(topicsCountBelowQuota).withNamespaceName(namespace).withTopicOperation(AdminClientOperations.CREATE_TOPICS.toString()).withAdditionalConfig(KafkaAdminClients.getAdminClientScramConfig(namespace, kafkaUsername, 240000)).build();
resourceManager.createResource(extensionContext, adminClientJob.defaultAdmin());
ClientUtils.waitForClientSuccess(createAdminName, namespace, topicsCountBelowQuota);
String createPodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", createAdminName).get(0);
PodUtils.waitUntilMessageIsInPodLogs(namespace, createPodName, "All topics created");
// List 'topicsCountBelowQuota' topics
KafkaAdminClients adminClientListJob = new KafkaAdminClientsBuilder().withAdminName(listAdminName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withNamespaceName(namespace).withTopicOperation(AdminClientOperations.LIST_TOPICS.toString()).withAdditionalConfig(KafkaAdminClients.getAdminClientScramConfig(namespace, kafkaUsername, 600000)).build();
resourceManager.createResource(extensionContext, adminClientListJob.defaultAdmin());
ClientUtils.waitForClientSuccess(listAdminName, namespace, 0);
String listPodName = kubeClient().listPodNamesInSpecificNamespace(namespace, "job-name", listAdminName).get(0);
PodUtils.waitUntilMessageIsInPodLogs(namespace, listPodName, topicNamePrefix + "-" + (topicsCountBelowQuota - 1));
JobUtils.deleteJobWithWait(namespace, listAdminName);
// Delete 'topicsCountBelowQuota' topics
adminClientJob = new KafkaAdminClientsBuilder(adminClientJob).withAdminName(deleteAdminName).withTopicOperation(AdminClientOperations.DELETE_TOPICS.toString()).build();
resourceManager.createResource(extensionContext, adminClientJob.defaultAdmin());
ClientUtils.waitForClientSuccess(deleteAdminName, namespace, 10);
String deletePodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", deleteAdminName).get(0);
PodUtils.waitUntilMessageIsInPodLogs(namespace, deletePodName, "Successfully removed all " + topicsCountBelowQuota);
// List topics after deletion
resourceManager.createResource(extensionContext, adminClientListJob.defaultAdmin());
ClientUtils.waitForClientSuccess(listAdminName, namespace, 0);
listPodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", listAdminName).get(0);
String afterDeletePodLogs = kubeClient(namespace).logsInSpecificNamespace(namespace, listPodName);
assertThat(afterDeletePodLogs.contains(topicNamePrefix), is(false));
assertThat(afterDeletePodLogs, not(containsString(topicNamePrefix)));
JobUtils.deleteJobWithWait(namespace, createAdminName);
JobUtils.deleteJobWithWait(namespace, listAdminName);
JobUtils.deleteJobWithWait(namespace, deleteAdminName);
}
use of io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder in project strimzi by strimzi.
the class ThrottlingQuotaST method testThrottlingQuotasCreateTopic.
/**
* Test checks for throttling quotas set for user
* on creation & deletion of topics and create partition operations.
*/
@ParallelTest
void testThrottlingQuotasCreateTopic(ExtensionContext extensionContext) {
final String kafkaUsername = mapWithTestUsers.get(extensionContext.getDisplayName());
final String createAdminName = "create-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
final String topicNamePrefix = classTopicPrefix + "-create";
int topicsCountOverQuota = 500;
setupKafkaUserInNamespace(extensionContext, kafkaUsername);
KafkaAdminClients adminClientJob = new KafkaAdminClientsBuilder().withAdminName(createAdminName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withTopicName(topicNamePrefix).withTopicCount(topicsCountOverQuota).withNamespaceName(namespace).withTopicOperation(AdminClientOperations.CREATE_TOPICS.toString()).withAdditionalConfig(KafkaAdminClients.getAdminClientScramConfig(namespace, kafkaUsername, 240000)).build();
resourceManager.createResource(extensionContext, adminClientJob.defaultAdmin());
String createPodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", createAdminName).get(0);
PodUtils.waitUntilMessageIsInPodLogs(namespace, createPodName, "org.apache.kafka.common.errors.ThrottlingQuotaExceededException: The throttling quota has been exceeded.", GLOBAL_TIMEOUT);
JobUtils.deleteJobWithWait(namespace, createAdminName);
// Teardown delete created topics
KafkaTopicUtils.deleteAllKafkaTopicsWithPrefix(namespace, topicNamePrefix);
}
use of io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder in project strimzi by strimzi.
the class ThrottlingQuotaST method testThrottlingQuotasDeleteTopic.
@ParallelTest
void testThrottlingQuotasDeleteTopic(ExtensionContext extensionContext) {
final String kafkaUsername = mapWithTestUsers.get(extensionContext.getDisplayName());
final String createAdminName = "create-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
final String deleteAdminName = "delete-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
final String topicNamePrefix = classTopicPrefix + "-delete";
int topicsCountOverQuota = 500;
setupKafkaUserInNamespace(extensionContext, kafkaUsername);
// Create many topics in multiple rounds using starting offset
KafkaAdminClients createAdminClientJob = new KafkaAdminClientsBuilder().withAdminName(createAdminName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withTopicName(topicNamePrefix).withTopicCount(100).withNamespaceName(namespace).withTopicOperation(AdminClientOperations.CREATE_TOPICS.toString()).withAdditionalConfig(KafkaAdminClients.getAdminClientScramConfig(namespace, kafkaUsername, 240000)).build();
String createPodName;
int offset = 100;
int iterations = topicsCountOverQuota / 100;
for (int i = 0; i < iterations; i++) {
LOGGER.info("Executing {}/{} iteration.", i + 1, iterations);
createAdminClientJob = new KafkaAdminClientsBuilder(createAdminClientJob).withTopicOffset(i * offset).build();
resourceManager.createResource(extensionContext, createAdminClientJob.defaultAdmin());
ClientUtils.waitForClientSuccess(createAdminName, namespace, 100);
createPodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", createAdminName).get(0);
PodUtils.waitUntilMessageIsInPodLogs(namespace, createPodName, "All topics created", Constants.GLOBAL_TIMEOUT);
JobUtils.deleteJobWithWait(namespace, createAdminName);
}
// Test delete all topics at once - should fail on Throttling Quota limit
KafkaAdminClients deleteAdminClientJob = new KafkaAdminClientsBuilder().withAdminName(deleteAdminName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withTopicName(topicNamePrefix).withTopicCount(topicsCountOverQuota).withNamespaceName(namespace).withTopicOperation(AdminClientOperations.DELETE_TOPICS.toString()).withAdditionalConfig(KafkaAdminClients.getAdminClientScramConfig(namespace, kafkaUsername, 240000)).build();
resourceManager.createResource(extensionContext, deleteAdminClientJob.defaultAdmin());
String deletePodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", deleteAdminName).get(0);
PodUtils.waitUntilMessageIsInPodLogs(namespace, deletePodName, "org.apache.kafka.common.errors.ThrottlingQuotaExceededException: The throttling quota has been exceeded.", Constants.GLOBAL_TIMEOUT);
JobUtils.deleteJobWithWait(namespace, deleteAdminName);
// Teardown - delete all (remaining) topics (within Quota limits) in multiple rounds using starting offsets
for (int i = 0; i < iterations; i++) {
LOGGER.info("Executing {}/{} iteration for {}.", i + 1, iterations, deleteAdminName);
deleteAdminClientJob = new KafkaAdminClientsBuilder(deleteAdminClientJob).withTopicOffset(i * offset).withTopicCount(100).withAdditionalConfig("").build();
resourceManager.createResource(extensionContext, deleteAdminClientJob.defaultAdmin());
ClientUtils.waitForClientSuccess(deleteAdminName, namespace, 10);
JobUtils.deleteJobWithWait(namespace, deleteAdminName);
}
}
use of io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder in project strimzi by strimzi.
the class ThrottlingQuotaST method setup.
@BeforeAll
void setup(ExtensionContext extensionContext) {
sharedTestStorage = new TestStorage(extensionContext, namespace);
// Deploy kafka with ScramSHA512
LOGGER.info("Deploying shared Kafka across all test cases in {} namespace", sharedTestStorage.getNamespaceName());
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(sharedTestStorage.getClusterName(), 3).editMetadata().withNamespace(sharedTestStorage.getNamespaceName()).endMetadata().editSpec().editKafka().withListeners(new GenericKafkaListenerBuilder().withName(Constants.PLAIN_LISTENER_DEFAULT_NAME).withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).withNewKafkaListenerAuthenticationScramSha512Auth().endKafkaListenerAuthenticationScramSha512Auth().build(), new GenericKafkaListenerBuilder().withName(Constants.TLS_LISTENER_DEFAULT_NAME).withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).withNewKafkaListenerAuthenticationTlsAuth().endKafkaListenerAuthenticationTlsAuth().build()).endKafka().endSpec().build());
resourceManager.createResource(extensionContext, KafkaUserTemplates.defaultUser(sharedTestStorage.getNamespaceName(), sharedTestStorage.getClusterName(), sharedTestStorage.getUserName()).editOrNewSpec().withNewQuotas().withControllerMutationRate(1.0).endQuotas().withAuthentication(new KafkaUserScramSha512ClientAuthentication()).endSpec().build());
adminClientsBuilder = new KafkaAdminClientsBuilder().withBootstrapAddress(KafkaResources.plainBootstrapAddress(sharedTestStorage.getClusterName())).withNamespaceName(sharedTestStorage.getNamespaceName()).withAdditionalConfig(KafkaAdminClients.getAdminClientScramConfig(sharedTestStorage.getNamespaceName(), sharedTestStorage.getUserName(), 240000));
}
Aggregations