Search in sources :

Example 71 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi-kafka-operator by strimzi.

the class MetricsIsolatedST method testZookeeperQuorumSize.

@ParallelTest
@Tag(ACCEPTANCE)
void testZookeeperQuorumSize() {
    Pattern quorumSize = Pattern.compile("zookeeper_quorumsize ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(quorumSize, zookeeperMetricsData);
    assertThat("Zookeeper quorum size doesn't match expected value", values.stream().mapToDouble(i -> i).max(), is(OptionalDouble.of(3.0)));
}
Also used : Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

Example 72 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi-kafka-operator by strimzi.

the class MetricsIsolatedST method testKafkaMetricsSettings.

/**
 * 1. Update metrics form whatever it is to @metricsConfigYaml in spec.kafka.metricsConfig
 * 2. Check, whether the metrics ConfigMap is changed
 * 3. Updates ConfigMap linked as metrics on
 * 4. Check, whether the metrics ConfigMap is changed
 */
@ParallelTest
void testKafkaMetricsSettings() {
    String metricsConfigJson = "{\"lowercaseOutputName\":true}";
    String metricsConfigYaml = "lowercaseOutputName: true";
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true);
    ConfigMap externalMetricsCm = new ConfigMapBuilder().withData(Collections.singletonMap(Constants.METRICS_CONFIG_YAML_NAME, metricsConfigYaml)).withNewMetadata().withName("external-metrics-cm").withNamespace(SECOND_NAMESPACE).endMetadata().build();
    kubeClient().getClient().configMaps().inNamespace(SECOND_NAMESPACE).createOrReplace(externalMetricsCm);
    // spec.kafka.metrics -> spec.kafka.jmxExporterMetrics
    ConfigMapKeySelector cmks = new ConfigMapKeySelectorBuilder().withName("external-metrics-cm").withKey(Constants.METRICS_CONFIG_YAML_NAME).build();
    JmxPrometheusExporterMetrics jmxPrometheusExporterMetrics = new JmxPrometheusExporterMetricsBuilder().withNewValueFrom().withConfigMapKeyRef(cmks).endValueFrom().build();
    KafkaResource.replaceKafkaResourceInSpecificNamespace(SECOND_CLUSTER, k -> {
        k.getSpec().getKafka().setMetricsConfig(jmxPrometheusExporterMetrics);
    }, SECOND_NAMESPACE);
    PodUtils.verifyThatRunningPodsAreStable(SECOND_NAMESPACE, SECOND_CLUSTER);
    ConfigMap actualCm = kubeClient(SECOND_NAMESPACE).getConfigMap(KafkaResources.kafkaMetricsAndLogConfigMapName(SECOND_CLUSTER));
    assertThat(actualCm.getData().get(Constants.METRICS_CONFIG_JSON_NAME), is(metricsConfigJson));
    // update metrics
    ConfigMap externalMetricsUpdatedCm = new ConfigMapBuilder().withData(Collections.singletonMap(Constants.METRICS_CONFIG_YAML_NAME, metricsConfigYaml.replace("true", "false"))).withNewMetadata().withName("external-metrics-cm").withNamespace(SECOND_NAMESPACE).endMetadata().build();
    kubeClient().getClient().configMaps().inNamespace(SECOND_NAMESPACE).createOrReplace(externalMetricsUpdatedCm);
    PodUtils.verifyThatRunningPodsAreStable(SECOND_NAMESPACE, SECOND_CLUSTER);
    actualCm = kubeClient(SECOND_NAMESPACE).getConfigMap(KafkaResources.kafkaMetricsAndLogConfigMapName(SECOND_CLUSTER));
    assertThat(actualCm.getData().get(Constants.METRICS_CONFIG_JSON_NAME), is(metricsConfigJson.replace("true", "false")));
}
Also used : JmxPrometheusExporterMetrics(io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapKeySelectorBuilder(io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder) JmxPrometheusExporterMetricsBuilder(io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) Matchers.emptyString(org.hamcrest.Matchers.emptyString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigMapKeySelector(io.fabric8.kubernetes.api.model.ConfigMapKeySelector) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 73 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi-kafka-operator by strimzi.

the class MetricsIsolatedST method testKafkaTopicUnderReplicatedPartitions.

@ParallelTest
void testKafkaTopicUnderReplicatedPartitions() {
    Pattern underReplicatedPartitions = Pattern.compile("kafka_server_replicamanager_underreplicatedpartitions ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(underReplicatedPartitions, kafkaMetricsData);
    assertThat("Topic under-replicated partitions doesn't match expected value", values.stream().mapToDouble(i -> i).sum(), is((double) 0));
}
Also used : Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 74 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi-kafka-operator by strimzi.

the class MetricsIsolatedST method testKafkaBrokersCount.

@ParallelTest
@Tag(ACCEPTANCE)
void testKafkaBrokersCount() {
    Pattern brokerOnlineCount = Pattern.compile("kafka_server_replicamanager_leadercount ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(brokerOnlineCount, kafkaMetricsData);
    assertThat("Broker count doesn't match expected value", values.size(), is(3));
}
Also used : Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

Example 75 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest 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);
}
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

ParallelTest (io.strimzi.systemtest.annotations.ParallelTest)192 Tag (org.junit.jupiter.api.Tag)62 InternalKafkaClient (io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient)38 Matchers.containsString (org.hamcrest.Matchers.containsString)38 KafkaOauthClients (io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClients)32 KafkaOauthClientsBuilder (io.strimzi.systemtest.kafkaclients.internalClients.KafkaOauthClientsBuilder)32 OptionalDouble (java.util.OptionalDouble)28 Pattern (java.util.regex.Pattern)28 StringContains.containsString (org.hamcrest.core.StringContains.containsString)28 BridgeClients (io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients)26 BridgeClientsBuilder (io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder)26 Description (io.vertx.core.cli.annotations.Description)24 KafkaUser (io.strimzi.api.kafka.model.KafkaUser)16 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)16 KafkaResources (io.strimzi.api.kafka.model.KafkaResources)14 AbstractST (io.strimzi.systemtest.AbstractST)14 Constants (io.strimzi.systemtest.Constants)14 INFRA_NAMESPACE (io.strimzi.systemtest.Constants.INFRA_NAMESPACE)14 REGRESSION (io.strimzi.systemtest.Constants.REGRESSION)14 IsolatedSuite (io.strimzi.systemtest.annotations.IsolatedSuite)14