Skip to content

Commit 91c08f0

Browse files
committed
feat(opentelemetry): Migrate smoke test to JUnit
1 parent 99ec62f commit 91c08f0

4 files changed

Lines changed: 62 additions & 32 deletions

File tree

dd-smoke-tests/opentelemetry/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ dependencies {
1515
implementation group: 'io.opentelemetry', name: 'opentelemetry-api', version: '1.4.0'
1616
implementation group: 'io.opentelemetry.instrumentation', name: 'opentelemetry-instrumentation-annotations', version: '1.20.0'
1717
testImplementation project(':dd-smoke-tests')
18+
// Needed to use TraceBackend.testAgent(): Testcontainers is compileOnly on the smoke-test base
19+
// (so it isn't forced on every consumer), so a module using the container backend opts in here.
20+
testImplementation libs.testcontainers
1821
}
1922

2023
tasks.withType(Test).configureEach {
24+
usesService(testcontainersLimit)
2125
dependsOn 'shadowJar'
2226
def shadowJarTask = tasks.named('shadowJar', ShadowJar)
2327
jvmArgumentProviders.add(new CommandLineArgumentProvider() {

dd-smoke-tests/opentelemetry/gradle.lockfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ com.datadoghq:dd-instrument-java:0.0.4=testCompileClasspath,testRuntimeClasspath
1313
com.datadoghq:dd-javac-plugin-client:0.2.2=testCompileClasspath,testRuntimeClasspath
1414
com.datadoghq:java-dogstatsd-client:4.4.5=testRuntimeClasspath
1515
com.datadoghq:sketches-java:0.8.3=testRuntimeClasspath
16+
com.fasterxml.jackson.core:jackson-annotations:2.10.3=testCompileClasspath,testRuntimeClasspath
17+
com.github.docker-java:docker-java-api:3.4.2=testCompileClasspath,testRuntimeClasspath
18+
com.github.docker-java:docker-java-transport-zerodep:3.4.2=testCompileClasspath,testRuntimeClasspath
19+
com.github.docker-java:docker-java-transport:3.4.2=testCompileClasspath,testRuntimeClasspath
1620
com.github.javaparser:javaparser-core:3.25.6=codenarc
1721
com.github.jnr:jffi:1.3.15=testRuntimeClasspath
1822
com.github.jnr:jnr-a64asm:1.0.0=testRuntimeClasspath
@@ -50,20 +54,21 @@ io.opentelemetry:opentelemetry-context:1.19.0=compileClasspath,runtimeClasspath,
5054
io.sqreen:libsqreen:17.4.0=testRuntimeClasspath
5155
javax.servlet:javax.servlet-api:3.1.0=testCompileClasspath,testRuntimeClasspath
5256
jaxen:jaxen:2.0.0=spotbugs
53-
junit:junit:4.13.2=testRuntimeClasspath
57+
junit:junit:4.13.2=testCompileClasspath,testRuntimeClasspath
5458
net.bytebuddy:byte-buddy-agent:1.18.10=testCompileClasspath,testRuntimeClasspath
5559
net.bytebuddy:byte-buddy:1.18.10=testCompileClasspath,testRuntimeClasspath
5660
net.java.dev.jna:jna-platform:5.8.0=testRuntimeClasspath
57-
net.java.dev.jna:jna:5.8.0=testRuntimeClasspath
61+
net.java.dev.jna:jna:5.13.0=testCompileClasspath,testRuntimeClasspath
5862
net.sf.saxon:Saxon-HE:12.9=spotbugs
5963
org.apache.ant:ant-antlr:1.10.14=codenarc
6064
org.apache.ant:ant-junit:1.10.14=codenarc
6165
org.apache.bcel:bcel:6.11.0=spotbugs
66+
org.apache.commons:commons-compress:1.24.0=testCompileClasspath,testRuntimeClasspath
6267
org.apache.commons:commons-lang3:3.19.0=spotbugs
6368
org.apache.commons:commons-text:1.14.0=spotbugs
6469
org.apache.logging.log4j:log4j-api:2.25.2=spotbugs
6570
org.apache.logging.log4j:log4j-core:2.25.2=spotbugs
66-
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
71+
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testRuntimeClasspath
6772
org.codehaus.groovy:groovy-ant:3.0.23=codenarc
6873
org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc
6974
org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc
@@ -76,10 +81,11 @@ org.codehaus.groovy:groovy:3.0.25=testCompileClasspath,testRuntimeClasspath
7681
org.codenarc:CodeNarc:3.7.0=codenarc
7782
org.dom4j:dom4j:2.2.0=spotbugs
7883
org.gmetrics:GMetrics:2.1.0=codenarc
79-
org.hamcrest:hamcrest-core:1.3=testRuntimeClasspath
84+
org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath
8085
org.hamcrest:hamcrest:3.0=testCompileClasspath,testRuntimeClasspath
8186
org.jctools:jctools-core-jdk11:4.0.6=testRuntimeClasspath
8287
org.jctools:jctools-core:4.0.6=testRuntimeClasspath
88+
org.jetbrains:annotations:17.0.0=testCompileClasspath,testRuntimeClasspath
8389
org.jspecify:jspecify:1.0.0=testCompileClasspath,testRuntimeClasspath
8490
org.junit.jupiter:junit-jupiter-api:5.14.1=testCompileClasspath,testRuntimeClasspath
8591
org.junit.jupiter:junit-jupiter-engine:5.14.1=testRuntimeClasspath
@@ -107,15 +113,17 @@ org.ow2.asm:asm-util:9.7.1=testRuntimeClasspath
107113
org.ow2.asm:asm-util:9.9=spotbugs
108114
org.ow2.asm:asm:9.10.1=testCompileClasspath,testRuntimeClasspath
109115
org.ow2.asm:asm:9.9=spotbugs
116+
org.rnorth.duct-tape:duct-tape:1.0.8=testCompileClasspath,testRuntimeClasspath
110117
org.slf4j:jcl-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
111118
org.slf4j:jul-to-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
112119
org.slf4j:log4j-over-slf4j:1.7.30=testCompileClasspath,testRuntimeClasspath
113-
org.slf4j:slf4j-api:1.7.32=testCompileClasspath,testRuntimeClasspath
120+
org.slf4j:slf4j-api:1.7.36=testCompileClasspath,testRuntimeClasspath
114121
org.slf4j:slf4j-api:2.0.17=spotbugs,spotbugsSlf4j
115122
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
116123
org.spockframework:spock-bom:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
117124
org.spockframework:spock-core:2.4-groovy-3.0=testCompileClasspath,testRuntimeClasspath
118125
org.tabletest:tabletest-junit:1.2.1=testCompileClasspath,testRuntimeClasspath
119126
org.tabletest:tabletest-parser:1.2.0=testCompileClasspath,testRuntimeClasspath
127+
org.testcontainers:testcontainers:1.21.4=testCompileClasspath,testRuntimeClasspath
120128
org.xmlresolver:xmlresolver:5.3.3=spotbugs
121129
empty=annotationProcessor,shadow,spotbugsPlugins,testAnnotationProcessor

dd-smoke-tests/opentelemetry/src/test/groovy/datadog/smoketest/OpenTelemetrySmokeTest.groovy

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package datadog.smoketest;
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;
6+
import static java.util.concurrent.TimeUnit.SECONDS;
7+
8+
import java.io.File;
9+
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.extension.RegisterExtension;
11+
12+
class OpenTelemetrySmokeTest {
13+
private static final int TIMEOUT_SECONDS = 30;
14+
private static final File WORKING_DIRECTORY =
15+
new File(System.getProperty("datadog.smoketest.builddir"));
16+
private static final String APPLICATION_JAR =
17+
System.getProperty("datadog.smoketest.shadowJar.path");
18+
19+
@RegisterExtension
20+
static final SmokeCliApp app =
21+
SmokeCliApp.named("opentelemetry")
22+
.jar(APPLICATION_JAR)
23+
.jvmArgs("-Ddd.trace.otel.enabled=true")
24+
.workingDirectory(WORKING_DIRECTORY)
25+
.backend(testAgent())
26+
.build();
27+
28+
@Test
29+
void receivesTraces() {
30+
app.traces()
31+
.assertTraces(
32+
trace(span().root().operationName("Application.annotatedSpan")),
33+
trace(span().root().resourceName("span-0")),
34+
trace(span().root().resourceName("span-1")),
35+
trace(span().root().resourceName("span-2")),
36+
trace(span().root().resourceName("span-3")),
37+
trace(span().root().resourceName("span-4")),
38+
trace(span().root().resourceName("span-5")),
39+
trace(span().root().resourceName("span-6")),
40+
trace(span().root().resourceName("span-7")),
41+
trace(span().root().resourceName("span-8")),
42+
trace(span().root().resourceName("span-9")));
43+
app.assertCompletesWithValue(TIMEOUT_SECONDS, SECONDS, 0);
44+
}
45+
}

0 commit comments

Comments
 (0)