Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: building connector jars for telemetry end to end test from docker compose file #132

Merged
merged 8 commits into from
Oct 10, 2023
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
3 changes: 1 addition & 2 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ jobs:
- name: End to End Integration Tests
uses: ./.github/actions/run-tests
with:
command:
- ./gradlew test -DincludeTags="EndToEndTest"
command: ./gradlew test -DincludeTags="EndToEndTest"

Upload-Test-Report:
needs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class FileTransferSampleTestCommon {
final String sampleAssetFilePath;
final File sampleAssetFile;
final File destinationFile;
Duration timeout = Duration.ofSeconds(15);
Duration timeout = Duration.ofSeconds(30);
Duration pollInterval = Duration.ofMillis(500);

String contractNegotiationId;
Expand Down
36 changes: 23 additions & 13 deletions transfer/transfer-04-open-telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ is configured to expose a Prometheus metrics endpoint.
To run the consumer, the provider, and Jaeger execute the following commands in the project root folder:

```bash
./gradlew transfer:transfer-04-open-telemetry:open-telemetry-consumer:build transfer:transfer-04-open-telemetry:open-telemetry-provider:build
docker-compose -f transfer/transfer-04-open-telemetry/docker-compose.yaml up --abort-on-container-exit
```

Expand Down Expand Up @@ -79,26 +78,37 @@ which has to be stored in the root folder of this sample as well. The only addit

```yaml
consumer:
image: openjdk:17-jdk-slim-buster
build:
context: ../..
dockerfile: transfer/transfer-04-open-telemetry/open-telemetry-consumer/Dockerfile
volumes:
- ./:/resources
ports:
- "9191:9191"
- "9192:9192"
environment:
APPLICATIONINSIGHTS_CONNECTION_STRING: <your-connection-string>
APPLICATIONINSIGHTS_ROLE_NAME: consumer
# optional: increase log verbosity (default level is INFO)
APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL: DEBUG
WEB_HTTP_PORT: 8181
EDC_HOSTNAME: consumer
OTEL_SERVICE_NAME: consumer
OTEL_TRACES_EXPORTER: jaeger
OTEL_EXPORTER_JAEGER_ENDPOINT: http://jaeger:14250
OTEL_METRICS_EXPORTER: prometheus
WEB_HTTP_PORT: 9191
WEB_HTTP_PATH: /api
WEB_HTTP_MANAGEMENT_PORT: 8182
WEB_HTTP_MANAGEMENT_PORT: 9192
WEB_HTTP_MANAGEMENT_PATH: /management
DSP_WEBHOOK_ADDRESS: http://consumer:8181
volumes:
- ../:/samples
ports:
- 9191:8181
- 9192:8182
WEB_HTTP_PROTOCOL_PORT: 9292
WEB_HTTP_PROTOCOL_PATH: /protocol
EDC_DSP_CALLBACK_ADDRESS: http://consumer:9292/protocol
EDC_PARTICIPANT_ID: consumer
EDC_API_AUTH_KEY: password
entrypoint: java
-javaagent:/samples/transfer-04-open-telemetry/applicationinsights-agent-3.2.8.jar
-Djava.util.logging.config.file=/samples/transfer-04-open-telemetry/logging.properties
-jar /samples/transfer-04-open-telemetry/open-telemetry-consumer/build/libs/consumer.jar
-javaagent:/resources/opentelemetry-javaagent.jar
-Djava.util.logging.config.file=/resources/logging.properties
-jar /app/connector.jar
```

The Application Insights Java agent will automatically collect metrics from Micrometer, without any configuration needed.
Expand Down
48 changes: 25 additions & 23 deletions transfer/transfer-04-open-telemetry/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ version: "3.8"
services:

consumer:
image: openjdk:17-jdk-slim-buster
build:
context: ../..
dockerfile: transfer/transfer-04-open-telemetry/open-telemetry-consumer/Dockerfile
volumes:
- ./:/resources
ports:
- "9191:9191"
- "9192:9192"
environment:
EDC_HOSTNAME: consumer
OTEL_SERVICE_NAME: consumer
Expand All @@ -18,21 +25,21 @@ services:
WEB_HTTP_PROTOCOL_PATH: /protocol
EDC_DSP_CALLBACK_ADDRESS: http://consumer:9292/protocol
EDC_PARTICIPANT_ID: consumer
WEB_HTTP_DSP_PORT: 9393
WEB_HTTP_DSP_PATH: /protocol
EDC_API_AUTH_KEY: password
volumes:
- ../:/samples
ports:
- "9191:9191"
- "9192:9192"
entrypoint: java
-javaagent:/samples/transfer-04-open-telemetry/opentelemetry-javaagent.jar
-Djava.util.logging.config.file=/samples/transfer-04-open-telemetry/logging.properties
-jar /samples/transfer-04-open-telemetry/open-telemetry-consumer/build/libs/consumer.jar
-javaagent:/app/libs/opentelemetry-javaagent.jar
-Djava.util.logging.config.file=/resources/logging.properties
-jar /app/connector.jar

provider:
image: openjdk:17-jdk-slim-buster
build:
context: ../..
dockerfile: transfer/transfer-04-open-telemetry/open-telemetry-provider/Dockerfile
volumes:
- ./:/resources
ports:
- "8181:8181"
- "8182:8182"
environment:
EDC_HOSTNAME: provider
OTEL_SERVICE_NAME: provider
Expand All @@ -46,25 +53,20 @@ services:
WEB_HTTP_PROTOCOL_PATH: /protocol
EDC_DSP_CALLBACK_ADDRESS: http://provider:8282/protocol
EDC_PARTICIPANT_ID: provider
EDC_SAMPLES_TRANSFER_01_ASSET_PATH: /samples/transfer-04-open-telemetry/README.md
volumes:
- ../:/samples
ports:
- "8181:8181"
- "8182:8182"
EDC_SAMPLES_TRANSFER_01_ASSET_PATH: /resources/README.md
entrypoint: java
-javaagent:/samples/transfer-04-open-telemetry/opentelemetry-javaagent.jar
-Djava.util.logging.config.file=/samples/transfer-04-open-telemetry/logging.properties
-jar /samples/transfer-04-open-telemetry/open-telemetry-provider/build/libs/provider.jar
-javaagent:/app/libs/opentelemetry-javaagent.jar
-Djava.util.logging.config.file=/resources/logging.properties
-jar /app/connector.jar

jaeger:
image: jaegertracing/all-in-one
ports:
- 16686:16686
- "16686:16686"

prometheus:
image: prom/prometheus:v2.30.3
volumes:
- ./prometheus/:/etc/prometheus/
ports:
- 9090:9090
- "9090:9090"
2 changes: 1 addition & 1 deletion transfer/transfer-04-open-telemetry/filetransfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@type": "TransferRequestDto",
"dataDestination": {
"type": "File",
"path": "/samples/transfer-04-open-telemetry/README_transferred.md",
"path": "/resources/README_transferred.md",
"keyName": "keyName"
},
"protocol": "dataspace-protocol-http",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM gradle:jdk17 AS build

WORKDIR /home/gradle/project/
COPY --chown=gradle:gradle . /home/gradle/project/
RUN gradle transfer:transfer-04-open-telemetry:open-telemetry-consumer:build

FROM openjdk:17-slim

WORKDIR /app
COPY --from=build /home/gradle/project/transfer/transfer-04-open-telemetry/opentelemetry-javaagent.jar /app/libs/opentelemetry-javaagent.jar
COPY --from=build /home/gradle/project/transfer/transfer-04-open-telemetry/open-telemetry-consumer/build/libs/consumer.jar /app/connector.jar
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {
}

dependencies {
implementation(libs.opentelemetry)

implementation(libs.edc.control.plane.api.client)
implementation(libs.edc.control.plane.core)
implementation(libs.edc.data.plane.selector.core)
Expand All @@ -38,6 +38,7 @@ dependencies {

implementation(project(":transfer:transfer-01-file-transfer:status-checker"))

runtimeOnly(libs.opentelemetry)
runtimeOnly(libs.edc.jersey.micrometer)
runtimeOnly(libs.edc.jetty.micrometer)
runtimeOnly(libs.edc.monitor.jdk.logger)
Expand All @@ -54,8 +55,7 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {

tasks.register("copyOpenTelemetryJar") {
doLast {
val filePath = "transfer/transfer-04-open-telemetry/opentelemetry-javaagent.jar"
val file = File(filePath)
val file = file("../opentelemetry-javaagent.jar")

if (!file.exists()) {
sourceSets["main"]
Expand All @@ -65,13 +65,13 @@ tasks.register("copyOpenTelemetryJar") {
?.path
?.let {
val sourcePath = Paths.get(it)
val targetPath = Paths.get(filePath)
val targetPath = Paths.get(file.path)
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING)
}
}
}
}

tasks.compileJava {
tasks.build {
finalizedBy("copyOpenTelemetryJar")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM gradle:jdk17 AS build

WORKDIR /home/gradle/project/
COPY --chown=gradle:gradle . /home/gradle/project/
RUN gradle transfer:transfer-04-open-telemetry:open-telemetry-provider:build

FROM openjdk:17-slim

WORKDIR /app
COPY --from=build /home/gradle/project/transfer/transfer-04-open-telemetry/opentelemetry-javaagent.jar /app/libs/opentelemetry-javaagent.jar
COPY --from=build /home/gradle/project/transfer/transfer-04-open-telemetry/open-telemetry-provider/build/libs/provider.jar /app/connector.jar
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

dependencies {
implementation(libs.opentelemetry)

implementation(libs.edc.control.plane.api.client)
implementation(libs.edc.control.plane.core)
implementation(libs.edc.data.plane.selector.core)
Expand All @@ -39,6 +39,8 @@ dependencies {
implementation(libs.edc.dsp)

implementation(project(":transfer:transfer-01-file-transfer:transfer-file-local"))

runtimeOnly(libs.opentelemetry)
runtimeOnly(libs.edc.monitor.jdk.logger)
}

Expand All @@ -53,8 +55,7 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {

tasks.register("copyOpenTelemetryJar") {
doLast {
val filePath = "transfer/transfer-04-open-telemetry/opentelemetry-javaagent.jar"
val file = File(filePath)
val file = file("../opentelemetry-javaagent.jar")

if (!file.exists()) {
sourceSets["main"]
Expand All @@ -64,13 +65,13 @@ tasks.register("copyOpenTelemetryJar") {
?.path
?.let {
val sourcePath = Paths.get(it)
val targetPath = Paths.get(filePath)
val targetPath = Paths.get(file.path)
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING)
}
}
}
}

tasks.compileJava {
tasks.build {
finalizedBy("copyOpenTelemetryJar")
}
Loading