Simply since the agent code doesn't run without java.instrument
DELETE
dd-smoke-tests/java9-modules/instrumentable-module-app/instrumentable-module-app.gradle
-ext {
- minJavaVersionForTests = JavaVersion.VERSION_1_9
-}
-
-apply from: "${rootDir}/gradle/java.gradle"
-
-jar {
- manifest {
- attributes(
- 'Main-Class': 'datadog.smoketest.moduleapp.instrumentable.ModuleApplication'
- )
- }
-}
-
-jlink {
- moduleName = 'datadog.smoketest.moduleapp.instrumentable'
- options = ['--no-man-pages', '--no-header-files']
-}
-
-sourceCompatibility = "1.9"
-targetCompatibility = "1.9"
\ No newline at end of file

DELETE
dd-smoke-tests/java9-modules/instrumentable-module-app/src/main/java/datadog/smoketest/moduleapp/instrumentable/ModuleApplication.java
-package datadog.smoketest.moduleapp.instrumentable;
-
-public class ModuleApplication {
- public static void main(final String[] args) {
- final String agentStatus = System.getProperty("dd.agent.status");
-
- if (!"INSTALLED".equals(agentStatus)) {
- throw new RuntimeException("Incorrect agent status: " + agentStatus);
- }
- }
-}

DELETE
dd-smoke-tests/java9-modules/instrumentable-module-app/src/main/java/module-info.java
-module datadog.smoketest.moduleapp.instrumentable {
- exports datadog.smoketest.moduleapp.instrumentable;
-}

