Skip to content

Commit 6350315

Browse files
committed
use docker compose
1 parent 6290041 commit 6350315

File tree

5 files changed

+54
-7
lines changed

5 files changed

+54
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
zookeeper:
3+
image: confluentinc/cp-zookeeper:6.2.10
4+
environment:
5+
ZOOKEEPER_CLIENT_PORT: 2181
6+
ZOOKEEPER_TICK_TIME: 2000
7+
ports:
8+
- "22181:2181"
9+
10+
kafka:
11+
image: confluentinc/cp-kafka:6.2.10
12+
depends_on:
13+
- zookeeper
14+
ports:
15+
- "29092:29092"
16+
environment:
17+
KAFKA_BROKER_ID: 1
18+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
19+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
20+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
21+
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
22+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
# Testcontainers does not work with native-image,
2828
# therefore we're starting a Kafka container manually for the tests
2929
# The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
30-
# todo: build image from https://github.com/hey-johnnypark/docker-kafka-zookeeper and publish
31-
docker run -p 2181:2181 -p 9092:9092 -e ADVERTISED_HOST=localhost --rm kafka-zookeepter
30+
docker compose -f graal-native-docker-compose.yaml up -d
31+
# don't wait for startup - gradle compile takes long enough
3232
./gradlew nativeTest
33-
docker stop kafka # is this needed?
33+
docker compose -f graal-native-docker-compose.yaml down # is this needed?

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.opentelemetry.smoketest;
77

8+
import io.opentelemetry.spring.smoketest.EnabledInGithubActions;
89
import org.junit.jupiter.api.condition.EnabledInNativeImage;
910

1011
/**
@@ -16,8 +17,8 @@
1617
* it's not yet clear why it doesn't work in our case.
1718
*
1819
* <p>In CI, this is done in reusable-native-tests.yml. If you want to run the tests locally, you
19-
* need to start the container manually: docker run -d -p 9092:9092 --name kafka --rm
20-
* confluentinc/cp-kafka:6.2.10
20+
* need to start the container manually: see reusable-native-tests.yml for the command.
2121
*/
22-
@EnabledInNativeImage
22+
@EnabledInNativeImage // see JvmMongodbSpringStarterSmokeTest for the JVM test
23+
@EnabledInGithubActions
2324
public class GraalVmNativeKafkaSpringStarterSmokeTest extends AbstractKafkaSpringStarterSmokeTest {}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.testcontainers.utility.DockerImageName;
1616

1717
@Testcontainers
18-
@DisabledInNativeImage
18+
@DisabledInNativeImage // See GraalVmNativeKafkaSpringStarterSmokeTest for the GraalVM native test
1919
public class JvmKafkaSpringStarterSmokeTest extends AbstractKafkaSpringStarterSmokeTest {
2020

2121
@Container @ServiceConnection
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.spring.smoketest;
7+
8+
import java.lang.annotation.Documented;
9+
import java.lang.annotation.ElementType;
10+
import java.lang.annotation.Retention;
11+
import java.lang.annotation.RetentionPolicy;
12+
import java.lang.annotation.Target;
13+
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
14+
15+
@Target({ElementType.TYPE, ElementType.METHOD})
16+
@Retention(RetentionPolicy.RUNTIME)
17+
@Documented
18+
@EnabledIfEnvironmentVariable(
19+
named = "GITHUB_ACTIONS",
20+
matches = "true",
21+
disabledReason =
22+
"Not currently executing within GitHub actions where the required external "
23+
+ "services (e.g. mongodb) are started using docker.")
24+
public @interface EnabledInGithubActions {}

0 commit comments

Comments
 (0)