Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ dependencies {
testImplementation libs.bundles.junit5
testImplementation libs.guava
testImplementation libs.bundles.mockito
testImplementation group: 'org.awaitility', name: 'awaitility', version: '4.0.1'
testImplementation libs.awaitility
}

10 changes: 1 addition & 9 deletions dd-smoke-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,10 @@ dependencies {
api project(':utils:test-agent-utils:decoder')

compileOnly(libs.junit.jupiter)

compileOnly(libs.bundles.groovy)
compileOnly(libs.bundles.spock)
}

tasks.withType(GroovyCompile).configureEach {
configureCompiler(
it,
8,
JavaVersion.VERSION_1_8,
"CharBuffer#flip() signature needs to be ()Ljava.nio.Buffer (to run on JDK8)."
)
implementation libs.awaitility
}

// Disable forbiddenApis for all smoke-test modules
Expand Down
31 changes: 13 additions & 18 deletions dd-smoke-tests/concurrent/java-25/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,32 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id 'application'
id 'com.gradleup.shadow'
id 'idea'
}

apply from: "$rootDir/gradle/java.gradle"

testJvmConstraints {
// This smoke test should be limited to Java 25 and above
// But the groovy testing framework cannot run on Java 25
// Using Java 8 for now and runs a JVM 25 when forking tests process.
// Relying on forked JVM 25 is hardcoded in the test suites (see createProcessBuilder()).
minJavaVersion = JavaVersion.VERSION_1_8
maxJavaVersion = JavaVersion.VERSION_1_8
// Only runs on Temurin build as it spawns a Temurin 25 for test process.
excludeJdk = ['IBM8', 'SEMERU8']
minJavaVersion = JavaVersion.VERSION_25
}

description = 'JDK 25 Concurrent Integration Tests'

javaToolchains {
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}

tasks.named('compileJava', JavaCompile) {
configureCompiler(it, 25, JavaVersion.VERSION_25)
options.compilerArgs.add("--enable-preview")
idea {
module {
jdkName = '25'
}
}

tasks.named('compileTestGroovy') {
configureCompiler(it, 8, JavaVersion.VERSION_1_8)
tasks.withType(JavaCompile).configureEach {
configureCompiler(it, 25, JavaVersion.VERSION_25)
options.compilerArgs.add("--enable-preview")
}

application {
Expand All @@ -44,6 +38,7 @@ application {
dependencies {
implementation group: 'io.opentelemetry.instrumentation', name: 'opentelemetry-instrumentation-annotations', version: '2.19.0'
testImplementation project(':dd-smoke-tests')
testImplementation libs.bundles.junit5
}

tasks.withType(Test).configureEach {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package datadog.smoketest.concurrent;

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

import datadog.smoketest.AbstractJavaSmokeTest;
import datadog.trace.test.agent.decoder.DecodedSpan;
import datadog.trace.test.agent.decoder.DecodedTrace;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;

abstract class AbstractStructuredConcurrencyTest extends AbstractJavaSmokeTest {
private static final int TIMEOUT_SECONDS = 10;

protected abstract String testCaseName();

protected abstract Predicate<DecodedTrace> checkTrace();

@Override
protected ProcessBuilder createProcessBuilder() {
String applicationJar = System.getProperty("datadog.smoketest.shadowJar.path");
Path javaExecutable = Path.of(System.getenv("JAVA_HOME"), "bin", "java");

var processBuilder = new ProcessBuilder(javaExecutable.toString());
var command = processBuilder.command();
command.addAll(defaultJavaProperties);
command.addAll(
List.of(
"--enable-preview",
"-Ddd.trace.otel.enabled=true",
"-jar",
applicationJar,
testCaseName()));

processBuilder.directory(buildDirectory.toFile());
return processBuilder;
}

protected void receivedCorrectTrace() throws Exception {
Process process = testedProcess;
assertTrue(
process.waitFor(TIMEOUT_SECONDS, TimeUnit.SECONDS),
"Instrumented process did not exit within " + TIMEOUT_SECONDS + " seconds");
assertEquals(0, process.exitValue(), "Instrumented process exited abnormally");
waitForTrace(checkTrace());
assertEquals(1, traceCount.get());
}

protected Optional<DecodedSpan> findRootSpan(DecodedTrace trace, String resource) {
return trace.getSpans().stream()
.filter(span -> Objects.equals(resource, span.getResource()) && span.getParentId() == 0)
.findFirst();
}

protected Optional<DecodedSpan> findChildSpan(
DecodedTrace trace, String resource, long parentSpanId) {
return trace.getSpans().stream()
.filter(
span ->
Objects.equals(resource, span.getResource()) && span.getParentId() == parentSpanId)
.findFirst();
}

protected boolean hasChildSpan(DecodedTrace trace, String resource, long parentSpanId) {
return findChildSpan(trace, resource, parentSpanId).isPresent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package datadog.smoketest.concurrent;

import datadog.trace.test.agent.decoder.DecodedTrace;
import java.util.function.Predicate;
import org.junit.jupiter.api.Test;

/**
* Tests the structured task scope with multiple tasks. Here is the expected task/span structure:
*
* <pre>
* parent
* |-- child1
* |-- child2
* \-- child3
* </pre>
*/
class MultipleTasksTest extends AbstractStructuredConcurrencyTest {
@Override
protected String testCaseName() {
return "MultipleTasks";
}

@Override
protected Predicate<DecodedTrace> checkTrace() {
// 'parent' with 'child1', 'child2', and 'child3' as direct children
return trace ->
trace.getSpans().size() == 4
&& findRootSpan(trace, "parent")
.filter(
parent ->
hasChildSpan(trace, "child1", parent.getSpanId())
&& hasChildSpan(trace, "child2", parent.getSpanId())
&& hasChildSpan(trace, "child3", parent.getSpanId()))
.isPresent();
}

@Test
void testMultipleTasks() throws Exception {
receivedCorrectTrace();
}
}
Loading
Loading