MODIFY
dd-smoke-tests/java9-modules/java9-modules.gradle
dd-smoke-tests/java9-modules/java9-modules.gradle
@@ -2,21 +2,34 @@ plugins {
id 'org.beryx.jlink' version '2.1.1' // latest version that doesn't have a Java 11+ warning
}
+ext {
+ minJavaVersionForTests = JavaVersion.VERSION_1_9
+}
+
apply from: "${rootDir}/gradle/java.gradle"
sourceCompatibility = "1.9"
targetCompatibility = "1.9"
-dependencies {
- testCompile project(':dd-smoke-tests')
+jar {
+ manifest {
+ attributes(
+ 'Main-Class': 'datadog.smoketest.moduleapp.ModuleApplication'
+ )
+ }
}
-Project main_project = project
-subprojects { subProject ->
- apply plugin: "org.beryx.jlink"
+jlink {
+ moduleName = 'datadog.smoketest.moduleapp'
+ options = ['--no-man-pages', '--no-header-files', '--add-modules', 'java.instrument']
+}
- main_project.tasks.test.dependsOn subProject.tasks.jlink
+test {
+ dependsOn tasks.jlink
+ jvmArgs "-Ddatadog.smoketest.module.image=${jlink.imageDir.get()}"
+}
- main_project.tasks.test.jvmArgs "-Ddatadog.smoketest.${subProject.tasks.jlink.moduleName.get()}.image=${subProject.tasks.jlink.imageDir.get()}"
+dependencies {
+ testCompile project(':dd-smoke-tests')
}

ADD
dd-smoke-tests/java9-modules/src/main/java/datadog/smoketest/moduleapp/ModuleApplication.java
+package datadog.smoketest.moduleapp;
+
+public class ModuleApplication {
+ public static void main(final String[] args) throws InterruptedException {
+ Thread.sleep(600);
+ }
+}

ADD
dd-smoke-tests/java9-modules/src/main/java/module-info.java
+module datadog.smoketest.moduleapp {
+ exports datadog.smoketest.moduleapp;
+}

MODIFY
dd-smoke-tests/java9-modules/src/test/groovy/datadog/smoketest/Java9ModulesSmokeTest.groovy
dd-smoke-tests/java9-modules/src/test/groovy/datadog/smoketest/Java9ModulesSmokeTest.groovy
@@ -4,27 +4,25 @@ import spock.lang.Timeout
import java.util.concurrent.TimeUnit
-abstract class Java9ModulesSmokeTest extends AbstractSmokeTest {
+class Java9ModulesSmokeTest extends AbstractSmokeTest {
// Estimate for the amount of time instrumentation plus some extra
private static final int TIMEOUT_SECS = 30
@Override
ProcessBuilder createProcessBuilder() {
println System.getProperties()
- String imageDir = System.getProperty("datadog.smoketest.${moduleName}.image")
+ String imageDir = System.getProperty("datadog.smoketest.module.image")
assert imageDir != null
List<String> command = new ArrayList<>()
command.add(imageDir + "/bin/java")
command.addAll(defaultJavaProperties)
- command.addAll((String[]) ["-m", "${moduleName}/${moduleName}.ModuleApplication"])
+ command.addAll((String[]) ["-m", "datadog.smoketest.moduleapp/datadog.smoketest.moduleapp.ModuleApplication"])
ProcessBuilder processBuilder = new ProcessBuilder(command)
processBuilder.directory(new File(buildDirectory))
}
- abstract getModuleName()
-
// TODO: once java7 support is dropped use waitFor() with timeout call added in java8
// instead of timeout on test
@Timeout(value = TIMEOUT_SECS, unit = TimeUnit.SECONDS)
@@ -33,19 +31,3 @@ abstract class Java9ModulesSmokeTest extends AbstractSmokeTest {
assert serverProcess.waitFor() == 0
}
}
-
-class InstrumentableModuleTest extends Java9ModulesSmokeTest {
-
- @Override
- def getModuleName() {
- return "datadog.smoketest.moduleapp.instrumentable"
- }
-}
-
-class UninstrumentableModuleTest extends Java9ModulesSmokeTest {
-
- @Override
- def getModuleName() {
- return "datadog.smoketest.moduleapp.uninstrumentable"
- }
-}

DELETE
dd-smoke-tests/java9-modules/uninstrumentable-module-app/src/main/java/datadog/smoketest/moduleapp/uninstrumentable/ModuleApplication.java
-package datadog.smoketest.moduleapp.uninstrumentable;
-
-public class ModuleApplication {
- public static void main(final String[] args) {
- final String agentStatus = System.getProperty("dd.agent.status");
-
- if (!"NOT_INSTALLED".equals(agentStatus)) {
- throw new RuntimeException("Incorrect agent status: " + agentStatus);
- }
- }
-}

DELETE
dd-smoke-tests/java9-modules/uninstrumentable-module-app/src/main/java/module-info.java
-module datadog.smoketest.moduleapp.uninstrumentable {
- exports datadog.smoketest.moduleapp.uninstrumentable;
-}

DELETE
dd-smoke-tests/java9-modules/uninstrumentable-module-app/uninstrumentable-module-app.gradle
-ext {
- minJavaVersionForTests = JavaVersion.VERSION_1_9
-}
-
-apply from: "${rootDir}/gradle/java.gradle"
-
-jar {
- manifest {
- attributes(
- 'Main-Class': 'datadog.smoketest.moduleapp.uninstrumentable.ModuleApplication'
- )
- }
-}
-
-jlink {
- moduleName = 'datadog.smoketest.moduleapp.uninstrumentable'
- options = ['--no-man-pages', '--no-header-files']
-}
-
-sourceCompatibility = "1.9"
-targetCompatibility = "1.9"

MODIFY
settings.gradle
settings.gradle
@@ -24,8 +24,6 @@ include ':dd-smoke-tests:springboot'
include ':dd-smoke-tests:wildfly'
include ':dd-smoke-tests:cli'
include ':dd-smoke-tests:java9-modules'
-include ':dd-smoke-tests:java9-modules:instrumentable-module-app'
-include ':dd-smoke-tests:java9-modules:uninstrumentable-module-app'
// instrumentation:
include ':dd-java-agent:instrumentation:akka-http-10.0'

Simply since the agent code doesn't run without java.instrument