Search in sources :

Example 11 with KafkaAdminClientsBuilder

use of io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder in project strimzi-kafka-operator 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);
    }
}
Also used : KafkaAdminClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClients) KafkaAdminClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 12 with KafkaAdminClientsBuilder

use of io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder in project strimzi by strimzi.

the class ThrottlingQuotaST method testThrottlingQuotasCreateAlterPartitions.

@ParallelTest
void testThrottlingQuotasCreateAlterPartitions(ExtensionContext extensionContext) {
    final String kafkaUsername = mapWithTestUsers.get(extensionContext.getDisplayName());
    final String createAdminName = "create-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
    final String alterAdminName = "alter-admin-" + mapWithKafkaClientNames.get(extensionContext.getDisplayName());
    final String topicNamePrefix = classTopicPrefix + "-partitions";
    int topicsCount = 50;
    int topicPartitions = 100;
    setupKafkaUserInNamespace(extensionContext, kafkaUsername);
    KafkaAdminClients adminClientJob = new KafkaAdminClientsBuilder().withAdminName(createAdminName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withTopicName(topicNamePrefix).withTopicCount(topicsCount).withPartitions(topicPartitions).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.", Constants.GLOBAL_TIMEOUT);
    JobUtils.deleteJobWithWait(namespace, createAdminName);
    // Delete created topics (as they were created in random order, we have to use KafkaTopic instead of this client)
    KafkaTopicUtils.deleteAllKafkaTopicsWithPrefix(namespace, topicNamePrefix);
    // Throttling quota after performed 'alter' partitions on existing topic
    int topicAlter = 20;
    adminClientJob = new KafkaAdminClientsBuilder(adminClientJob).withTopicCount(topicAlter).withPartitions(1).build();
    resourceManager.createResource(extensionContext, adminClientJob.defaultAdmin());
    createPodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", createAdminName).get(0);
    PodUtils.waitUntilMessageIsInPodLogs(namespace, createPodName, "All topics created", GLOBAL_TIMEOUT);
    JobUtils.deleteJobWithWait(namespace, createAdminName);
    // All topics altered
    adminClientJob = new KafkaAdminClientsBuilder(adminClientJob).withAdminName(alterAdminName).withTopicCount(topicAlter).withPartitions(500).withTopicOperation(AdminClientOperations.UPDATE_TOPICS.toString()).build();
    resourceManager.createResource(extensionContext, adminClientJob.defaultAdmin());
    String alterPodName = kubeClient(namespace).listPodNamesInSpecificNamespace(namespace, "job-name", alterAdminName).get(0);
    PodUtils.waitUntilMessageIsInPodLogs(namespace, alterPodName, "org.apache.kafka.common.errors.ThrottlingQuotaExceededException: The throttling quota has been exceeded.", GLOBAL_TIMEOUT);
    JobUtils.deleteJobWithWait(namespace, alterAdminName);
    // Teardown - delete all (remaining) topics (within Quota limits)
    String teardownClientName = "teardown-delete";
    KafkaAdminClients deleteAdminClientJob = new KafkaAdminClientsBuilder().withAdminName(teardownClientName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(CLUSTER_NAME)).withTopicName(topicNamePrefix).withTopicCount(topicAlter).withNamespaceName(namespace).withTopicOperation(AdminClientOperations.DELETE_TOPICS.toString()).build();
    resourceManager.createResource(extensionContext, deleteAdminClientJob.defaultAdmin());
    ClientUtils.waitForClientSuccess(teardownClientName, namespace, 10);
    JobUtils.deleteJobWithWait(namespace, teardownClientName);
}
Also used : KafkaAdminClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClients) KafkaAdminClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder) Matchers.containsString(org.hamcrest.Matchers.containsString) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Aggregations

KafkaAdminClientsBuilder (io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClientsBuilder)12 ParallelTest (io.strimzi.systemtest.annotations.ParallelTest)10 KafkaAdminClients (io.strimzi.systemtest.kafkaclients.internalClients.KafkaAdminClients)10 Matchers.containsString (org.hamcrest.Matchers.containsString)8 TestStorage (io.strimzi.systemtest.storage.TestStorage)4 KafkaUserScramSha512ClientAuthentication (io.strimzi.api.kafka.model.KafkaUserScramSha512ClientAuthentication)2 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2