Merge branch 'master' of github.com:DataDog/dd-trace-java into labbati/non-static-config
This commit is contained in:
commit
a522196b49
|
@ -115,6 +115,11 @@ jobs:
|
|||
environment:
|
||||
- TEST_TASK: testJava11
|
||||
|
||||
test_12:
|
||||
<<: *default_test_job
|
||||
environment:
|
||||
- TEST_TASK: testJava12
|
||||
|
||||
agent_integration_tests:
|
||||
<<: *defaults
|
||||
docker:
|
||||
|
@ -268,6 +273,12 @@ workflows:
|
|||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
- test_12:
|
||||
requires:
|
||||
- build
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
|
||||
- agent_integration_tests:
|
||||
requires:
|
||||
|
@ -298,6 +309,7 @@ workflows:
|
|||
- test_9
|
||||
- test_10
|
||||
- test_11
|
||||
- test_12
|
||||
- agent_integration_tests
|
||||
- check
|
||||
filters:
|
||||
|
@ -314,6 +326,7 @@ workflows:
|
|||
- test_9
|
||||
- test_10
|
||||
- test_11
|
||||
- test_12
|
||||
- agent_integration_tests
|
||||
- check
|
||||
filters:
|
||||
|
|
|
@ -16,7 +16,7 @@ dependencies {
|
|||
annotationProcessor deps.autoservice
|
||||
implementation deps.autoservice
|
||||
|
||||
compileOnly project(':dd-trace-ot')
|
||||
compile project(':dd-trace-ot')
|
||||
|
||||
testCompile deps.opentracing
|
||||
testCompile project(':dd-java-agent:testing')
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class DDJavaAgentInfo {
|
||||
public static final String VERSION;
|
||||
|
||||
static {
|
||||
String v;
|
||||
try {
|
||||
Class<?> tracingAgentClass =
|
||||
ClassLoader.getSystemClassLoader().loadClass("datadog.trace.agent.TracingAgent");
|
||||
Method getAgentVersionMethod = tracingAgentClass.getMethod("getAgentVersion");
|
||||
v = (String) getAgentVersionMethod.invoke(null);
|
||||
} catch (final Exception e) {
|
||||
log.error("failed to read agent version", e);
|
||||
v = "unknown";
|
||||
}
|
||||
VERSION = v;
|
||||
log.info("dd-java-agent - version: {}", v);
|
||||
}
|
||||
}
|
|
@ -102,7 +102,7 @@ dependencies {
|
|||
|
||||
testCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2'
|
||||
testCompile group: 'org.mongodb', name: 'mongodb-driver-async', version: '3.4.2'
|
||||
// run embeded mongodb for integration testing
|
||||
// run embedded mongodb for integration testing
|
||||
testCompile group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '1.50.5'
|
||||
}
|
||||
|
||||
|
|
|
@ -14,18 +14,22 @@ testSets {
|
|||
}
|
||||
|
||||
muzzle {
|
||||
pass {
|
||||
group = 'com.couchbase.client'
|
||||
module = 'java-client'
|
||||
// Looks like 2.7.5 was just released and didn't sync up with mirrors properly causing build failures
|
||||
// TODO: remove this on a few days.
|
||||
versions = "[2.0.0,2.7.5)"
|
||||
// assertInverse = true
|
||||
}
|
||||
// Version 2.7.5 was not released properly and muzzle cannot test against it causing failure.
|
||||
// So we have to skip it resulting in this verbose setup.
|
||||
fail {
|
||||
group = 'com.couchbase.client'
|
||||
module = 'java-client'
|
||||
versions = "(,2.0.0)"
|
||||
versions = "[,2.0.0)"
|
||||
}
|
||||
pass {
|
||||
group = 'com.couchbase.client'
|
||||
module = 'java-client'
|
||||
versions = "[2.0.0,2.7.5)"
|
||||
}
|
||||
pass {
|
||||
group = 'com.couchbase.client'
|
||||
module = 'java-client'
|
||||
versions = "[2.7.6,)"
|
||||
}
|
||||
fail {
|
||||
group = 'com.couchbase.client'
|
||||
|
@ -53,8 +57,6 @@ dependencies {
|
|||
testCompile group: 'com.couchbase.client', name: 'java-client', version: '2.5.0'
|
||||
|
||||
latestDepTestCompile group: 'org.springframework.data', name: 'spring-data-couchbase', version: '3.+'
|
||||
// Looks like 2.7.5 was just released and didn't sync up with mirrors properly causing build failures
|
||||
// TODO: remove this on a few days.
|
||||
latestDepTestCompile group: 'com.couchbase.client', name: 'java-client', version: '2.7.4'
|
||||
latestDepTestCompile group: 'com.couchbase.client', name: 'encryption', version: '1.0.0'
|
||||
latestDepTestCompile group: 'com.couchbase.client', name: 'java-client', version: '2.6+'
|
||||
latestDepTestCompile group: 'com.couchbase.client', name: 'encryption', version: '+'
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ testSets {
|
|||
|
||||
dependencies {
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
compile deps.bytebuddy
|
||||
|
|
|
@ -44,7 +44,6 @@ testSets {
|
|||
dependencies {
|
||||
compileOnly group: 'io.grpc', name: 'grpc-core', version: grpcVersion
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
compile deps.bytebuddy
|
||||
|
|
|
@ -20,7 +20,6 @@ dependencies {
|
|||
compileOnly group: 'com.netflix.hystrix', name: 'hystrix-core', version: '1.4.0'
|
||||
compileOnly group: 'io.reactivex', name: 'rxjava', version: '1.0.7'
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
compile deps.bytebuddy
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// this project will run in isolation under the agent's classloader
|
||||
buildscript {
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
classpath "net.bytebuddy:byte-buddy-gradle-plugin:${versions.bytebuddy}"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
|
||||
|
|
|
@ -12,7 +12,6 @@ dependencies {
|
|||
compileOnly deps.scala
|
||||
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
testCompile deps.scala
|
||||
testCompile group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.5.0'
|
||||
|
||||
|
|
|
@ -9,9 +9,8 @@ apply from: "${rootDir}/gradle/test-with-scala.gradle"
|
|||
|
||||
dependencies {
|
||||
compileOnly deps.scala
|
||||
|
||||
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
testCompile deps.scala
|
||||
testCompile group: 'com.typesafe.akka', name: 'akka-actor_2.11', version: '2.3.16'
|
||||
testCompile group: 'com.typesafe.akka', name: 'akka-testkit_2.11', version: '2.3.16'
|
||||
|
|
|
@ -3,7 +3,8 @@ apply from: "${rootDir}/gradle/test-with-kotlin.gradle"
|
|||
|
||||
dependencies {
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
|
||||
|
||||
testCompile deps.kotlin
|
||||
testCompile deps.coroutines
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ dependencies {
|
|||
compileOnly deps.scala
|
||||
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
testCompile deps.scala
|
||||
|
||||
testCompile project(':dd-java-agent:testing')
|
||||
|
|
|
@ -20,7 +20,6 @@ testSets {
|
|||
dependencies {
|
||||
compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
compile deps.bytebuddy
|
||||
|
|
|
@ -23,7 +23,6 @@ dependencies {
|
|||
compileOnly group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '2.3.0'
|
||||
compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
compile deps.bytebuddy
|
||||
|
|
|
@ -17,10 +17,21 @@ testSets {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Note: there is a bit of dependency exclusion magic goin on.
|
||||
We have to exclude all transitive dependencies on 'okhttp' because we would like to force
|
||||
specific version. We cannot use . Unfortunately we cannot just force version on
|
||||
a dependency because this doesn't work well with version ranges - it doesn't select latest.
|
||||
And we cannot use configurations to exclude this dependency from everywhere in one go
|
||||
because it looks like exclusions using configurations excludes dependency even if it explicit
|
||||
not transitive.
|
||||
*/
|
||||
dependencies {
|
||||
compileOnly group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.0.0'
|
||||
compileOnly(group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.0.0')
|
||||
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
compile(project(':dd-java-agent:agent-tooling')) {
|
||||
exclude module: 'okhttp'
|
||||
}
|
||||
|
||||
compile deps.bytebuddy
|
||||
compile deps.opentracing
|
||||
|
@ -30,7 +41,9 @@ dependencies {
|
|||
testCompile(project(':dd-java-agent:testing')) {
|
||||
exclude module: 'okhttp'
|
||||
}
|
||||
testCompile project(':dd-java-agent:instrumentation:java-concurrent')
|
||||
testCompile(project(':dd-java-agent:instrumentation:java-concurrent')) {
|
||||
exclude module: 'okhttp'
|
||||
}
|
||||
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.0.0'
|
||||
|
||||
// 4.x.x-alpha has been released and it looks like there are lots of incompatible changes
|
||||
|
|
|
@ -20,7 +20,6 @@ testSets {
|
|||
dependencies {
|
||||
compileOnly group: 'com.rabbitmq', name: 'amqp-client', version: '2.7.0'
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
compile deps.bytebuddy
|
||||
|
|
|
@ -25,7 +25,6 @@ testSets {
|
|||
dependencies {
|
||||
compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
compile deps.bytebuddy
|
||||
|
|
|
@ -2,8 +2,9 @@ package datadog.trace.agent
|
|||
|
||||
import datadog.opentracing.DDTraceOTInfo
|
||||
import datadog.trace.api.DDTraceApiInfo
|
||||
import spock.lang.Specification
|
||||
|
||||
class DDInfoTest {
|
||||
class DDInfoTest extends Specification {
|
||||
def "info accessible from api"() {
|
||||
expect:
|
||||
DDTraceApiInfo.VERSION == DDTraceOTInfo.VERSION
|
||||
|
@ -15,17 +16,4 @@ class DDInfoTest {
|
|||
DDTraceOTInfo.VERSION != ""
|
||||
DDTraceOTInfo.VERSION != "unknown"
|
||||
}
|
||||
|
||||
def "info accessible from agent"() {
|
||||
setup:
|
||||
def clazz = Class.forName("datadog.trace.agent.tooling.DDJavaAgentInfo")
|
||||
def versionField = clazz.getDeclaredField("VERSION")
|
||||
def version = versionField.get(null)
|
||||
|
||||
expect:
|
||||
version != null
|
||||
version != ""
|
||||
version != "unknown"
|
||||
version == DDTraceApiInfo.VERSION
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package datadog.trace.agent.test.utils;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PortUtils {
|
||||
|
||||
|
@ -20,4 +22,39 @@ public class PortUtils {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPortOpen(final int port) {
|
||||
try (final Socket socket = new Socket((String) null, port)) {
|
||||
return true;
|
||||
} catch (final IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void waitForPortToOpen(
|
||||
final int port, final long timeout, final TimeUnit unit, final Process process) {
|
||||
final long waitUntil = System.currentTimeMillis() + unit.toMillis(timeout);
|
||||
|
||||
while (System.currentTimeMillis() < waitUntil) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (final InterruptedException e) {
|
||||
throw new RuntimeException("Interrupted while waiting for " + port + " to be opened");
|
||||
}
|
||||
|
||||
// Note: we should have used `process.isAlive()` here but it is java8 only
|
||||
try {
|
||||
process.exitValue();
|
||||
throw new RuntimeException("Process died before port " + port + " was opened");
|
||||
} catch (final IllegalThreadStateException e) {
|
||||
// process is still alive, things are good.
|
||||
}
|
||||
|
||||
if (isPortOpen(port)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Timed out waiting for port " + port + " to be opened");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,6 @@ dependencies {
|
|||
|
||||
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: '8.0.0.v20110901'
|
||||
|
||||
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.11.0'
|
||||
|
||||
compile project(':dd-trace-ot')
|
||||
compile project(':dd-java-agent:agent-tooling')
|
||||
|
||||
annotationProcessor deps.autoservice
|
||||
|
|
|
@ -1 +1,18 @@
|
|||
apply from: "${rootDir}/gradle/java.gradle"
|
||||
|
||||
description = 'dd-smoke-tests'
|
||||
|
||||
dependencies {
|
||||
compile deps.spock
|
||||
compile project(':dd-java-agent:testing')
|
||||
}
|
||||
|
||||
subprojects { subProject ->
|
||||
subProject.tasks.withType(Test).configureEach {
|
||||
dependsOn project(':dd-java-agent').shadowJar
|
||||
|
||||
// Tests depend on this to know where to run things and what agent jar to use
|
||||
jvmArgs "-Ddatadog.smoketest.builddir=${buildDir}"
|
||||
jvmArgs "-Ddatadog.smoketest.agent.shadowJar.path=${project(':dd-java-agent').tasks.shadowJar.archivePath}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
plugins {
|
||||
// using this plugin will launch the server in the background and won't block the tests
|
||||
id 'com.github.psxpaul.execfork' version '0.1.8'
|
||||
id 'play'
|
||||
}
|
||||
|
||||
ext {
|
||||
minJavaVersionForTests = JavaVersion.VERSION_1_8
|
||||
playHttpPort = 8080
|
||||
}
|
||||
|
||||
def playVersion = "2.6.20"
|
||||
|
@ -55,57 +52,9 @@ dependencies {
|
|||
play project(':dd-trace-api')
|
||||
play deps.opentracing
|
||||
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
testCompile project(':dd-java-agent:testing')
|
||||
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
|
||||
}
|
||||
|
||||
tasks.register("startServer", com.github.psxpaul.task.ExecFork) {
|
||||
dependsOn project(':dd-java-agent').shadowJar
|
||||
playHttpPort = randomOpenPort()
|
||||
|
||||
if (playHttpPort == -1) {
|
||||
throw new GradleException("Failed to get random port to start Play")
|
||||
}
|
||||
|
||||
workingDir = "${buildDir}/stage/playBinary"
|
||||
commandLine = "${workingDir}/bin/playBinary"
|
||||
stopAfter = test
|
||||
standardOutput "${buildDir}/reports/server.log"
|
||||
// these params tells the ExecFork plugin to block on startServer task until the port is opened or the string is seen in the ouput
|
||||
waitForPort = playHttpPort
|
||||
waitForOutput = "Listening for HTTP on /127.0.0.1:${playHttpPort}"
|
||||
timeout = 240
|
||||
environment = [
|
||||
'JAVA_OPTS': "-javaagent:${project(':dd-java-agent').tasks.shadowJar.archivePath}"
|
||||
+ " -Ddd.writer.type=LoggingWriter" + " -Ddd.service.name=java-app"
|
||||
+ " -Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"
|
||||
+ " -Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
|
||||
+ " -Dconfig.file=${workingDir}/conf/application.conf -Dhttp.port=${playHttpPort}"
|
||||
+ " -Dhttp.address=127.0.0.1"
|
||||
]
|
||||
|
||||
dependsOn 'stage'
|
||||
|
||||
// When tests are disabled this would still be run, so disable this manually
|
||||
onlyIf { !project.rootProject.hasProperty("skipTests") }
|
||||
}
|
||||
|
||||
tasks.register("deletePIDFile") {
|
||||
delete "${buildDir}/stage/playBinary/RUNNING_PID"
|
||||
testCompile project(':dd-smoke-tests')
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
// so the test can get this property
|
||||
jvmArgs "-Ddatadog.smoketest.server.port=${playHttpPort}"
|
||||
|
||||
testLogging {
|
||||
events "started"
|
||||
}
|
||||
|
||||
dependsOn startServer
|
||||
|
||||
// clean up the PID file from the server
|
||||
finalizedBy deletePIDFile
|
||||
dependsOn 'stage'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package datadog.smoketest
|
||||
|
||||
import okhttp3.Request
|
||||
import spock.lang.Shared
|
||||
|
||||
class PlaySmokeTest extends AbstractServerSmokeTest {
|
||||
|
||||
@Shared
|
||||
File playDirectory = new File("${buildDirectory}/stage/playBinary")
|
||||
|
||||
@Override
|
||||
ProcessBuilder createProcessBuilder() {
|
||||
ProcessBuilder processBuilder =
|
||||
new ProcessBuilder("${playDirectory}/bin/playBinary")
|
||||
processBuilder.directory(playDirectory)
|
||||
processBuilder.environment().put("JAVA_OPTS",
|
||||
defaultJavaProperties.join(" ")
|
||||
+ " -Dconfig.file=${workingDirectory}/conf/application.conf -Dhttp.port=${httpPort}"
|
||||
+ " -Dhttp.address=127.0.0.1")
|
||||
return processBuilder
|
||||
}
|
||||
|
||||
def "welcome endpoint #n th time"() {
|
||||
setup:
|
||||
String url = "http://localhost:$httpPort/welcome?id=$n"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
|
||||
then:
|
||||
def responseBodyStr = response.body().string()
|
||||
responseBodyStr == "Welcome $n."
|
||||
response.code() == 200
|
||||
|
||||
where:
|
||||
n << (1..200)
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package datadog.trace.agent
|
||||
|
||||
import datadog.trace.agent.test.utils.OkHttpUtils
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import spock.lang.Specification
|
||||
|
||||
class PlaySmokeTest extends Specification {
|
||||
|
||||
OkHttpClient client = OkHttpUtils.client()
|
||||
private int port = Integer.parseInt(System.getProperty("datadog.smoketest.server.port", "8080"))
|
||||
|
||||
def "welcome endpoint #n th time"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port/welcome?id=$n"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
|
||||
then:
|
||||
def responseBodyStr = response.body().string()
|
||||
responseBodyStr == "Welcome $n."
|
||||
response.code() == 200
|
||||
|
||||
where:
|
||||
n << (1..200)
|
||||
}
|
||||
}
|
|
@ -1,15 +1,9 @@
|
|||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "4.0.4"
|
||||
id 'com.github.psxpaul.execfork' version '0.1.8'
|
||||
}
|
||||
apply from: "${rootDir}/gradle/java.gradle"
|
||||
description = 'SpringBoot Smoke Tests.'
|
||||
|
||||
|
||||
ext {
|
||||
springbootHttpPort = 8080
|
||||
}
|
||||
|
||||
// The standard spring-boot plugin doesn't play nice with our project
|
||||
// so we'll build a fat jar instead
|
||||
jar {
|
||||
|
@ -23,40 +17,11 @@ jar {
|
|||
dependencies {
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.18.RELEASE'
|
||||
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
testCompile project(':dd-java-agent:testing')
|
||||
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
|
||||
}
|
||||
|
||||
tasks.register("startServer", com.github.psxpaul.task.ExecFork) {
|
||||
springbootHttpPort = randomOpenPort()
|
||||
dependsOn project(':dd-java-agent').shadowJar, shadowJar
|
||||
|
||||
if (springbootHttpPort == -1) {
|
||||
throw new GradleException("Failed to get random port to start springboot")
|
||||
}
|
||||
workingDir = "${buildDir}"
|
||||
commandLine = "java"
|
||||
args = ["-javaagent:${project(':dd-java-agent').tasks.shadowJar.archivePath}",
|
||||
"-Ddd.writer.type=LoggingWriter",
|
||||
"-Ddd.service.name=java-app",
|
||||
"-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug",
|
||||
"-jar",
|
||||
"${tasks.shadowJar.archivePath}",
|
||||
"--server.port=$springbootHttpPort"]
|
||||
standardOutput "${buildDir}/reports/server.log"
|
||||
waitForPort = springbootHttpPort
|
||||
waitForOutput = "datadog.smoketest.springboot.SpringbootApplication - Started SpringbootApplication"
|
||||
timeout = 240
|
||||
stopAfter = test
|
||||
|
||||
// When tests are disabled this would still be run, so disable this manually
|
||||
onlyIf { !project.rootProject.hasProperty("skipTests") }
|
||||
testCompile project(':dd-smoke-tests')
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
jvmArgs "-Ddatadog.smoketest.server.port=${springbootHttpPort}"
|
||||
dependsOn shadowJar
|
||||
|
||||
dependsOn startServer
|
||||
jvmArgs "-Ddatadog.smoketest.springboot.shadowJar.path=${tasks.shadowJar.archivePath}"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package datadog.smoketest
|
||||
|
||||
import okhttp3.Request
|
||||
|
||||
class SpringBootSmokeTest extends AbstractServerSmokeTest {
|
||||
|
||||
@Override
|
||||
ProcessBuilder createProcessBuilder() {
|
||||
String springBootShadowJar = System.getProperty("datadog.smoketest.springboot.shadowJar.path")
|
||||
|
||||
List<String> command = new ArrayList<>()
|
||||
command.add(javaPath())
|
||||
command.addAll(defaultJavaProperties)
|
||||
command.addAll((String[]) ["-jar", springBootShadowJar, "--server.port=${httpPort}"])
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command)
|
||||
processBuilder.directory(new File(buildDirectory))
|
||||
}
|
||||
|
||||
def "default home page #n th time"() {
|
||||
setup:
|
||||
String url = "http://localhost:${httpPort}/greeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
|
||||
then:
|
||||
def responseBodyStr = response.body().string()
|
||||
responseBodyStr != null
|
||||
responseBodyStr.contains("Sup Dawg")
|
||||
response.body().contentType().toString().contains("text/plain")
|
||||
response.code() == 200
|
||||
|
||||
where:
|
||||
n << (1..200)
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package datadog.trace.agent
|
||||
|
||||
import datadog.trace.agent.test.utils.OkHttpUtils
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import spock.lang.Specification
|
||||
|
||||
class SpringBootSmokeTest extends Specification {
|
||||
|
||||
private OkHttpClient client = OkHttpUtils.client()
|
||||
private int port = Integer.parseInt(System.getProperty("datadog.smoketest.server.port", "8080"))
|
||||
|
||||
def "default home page #n th time"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port/greeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
|
||||
then:
|
||||
def responseBodyStr = response.body().string()
|
||||
responseBodyStr != null
|
||||
responseBodyStr.contains("Sup Dawg")
|
||||
response.body().contentType().toString().contains("text/plain")
|
||||
response.code() == 200
|
||||
|
||||
where:
|
||||
n << (1..200)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package datadog.smoketest
|
||||
|
||||
|
||||
import datadog.trace.agent.test.utils.OkHttpUtils
|
||||
import datadog.trace.agent.test.utils.PortUtils
|
||||
import okhttp3.OkHttpClient
|
||||
import spock.lang.Shared
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
abstract class AbstractServerSmokeTest extends AbstractSmokeTest {
|
||||
|
||||
@Shared
|
||||
int httpPort = PortUtils.randomOpenPort()
|
||||
|
||||
|
||||
protected OkHttpClient client = OkHttpUtils.client()
|
||||
|
||||
def setupSpec() {
|
||||
PortUtils.waitForPortToOpen(httpPort, 240, TimeUnit.SECONDS, serverProcess)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package datadog.smoketest
|
||||
|
||||
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
abstract class AbstractSmokeTest extends Specification {
|
||||
|
||||
@Shared
|
||||
protected String workingDirectory = System.getProperty("user.dir")
|
||||
@Shared
|
||||
protected String buildDirectory = System.getProperty("datadog.smoketest.builddir")
|
||||
@Shared
|
||||
protected String shadowJarPath = System.getProperty("datadog.smoketest.agent.shadowJar.path")
|
||||
@Shared
|
||||
protected String[] defaultJavaProperties
|
||||
|
||||
@Shared
|
||||
protected Process serverProcess
|
||||
|
||||
def setupSpec() {
|
||||
if (buildDirectory == null || shadowJarPath == null) {
|
||||
throw new AssertionError("Expected system properties not found. Smoke tests have to be run from Gradle. Please make sure that is the case.")
|
||||
}
|
||||
|
||||
defaultJavaProperties = [
|
||||
"-javaagent:${shadowJarPath}",
|
||||
"-Ddd.writer.type=LoggingWriter",
|
||||
"-Ddd.service.name=smoke-test-java-app",
|
||||
"-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug",
|
||||
"-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
|
||||
]
|
||||
|
||||
ProcessBuilder processBuilder = createProcessBuilder()
|
||||
|
||||
processBuilder.environment().put("JAVA_HOME", System.getProperty("java.home"))
|
||||
|
||||
processBuilder.redirectErrorStream(true)
|
||||
File log = new File("${buildDirectory}/reports/serverProcess.log")
|
||||
processBuilder.redirectOutput(ProcessBuilder.Redirect.to(log))
|
||||
|
||||
serverProcess = processBuilder.start()
|
||||
}
|
||||
|
||||
String javaPath() {
|
||||
final String separator = System.getProperty("file.separator")
|
||||
return System.getProperty("java.home") + separator + "bin" + separator + "java"
|
||||
}
|
||||
|
||||
def cleanupSpec() {
|
||||
serverProcess?.waitForOrKill(1)
|
||||
}
|
||||
|
||||
abstract ProcessBuilder createProcessBuilder()
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package datadog.smoketest
|
||||
|
||||
import datadog.trace.agent.test.utils.PortUtils
|
||||
import okhttp3.Request
|
||||
import spock.lang.Shared
|
||||
|
||||
class WildflySmokeTest extends AbstractServerSmokeTest {
|
||||
|
||||
@Shared
|
||||
File wildflyDirectory = new File(System.getProperty("datadog.smoketest.wildflyDir"))
|
||||
@Shared
|
||||
int httpsPort = PortUtils.randomOpenPort()
|
||||
@Shared
|
||||
int managementPort = PortUtils.randomOpenPort()
|
||||
|
||||
@Override
|
||||
ProcessBuilder createProcessBuilder() {
|
||||
ProcessBuilder processBuilder =
|
||||
new ProcessBuilder("${wildflyDirectory}/bin/standalone.sh")
|
||||
processBuilder.directory(wildflyDirectory)
|
||||
processBuilder.environment().put("JAVA_OPTS",
|
||||
defaultJavaProperties.join(" ")
|
||||
+ " -Djboss.http.port=${httpPort} -Djboss.https.port=${httpsPort}"
|
||||
+ " -Djboss.management.http.port=${managementPort}")
|
||||
return processBuilder
|
||||
}
|
||||
|
||||
def cleanupSpec() {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||
"${wildflyDirectory}/bin/jboss-cli.sh",
|
||||
"--connect",
|
||||
"--controller=localhost:${managementPort}",
|
||||
"command=:shutdown")
|
||||
processBuilder.directory(wildflyDirectory)
|
||||
Process process = processBuilder.start()
|
||||
process.waitFor()
|
||||
}
|
||||
|
||||
def "default home page #n th time"() {
|
||||
setup:
|
||||
String url = "http://localhost:$httpPort/"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
|
||||
then:
|
||||
def responseBodyStr = response.body().string()
|
||||
responseBodyStr != null
|
||||
responseBodyStr.contains("Your WildFly instance is running.")
|
||||
response.body().contentType().toString().contains("text/html")
|
||||
response.code() == 200
|
||||
|
||||
where:
|
||||
n << (1..200)
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package datadog.trace.agent
|
||||
|
||||
import datadog.trace.agent.test.utils.OkHttpUtils
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import spock.lang.Specification
|
||||
|
||||
class WildflySmokeTest extends Specification {
|
||||
|
||||
OkHttpClient client = OkHttpUtils.client()
|
||||
private int port = Integer.parseInt(System.getProperty("datadog.smoketest.server.port", "8080"))
|
||||
|
||||
def "default home page #n th time"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port/"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
|
||||
then:
|
||||
def responseBodyStr = response.body().string()
|
||||
responseBodyStr != null
|
||||
responseBodyStr.contains("Your WildFly instance is running.")
|
||||
response.body().contentType().toString().contains("text/html")
|
||||
response.code() == 200
|
||||
|
||||
where:
|
||||
n << (1..200)
|
||||
}
|
||||
}
|
|
@ -1,15 +1,10 @@
|
|||
// using this plugin will launch the server in the background and won't block the tests
|
||||
plugins {
|
||||
id 'com.github.psxpaul.execfork' version '0.1.8'
|
||||
}
|
||||
|
||||
ext {
|
||||
serverName = 'wildfly'
|
||||
serverModule = 'servlet'
|
||||
serverVersion = '15.0.0.Final'
|
||||
serverExtension = 'zip'
|
||||
wildflyHttpPort = 8080
|
||||
wildflyManagementPort = 9990
|
||||
|
||||
minJavaVersionForTests = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
@ -30,10 +25,7 @@ dependencies {
|
|||
// organisation = serverName, revision = serverVersion, module = serverModule, ext = serverExtension
|
||||
compile "${serverName}:${serverModule}:${serverVersion}@${serverExtension}"
|
||||
|
||||
testCompile project(':dd-trace-api')
|
||||
testCompile project(':dd-trace-ot')
|
||||
testCompile project(':dd-java-agent:testing')
|
||||
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
|
||||
testCompile project(':dd-smoke-tests')
|
||||
}
|
||||
|
||||
tasks.register("unzip", Copy) {
|
||||
|
@ -55,64 +47,8 @@ tasks.register("unzip", Copy) {
|
|||
onlyIf { !project.rootProject.hasProperty("skipTests") }
|
||||
}
|
||||
|
||||
tasks.register("startServer", com.github.psxpaul.task.ExecFork) {
|
||||
dependsOn project(':dd-java-agent').shadowJar
|
||||
|
||||
wildflyHttpPort = randomOpenPort()
|
||||
// not used, but to ensure https default port 8443 won't clash
|
||||
int httpsPort = randomOpenPort()
|
||||
wildflyManagementPort = randomOpenPort()
|
||||
|
||||
if (wildflyHttpPort == -1 || httpsPort == -1 || wildflyManagementPort == -1) {
|
||||
throw new GradleException("Failed to get random ports to start Wildfly")
|
||||
}
|
||||
|
||||
workingDir = "${buildDir}/wildfly-servlet-15.0.0.Final"
|
||||
commandLine = "${workingDir}/bin/standalone.sh"
|
||||
// ideally this should be good enough to use to stop wildfly, but wildfly needs to gracefully shutdown from jboss-cli.sh
|
||||
// stopAfter = test
|
||||
standardOutput "${buildDir}/reports/server.log"
|
||||
// these params tells the ExecFork plugin to block on startServer task until the port is opened or the string is seen in the ouput
|
||||
waitForPort = wildflyHttpPort
|
||||
waitForOutput = "Undertow HTTP listener default listening on 127.0.0.1:${wildflyHttpPort}"
|
||||
timeout = 240
|
||||
environment = [
|
||||
'JAVA_OPTS': "-javaagent:${project(':dd-java-agent').tasks.shadowJar.archivePath}"
|
||||
+ " -Ddd.writer.type=LoggingWriter" + " -Ddd.service.name=java-app"
|
||||
+ " -Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"
|
||||
+ " -Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
|
||||
+ " -Djboss.http.port=${wildflyHttpPort} -Djboss.https.port=${httpsPort}"
|
||||
+ " -Djboss.management.http.port=${wildflyManagementPort}"
|
||||
]
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
dependsOn unzip
|
||||
|
||||
// When tests are disabled this would still be run, so disable this manually
|
||||
onlyIf { !project.rootProject.hasProperty("skipTests") }
|
||||
}
|
||||
|
||||
tasks.register("stopWildfly", Exec) {
|
||||
project.getLogger().info("Shutting down Wildfly")
|
||||
workingDir = "${buildDir}/wildfly-servlet-15.0.0.Final"
|
||||
commandLine = "${workingDir}/bin/jboss-cli.sh"
|
||||
args = ["--connect", "--controller=localhost:${wildflyManagementPort}", "command=:shutdown"]
|
||||
|
||||
dependsOn startServer
|
||||
|
||||
// When tests are disabled this would still be run, so disable this manually
|
||||
onlyIf { !project.rootProject.hasProperty("skipTests") }
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
// so the test can get this property
|
||||
jvmArgs "-Ddatadog.smoketest.server.port=${wildflyHttpPort}"
|
||||
|
||||
testLogging {
|
||||
events "started"
|
||||
}
|
||||
|
||||
dependsOn startServer
|
||||
|
||||
// ensure that the wildfly server gets shutdown
|
||||
finalizedBy stopWildfly
|
||||
jvmArgs "-Ddatadog.smoketest.wildflyDir=${buildDir}/${serverName}-${serverModule}-${serverVersion}"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
def groovyVer = "2.5.6"
|
||||
def groovyVer = "2.5.7"
|
||||
def spockGroovyVer = groovyVer.replaceAll(/\.\d+$/, '')
|
||||
|
||||
ext {
|
||||
|
|
|
@ -26,7 +26,7 @@ java {
|
|||
doFirst {
|
||||
// We do this specifically for Java7 bytecode generation because we would like to be able to compile
|
||||
// with Java8+ compiler. This likely would require some modifications when we switch to java11 compiler.
|
||||
// Using proper Java7 bootstrap and extentions allows to be sure our code will run on real Java7.
|
||||
// Using proper Java7 bootstrap and extensions allows to be sure our code will run on real Java7.
|
||||
if (JavaVersion.toVersion(sourceCompatibility) == JavaVersion.VERSION_1_7
|
||||
&& JavaVersion.current() != JavaVersion.VERSION_1_7
|
||||
&& System.env.JAVA_7_HOME != null) {
|
||||
|
|
Loading…
Reference in New Issue