Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion integration-tests/kafka-devservices/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devservices-common</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down Expand Up @@ -205,7 +215,31 @@
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<executions>
<execution>
<id>default-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludes>
<exclude>**/continuoustesting/**/*.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>devmode-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/continuoustesting/**/*.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void cleanup() {
}

public int partitions(String topic) {

TopicDescription topicDescription;
try {
Map<String, TopicDescription> partitions = admin.describeTopics(Collections.singletonList(topic))
Expand All @@ -55,4 +56,15 @@ public int partitions(String topic) {
return topicDescription.partitions().size();
}

int port() throws InterruptedException, ExecutionException {
return admin.describeCluster().controller().get().port();
}

String image() throws InterruptedException, ExecutionException {
// By observation, the red panda does not return anything for the supported features call
// It would be nice to have a more robust check, but hopefully this fragile check is good enough
boolean isRedPanda = admin.describeFeatures().featureMetadata().get().supportedFeatures().size() == 0;
return isRedPanda ? "redpanda" : "kafka-native";
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.it.kafka;

import java.util.concurrent.ExecutionException;

import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
Expand All @@ -16,4 +18,16 @@ public class KafkaEndpoint {
public Integer partitions(@PathParam("topic") String topic) {
return admin.partitions(topic);
}

@GET
@Path("/port")
public Integer partitions() throws ExecutionException, InterruptedException {
return admin.port();
}

@GET
@Path("/image")
public String image() throws ExecutionException, InterruptedException {
return admin.image();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ quarkus.kafka.devservices.provider=kafka-native
quarkus.kafka.devservices.topic-partitions.test=2
quarkus.kafka.devservices.topic-partitions.test-consumer=3
quarkus.kafka.devservices.topic-partitions-timeout=4S

# When running this project itself in dev or test mode, don't try and layer in the dev mode tests
quarkus.test.exclude-pattern=io.quarkus.it.kafka.continuoustesting.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.quarkus.it.kafka;

import java.util.concurrent.ExecutionException;

import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;

@Path("/kafka")
public class BundledEndpoint {

@Inject
KafkaAdminManager admin;

@GET
@Path("/partitions/{topic}")
public Integer partitions(@PathParam("topic") String topic) {
return admin.partitions(topic);
}

@GET
@Path("/port")
public Integer port() throws ExecutionException, InterruptedException {
return admin.port();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.quarkus.it.kafka;

import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import io.quarkus.it.kafka.devservices.profiles.DevServicesCustomPortProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.quarkus.test.ports.SocketKit;
import io.restassured.RestAssured;

@QuarkusTest
@TestProfile(DevServicesCustomPortProfile.class)
public class DevServicesKafkaCustomPortITest {

@Test
@DisplayName("should start kafka container with the given custom port")
public void shouldStartKafkaContainer() {
Assertions.assertTrue(SocketKit.isPortAlreadyUsed(5050));
RestAssured.when().get("/kafka/port").then().body(Matchers.is("5050"));
}

@Test
public void shouldBeCorrectImage() {
RestAssured.when().get("/kafka/image").then().body(Matchers.is("kafka-native"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.it.kafka;

import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import io.quarkus.it.kafka.devservices.profiles.DevServicesCustomPortReusableServiceProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.quarkus.test.ports.SocketKit;
import io.restassured.RestAssured;

@Disabled("https://github.com/quarkusio/quarkus/issues/47627")
@QuarkusTest
@TestProfile(DevServicesCustomPortReusableServiceProfile.class)
public class DevServicesKafkaCustomPortReusableServiceITest {

@Test
@DisplayName("should start kafka container with the given custom port")
public void shouldStartKafkaContainer() {
// We could strengthen this test to make sure the container is the same as seen by other tests, but it's hard since we won't know the order
Assertions.assertTrue(SocketKit.isPortAlreadyUsed(5050));
RestAssured.when().get("/kafka/port").then().body(Matchers.is("5050"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.quarkus.it.kafka;

import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import io.quarkus.it.kafka.devservices.profiles.DevServicesNonUniquePortProfile;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.quarkus.test.ports.SocketKit;
import io.restassured.RestAssured;

@Disabled("https://github.com/quarkusio/quarkus/issues/47627")
@QuarkusTest
@TestProfile(DevServicesNonUniquePortProfile.class)
public class DevServicesKafkaNonUniquePortITest {

@Test
@DisplayName("should start kafka container with the given custom port")
public void shouldStartKafkaContainer() {
Assertions.assertTrue(SocketKit.isPortAlreadyUsed(5050));
RestAssured.when().get("/kafka/port").then().body(Matchers.is("5050"));
}

@Test
public void shouldBeCorrectImage() {
RestAssured.when().get("/kafka/image").then().body(Matchers.is("redpanda"));
}

}
Loading
Loading