Skip to content

Commit

Permalink
Ensure Kafka version is visible in metrics, especially in native mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rsvoboda authored and fedinskiy committed Sep 3, 2024
1 parent 30af9f9 commit fca904f
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.quarkus.ts.micrometer.prometheus.kafka.reactive;

import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.KafkaService;
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.services.KafkaContainer;
import io.quarkus.test.services.QuarkusApplication;

/**
* Tests for Kafka and Metrics scenarios
*/
@QuarkusScenario
public class KafkaAndMetricsIT {
@KafkaContainer
static final KafkaService kafka = new KafkaService();

@QuarkusApplication
static RestService app = new RestService().withProperty("kafka.bootstrap.servers", kafka::getBootstrapUrl);

/**
* Test to ensure Kafka version is visible in metrics, especially in native mode
* Issues: https://github.com/quarkusio/quarkus/pull/41278 and https://github.com/quarkusio/quarkus/issues/42865
*/
@Test
public void testKafkaVersionInMetrics() {
String metrics = app.given().when().get("/q/metrics").then().statusCode(200).extract().asString();

boolean isKafkaVersionPresent = metrics.contains("kafka_version");
boolean isKafkaVersionUnknown = metrics.contains("kafka_version=\"unknown\"");

assertTrue(isKafkaVersionPresent, "'kafka_version' string is not present in the metrics response");
assertFalse(isKafkaVersionUnknown, "'kafka_version' is 'unknown' in the metrics response");
}
}

0 comments on commit fca904f

Please sign in to comment.