Skip to content

Commit 94626ff

Browse files
committed
no need for docker config
1 parent 504d3b1 commit 94626ff

File tree

4 files changed

+16
-52
lines changed

4 files changed

+16
-52
lines changed

.github/workflows/reusable-native-tests.yml

-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,4 @@ jobs:
2424
echo "JAVA_HOME: $JAVA_HOME"
2525
java --version
2626
native-image --version
27-
# Testcontainers does not work with native-image,
28-
# therefore we're starting a Kafka container manually for the tests
29-
docker run -d -p 9092:9092 --name kafka --rm confluentinc/cp-kafka:6.2.10
3027
./gradlew nativeTest
31-
docker stop kafka # is this needed?

smoke-tests-otel-starter/spring-boot-3/src/test/java/io/opentelemetry/smoketest/GraalVmNativeKafkaSpringStarterSmokeTest.java

-23
This file was deleted.

smoke-tests-otel-starter/spring-boot-3/src/test/java/io/opentelemetry/smoketest/JvmKafkaSpringStarterSmokeTest.java

-24
This file was deleted.
+16-1
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,33 @@
1818
import org.junit.jupiter.api.Test;
1919
import org.springframework.beans.factory.annotation.Autowired;
2020
import org.springframework.boot.test.context.SpringBootTest;
21+
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
2122
import org.springframework.kafka.core.KafkaTemplate;
23+
import org.testcontainers.containers.KafkaContainer;
24+
import org.testcontainers.containers.wait.strategy.Wait;
25+
import org.testcontainers.junit.jupiter.Container;
26+
import org.testcontainers.junit.jupiter.Testcontainers;
27+
import org.testcontainers.utility.DockerImageName;
28+
import java.time.Duration;
2229

30+
@Testcontainers
2331
@SpringBootTest(
2432
classes = {OtelSpringStarterSmokeTestApplication.class, SpringSmokeOtelConfiguration.class},
2533
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
2634
"spring.kafka.consumer.auto-offset-reset=earliest",
2735
"spring.kafka.consumer.linger-ms=10",
36+
"spring.kafka.admin.operation-timeout=5m",
2837
"spring.kafka.listener.idle-between-polls=1000",
2938
"spring.kafka.producer.transaction-id-prefix=test-"
3039

3140
})
32-
abstract class AbstractKafkaSpringStarterSmokeTest extends AbstractSpringStarterSmokeTest {
41+
public class KafkaSpringStarterSmokeTest extends AbstractSpringStarterSmokeTest {
42+
43+
@Container @ServiceConnection
44+
static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:6.2.10"))
45+
.withEnv("KAFKA_HEAP_OPTS", "-Xmx256m")
46+
.waitingFor(Wait.forLogMessage(".*started \\(kafka.server.KafkaServer\\).*", 1))
47+
.withStartupTimeout(Duration.ofMinutes(1));
3348

3449
@Autowired private KafkaTemplate<String, String> kafkaTemplate;
3550

0 commit comments

Comments
 (0)