|
1 | 1 | package datadog.smoketest; |
2 | 2 |
|
| 3 | +import static datadog.smoketest.backend.TraceBackend.testAgent; |
| 4 | +import static datadog.smoketest.trace.SpanMatcher.span; |
| 5 | +import static datadog.smoketest.trace.TraceMatcher.trace; |
3 | 6 | import static java.util.concurrent.TimeUnit.SECONDS; |
4 | 7 |
|
5 | | -import datadog.smoketest.backend.EnabledIfDockerAvailable; |
6 | | -import datadog.smoketest.backend.TraceBackend; |
7 | 8 | import java.io.File; |
8 | 9 | import org.junit.jupiter.api.Test; |
9 | 10 | import org.junit.jupiter.api.extension.RegisterExtension; |
10 | 11 |
|
11 | | -/** |
12 | | - * S8 pilot — ported from the Groovy {@code OpenTelemetrySmokeTest} onto the new Java smoke base. |
13 | | - * The OpenTelemetry sample app runs under the agent (OTel enabled), emits its traces, and exits; |
14 | | - * the test-agent backend must receive all of them. This is the first end-to-end exercise of the new |
15 | | - * base with a real agent and a non-server (batch) app. The {@code .testAgent()} container backend |
16 | | - * needs Docker, so the test is skipped when Docker is unavailable. |
17 | | - */ |
18 | | -@EnabledIfDockerAvailable |
19 | 12 | class OpenTelemetrySmokeTest { |
20 | 13 | private static final int TIMEOUT_SECONDS = 30; |
| 14 | + private static final File WORKING_DIRECTORY = new File(System.getProperty("datadog.smoketest.builddir")); |
| 15 | + private static final String APPLICATION_JAR = System.getProperty("datadog.smoketest.shadowJar.path"); |
21 | 16 |
|
22 | 17 | @RegisterExtension |
23 | 18 | static final SmokeApp app = |
24 | 19 | SmokeApp.named("opentelemetry") |
25 | | - .jar(System.getProperty("datadog.smoketest.shadowJar.path")) |
| 20 | + .jar(APPLICATION_JAR) |
26 | 21 | .jvmArgs("-Ddd.trace.otel.enabled=true") |
27 | | - .backend(TraceBackend.testAgent()) |
| 22 | + .workingDirectory(WORKING_DIRECTORY) |
28 | 23 | .notAServer() |
29 | | - .workingDirectory(new File(System.getProperty("datadog.smoketest.builddir"))) |
| 24 | + .backend(testAgent()) |
30 | 25 | .build(); |
31 | 26 |
|
32 | 27 | @Test |
33 | 28 | void receivesTraces() { |
34 | | - // 1 @WithSpan-annotated span + 10 manual OpenTelemetry spans, each its own trace. |
35 | | - app.traces().waitForTraceCount(11, TIMEOUT_SECONDS); |
36 | | - |
37 | | - // The app then runs to completion and exits cleanly. (app-started telemetry is asserted |
38 | | - // automatically at teardown by SmokeApp's default check — the test body needn't check it.) |
| 29 | + app.traces().assertTraces( |
| 30 | + trace(span().root().operationName("Application.annotatedSpan")), |
| 31 | + trace(span().root().resourceName("span-0")), |
| 32 | + trace(span().root().resourceName("span-1")), |
| 33 | + trace(span().root().resourceName("span-2")), |
| 34 | + trace(span().root().resourceName("span-3")), |
| 35 | + trace(span().root().resourceName("span-4")), |
| 36 | + trace(span().root().resourceName("span-5")), |
| 37 | + trace(span().root().resourceName("span-6")), |
| 38 | + trace(span().root().resourceName("span-7")), |
| 39 | + trace(span().root().resourceName("span-8")), |
| 40 | + trace(span().root().resourceName("span-9")) |
| 41 | + ); |
39 | 42 | app.assertCompletesWithValue(TIMEOUT_SECONDS, SECONDS, 0); |
40 | 43 | } |
41 | 44 | } |
0 commit comments