Merge pull request #922 from DataDog/landerson/cli-test
Cli Application Smoke Test
This commit is contained in:
commit
b57282daa4
|
@ -1,8 +1,8 @@
|
|||
# Datadog Smoke Tests
|
||||
Assert that various application servers will start up with the Datadog JavaAgent without any obvious ill effects.
|
||||
Assert that various applications 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.
|
||||
* Launch the application with stdout and stderr logged to `$buildDir/reports/server.log`
|
||||
* For web servers, 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.
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "4.0.4"
|
||||
}
|
||||
apply from: "${rootDir}/gradle/java.gradle"
|
||||
description = 'Command Line Application Smoke Tests.'
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes(
|
||||
'Main-Class': 'datadog.smoketest.cli.CliApplication'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':dd-trace-api')
|
||||
|
||||
testCompile project(':dd-smoke-tests')
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
dependsOn shadowJar
|
||||
|
||||
jvmArgs "-Ddatadog.smoketest.cli.shadowJar.path=${tasks.shadowJar.archivePath}"
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package datadog.smoketest.cli;
|
||||
|
||||
import datadog.trace.api.Trace;
|
||||
|
||||
/** Simple application that sleeps then quits. */
|
||||
public class CliApplication {
|
||||
|
||||
public static void main(final String[] args) throws InterruptedException {
|
||||
final CliApplication app = new CliApplication();
|
||||
|
||||
// Sleep to ensure all of the processes are running
|
||||
Thread.sleep(5000);
|
||||
|
||||
System.out.println("Calling example trace");
|
||||
|
||||
app.exampleTrace();
|
||||
|
||||
System.out.println("Finished calling example trace");
|
||||
}
|
||||
|
||||
@Trace(operationName = "example")
|
||||
public void exampleTrace() throws InterruptedException {
|
||||
Thread.sleep(500);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package datadog.smoketest
|
||||
|
||||
import spock.lang.Timeout
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class CliApplicationSmokeTest extends AbstractSmokeTest {
|
||||
// Estimate for the amount of time instrumentation, plus request, plus some extra
|
||||
private static final int TIMEOUT_SECS = 15
|
||||
|
||||
@Override
|
||||
ProcessBuilder createProcessBuilder() {
|
||||
String cliShadowJar = System.getProperty("datadog.smoketest.cli.shadowJar.path")
|
||||
|
||||
List<String> command = new ArrayList<>()
|
||||
command.add(javaPath())
|
||||
command.addAll(defaultJavaProperties)
|
||||
command.addAll((String[]) ["-jar", cliShadowJar])
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command)
|
||||
processBuilder.directory(new File(buildDirectory))
|
||||
}
|
||||
|
||||
@Timeout(value = TIMEOUT_SECS, unit = TimeUnit.SECONDS)
|
||||
def "Cli application process ends before timeout"() {
|
||||
expect:
|
||||
assert serverProcess.waitFor() == 0
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ include ':utils:gc-utils'
|
|||
include ':dd-smoke-tests:play'
|
||||
include ':dd-smoke-tests:springboot'
|
||||
include ':dd-smoke-tests:wildfly'
|
||||
include ':dd-smoke-tests:cli'
|
||||
|
||||
// instrumentation:
|
||||
include ':dd-java-agent:instrumentation:akka-http-10.0'
|
||||
|
|
Loading…
Reference in New Issue