-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from DataDog/ark/java9-logmanager-fix
Workaround LogManager startup issue and add springboot test
- Loading branch information
Showing
13 changed files
with
153 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Datadog Smoke Tests | ||
Assert that various application servers will start up with the Datadog JavaAgent without any obvious ill effects. | ||
|
||
Each subproject underneath `dd-smoke-tests` is a single smoke test. Each test does the following | ||
* Launch the app server with stdout and stderr logged to `$buildDir/reports/server.log` | ||
* Run a spock test which does 200 requests to an endpoint on the server and asserts on an expected response. | ||
|
||
Note that there is nothing special about doing 200 requests. 200 is simply an arbitrarily large number to exercise the server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
// Set properties before any plugins get loaded | ||
project.ext { | ||
// Execute tests on all JVMs, even rare and outdated ones | ||
integrationTests = true | ||
} | ||
|
||
apply from: "${rootDir}/gradle/java.gradle" | ||
|
||
description = 'dd-smoke-tests' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
plugins { | ||
id "com.github.johnrengelman.shadow" version "4.0.1" | ||
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 { | ||
manifest { | ||
attributes( | ||
'Main-Class': 'datadog.smoketest.springboot.SpringbootApplication' | ||
) | ||
} | ||
} | ||
|
||
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' | ||
} | ||
|
||
task startServer(type: 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" | ||
stopAfter = test | ||
} | ||
|
||
tasks.withType(Test) { | ||
jvmArgs "-Ddatadog.smoketest.server.port=${springbootHttpPort}" | ||
|
||
dependsOn startServer | ||
} |
12 changes: 12 additions & 0 deletions
12
...ke-tests/springboot/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package datadog.smoketest.springboot; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringbootApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringbootApplication.class, args); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...tests/springboot/src/main/java/datadog/smoketest/springboot/controller/WebController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package datadog.smoketest.springboot.controller; | ||
|
||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class WebController { | ||
@RequestMapping("/greeting") | ||
public String greeting() { | ||
return "Sup Dawg"; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
dd-smoke-tests/springboot/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
logging.level.root=WARN |
31 changes: 31 additions & 0 deletions
31
dd-smoke-tests/springboot/src/test/groovy/datadog/trace/agent/SpringBootSmokeTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters