Search in sources :

Example 16 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi by strimzi.

the class MetricsIsolatedST method testKafkaBridgeMetrics.

@ParallelTest
@Tag(BRIDGE)
@Tag(ACCEPTANCE)
void testKafkaBridgeMetrics(ExtensionContext extensionContext) {
    String producerName = "bridge-producer";
    String consumerName = "bridge-consumer";
    MetricsCollector bridgeCollector = collector.toBuilder().withComponentName(BRIDGE_CLUSTER).withComponentType(ComponentType.KafkaBridge).build();
    // Attach consumer before producer
    BridgeClients kafkaBridgeClientJob = new BridgeClientsBuilder().withNamespaceName(INFRA_NAMESPACE).withProducerName(producerName).withConsumerName(consumerName).withBootstrapAddress(KafkaBridgeResources.serviceName(BRIDGE_CLUSTER)).withTopicName(bridgeTopic).withMessageCount(MESSAGE_COUNT).withPort(Constants.HTTP_BRIDGE_DEFAULT_PORT).withDelayMs(200).withPollInterval(200).build();
    resourceManager.createResource(extensionContext, kafkaBridgeClientJob.producerStrimziBridge());
    resourceManager.createResource(extensionContext, kafkaBridgeClientJob.consumerStrimziBridge());
    TestUtils.waitFor("KafkaProducer metrics will be available", Constants.GLOBAL_POLL_INTERVAL, Constants.GLOBAL_TIMEOUT, () -> {
        LOGGER.info("Looking for 'strimzi_bridge_kafka_producer_count' in bridge metrics");
        kafkaBridgeMetricsData = bridgeCollector.collectMetricsFromPods();
        Pattern producerCountPattern = Pattern.compile("strimzi_bridge_kafka_producer_count\\{.*,} ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
        ArrayList<Double> producerCountValues = MetricsCollector.collectSpecificMetric(producerCountPattern, kafkaBridgeMetricsData);
        return producerCountValues.stream().mapToDouble(i -> i).count() == (double) 1;
    });
    TestUtils.waitFor("KafkaConsumer metrics will be available", Constants.GLOBAL_POLL_INTERVAL, Constants.GLOBAL_TIMEOUT, () -> {
        LOGGER.info("Looking for 'strimzi_bridge_kafka_consumer_connection_count' in bridge metrics");
        kafkaBridgeMetricsData = bridgeCollector.collectMetricsFromPods();
        Pattern consumerConnectionsPattern = Pattern.compile("strimzi_bridge_kafka_consumer_connection_count\\{.*,} ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
        ArrayList<Double> consumerConnectionsValues = MetricsCollector.collectSpecificMetric(consumerConnectionsPattern, kafkaBridgeMetricsData);
        return consumerConnectionsValues.stream().mapToDouble(i -> i).count() > 0;
    });
    assertThat("Collected KafkaBridge metrics doesn't contains jvm metrics", kafkaBridgeMetricsData.values().toString().contains("jvm"));
    assertThat("Collected KafkaBridge metrics doesn't contains HTTP metrics", kafkaBridgeMetricsData.values().toString().contains("strimzi_bridge_http_server"));
    Pattern bridgeResponse = Pattern.compile("system_cpu_count ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(bridgeResponse, kafkaBridgeMetricsData);
    assertThat(values.stream().mapToDouble(i -> i).sum(), is((double) 1));
}
Also used : Pattern(java.util.regex.Pattern) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) Matchers.emptyString(org.hamcrest.Matchers.emptyString) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

Example 17 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi by strimzi.

the class MetricsIsolatedST method testZookeeperAliveConnections.

@ParallelTest
void testZookeeperAliveConnections() {
    Pattern numAliveConnections = Pattern.compile("zookeeper_numaliveconnections ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(numAliveConnections, zookeeperMetricsData);
    assertThat("Zookeeper alive connections count doesn't match expected value", values.stream().mapToDouble(i -> i).count(), is(0L));
}
Also used : Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 18 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi by strimzi.

the class MetricsIsolatedST method testUserOperatorMetrics.

@ParallelTest
@Tag(ACCEPTANCE)
void testUserOperatorMetrics() {
    userOperatorMetricsData = collector.toBuilder().withComponentType(ComponentType.UserOperator).build().collectMetricsFromPods();
    assertCoMetricNotNull("strimzi_reconciliations_locked_total", "KafkaUser", userOperatorMetricsData);
    assertCoMetricNotNull("strimzi_reconciliations_successful_total", "KafkaUser", userOperatorMetricsData);
    assertCoMetricNotNull("strimzi_reconciliations_duration_seconds_count", "KafkaUser", userOperatorMetricsData);
    assertCoMetricNotNull("strimzi_reconciliations_duration_seconds_sum", "KafkaUser", userOperatorMetricsData);
    assertCoMetricNotNull("strimzi_reconciliations_duration_seconds_max", "KafkaUser", userOperatorMetricsData);
    assertCoMetricNotNull("strimzi_reconciliations_periodical_total", "KafkaUser", userOperatorMetricsData);
    assertCoMetricNotNull("strimzi_reconciliations_failed_total", "KafkaUser", userOperatorMetricsData);
    assertCoMetricNotNull("strimzi_reconciliations_total", "KafkaUser", userOperatorMetricsData);
    Pattern userPattern = Pattern.compile("strimzi_resources\\{kind=\"KafkaUser\",.*} ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(userPattern, userOperatorMetricsData);
    assertThat(values.stream().mapToDouble(i -> i).sum(), is((double) 2));
}
Also used : Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

Example 19 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi by strimzi.

the class MetricsIsolatedST method testKafkaActiveControllers.

@ParallelTest
void testKafkaActiveControllers() {
    Pattern activeControllers = Pattern.compile("kafka_controller_kafkacontroller_activecontrollercount ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(activeControllers, kafkaMetricsData);
    assertThat("Kafka active controllers count doesn't match expected value", values.stream().mapToDouble(i -> i).sum(), is((double) 1));
}
Also used : Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 20 with ParallelTest

use of io.strimzi.systemtest.annotations.ParallelTest in project strimzi by strimzi.

the class CustomResourceStatusIsolatedST method testKafkaConnectorWithoutClusterConfig.

@ParallelTest
@Tag(CONNECTOR_OPERATOR)
void testKafkaConnectorWithoutClusterConfig(ExtensionContext extensionContext) {
    String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    // This test check NPE when connect cluster is not specified in labels
    // Check for NPE in CO logs is performed after every test in BaseST
    resourceManager.createResource(extensionContext, false, KafkaConnectorTemplates.kafkaConnector(clusterName, CUSTOM_RESOURCE_STATUS_CLUSTER_NAME, 2).withNewMetadata().withName(clusterName).withNamespace(ResourceManager.kubeClient().getNamespace()).endMetadata().build());
    KafkaConnectorUtils.waitForConnectorNotReady(clusterName);
    KafkaConnectorResource.kafkaConnectorClient().inNamespace(Constants.INFRA_NAMESPACE).withName(clusterName).withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();
    KafkaConnectorUtils.waitForConnectorDeletion(clusterName);
}
Also used : StringContains.containsString(org.hamcrest.core.StringContains.containsString) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

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