Skip to content
Draft
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
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ services:
zipkin:
image: openzipkin/zipkin:2
ports:
- "9412:9412"
# Keep the historical host port while routing to Zipkin's standard HTTP collector port.
- "9412:9411"

eureka-server:
build:
Expand Down Expand Up @@ -121,6 +122,7 @@ services:
FLYWAY_BASELINE_ON_MIGRATE: "true"
EUREKA_HOST: eureka-server
ZIPKIN_HOST: zipkin
MANAGEMENT_ZIPKIN_TRACING_ENDPOINT: http://zipkin:9411/api/v2/spans
ports:
- "8000:8000"

Expand Down Expand Up @@ -155,6 +157,7 @@ services:
REPLICA_PGPASSWORD: ${REPLICA_POSTGRES_PASSWORD:-xtrmetl}
EUREKA_HOST: eureka-server
ZIPKIN_HOST: zipkin
MANAGEMENT_ZIPKIN_TRACING_ENDPOINT: http://zipkin:9411/api/v2/spans
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
ports:
- "8001:8001"
Expand All @@ -173,6 +176,7 @@ services:
environment:
EUREKA_HOST: eureka-server
ZIPKIN_HOST: zipkin
MANAGEMENT_ZIPKIN_TRACING_ENDPOINT: http://zipkin:9411/api/v2/spans
ports:
- "8080:8080"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.xtrmetl.etl.documentation;

import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Verifies that the bundled Docker Compose tracing path targets Zipkin's documented HTTP port.
*/
class DockerComposeZipkinTransportTest {

private static final Path PROJECT_ROOT = findProjectRoot();
private static final String INTERNAL_ZIPKIN_ENDPOINT =
"MANAGEMENT_ZIPKIN_TRACING_ENDPOINT: http://zipkin:9411/api/v2/spans";

@Test
void bundledServicesTargetTheStandardZipkinCollectorPort() throws IOException {
String compose = Files.readString(
PROJECT_ROOT.resolve("docker-compose.yml"),
StandardCharsets.UTF_8
);

assertTrue(compose.contains("image: openzipkin/zipkin:2"));
assertTrue(
compose.contains("- \"9412:9411\""),
"The compatibility host port must forward to Zipkin's documented container port 9411"
);
assertFalse(
compose.contains("- \"9412:9412\""),
"The bundled image must not be treated as listening on undocumented container port 9412"
);
assertEquals(
3,
countOccurrences(compose, INTERNAL_ZIPKIN_ENDPOINT),
"ETL, CDC, and gateway must all export traces to Zipkin port 9411 inside Compose"
);
}

private static int countOccurrences(String text, String needle) {
int count = 0;
int cursor = 0;
while ((cursor = text.indexOf(needle, cursor)) >= 0) {
count++;
cursor += needle.length();
}
return count;
}

private static Path findProjectRoot() {
Path current = Paths.get(System.getProperty("user.dir")).toAbsolutePath();
Path lastPomParent = null;
while (current != null) {
if (Files.exists(current.resolve(".git"))) {
return current;
}
if (Files.exists(current.resolve("pom.xml"))) {
lastPomParent = current;
}
current = current.getParent();
}
if (lastPomParent != null) {
return lastPomParent;
}
throw new IllegalStateException("Could not find project root (no .git or pom.xml found)");
}
}
Loading