Remove okhttp instrumentation from servlet tests
seems to cause some confusion.
MODIFY
.circleci/collect_artifacts.sh
.circleci/collect_artifacts.sh
# Save all important reports and artifacts into (project-root)/build
# This folder will be saved by circleci and available after test runs.
+set -e
+
REPORTS_DIR=./reports
mkdir -p $REPORTS_DIR >/dev/null 2>&1
@@ -11,39 +13,38 @@ mkdir -p $ARTIFACT_DIR >/dev/null 2>&1
function save_reports () {
project_to_save=$1
- if [ -d workspace/$project_to_save/build/reports ]; then
+ echo "saving reports for $project_to_save"
+
report_path=$REPORTS_DIR/$project_to_save/reports
mkdir -p $report_path
cp -r workspace/$project_to_save/build/reports/* $report_path/
- fi
}
function save_libs () {
project_to_save=$1
- if [ -d workspace/$project_to_save/build/libs ]; then
+ echo "saving libs for $project_to_save"
+
libs_path=$ARTIFACT_DIR/$project_to_save/libs
mkdir -p $libs_path
cp -r workspace/$project_to_save/build/libs/* $libs_path/
- fi
}
function save_results () {
- if [ -d workspace/$project_to_save/build/test-results ]; then
+ echo "saving test results"
mkdir -p $REPORTS_DIR/results
find workspace/**/build/test-results -name \*.xml -exec cp {} $REPORTS_DIR/results \;
- fi
}
-save_reports dd-java-agent
-save_reports dd-java-agent/tooling
+save_reports dd-java-agent/agent-tooling
save_reports dd-java-agent/testing
# Save reports for all instrumentation projects
for integration_path in dd-java-agent/instrumentation/*; do
+ if [ -d "workspace/$integration_path/build/reports" ]; then
save_reports $integration_path
+ fi
done
save_reports dd-java-agent-ittests
-save_reports dd-trace-api
save_reports dd-trace-ot
save_libs dd-java-agent

MODIFY
dd-java-agent/instrumentation/servlet-2/servlet-2.gradle
dd-java-agent/instrumentation/servlet-2/servlet-2.gradle
@@ -28,6 +28,5 @@ dependencies {
testCompile group: 'org.eclipse.jetty', name: 'jetty-server', version: '7.0.0.v20091005'
testCompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '7.0.0.v20091005'
- testCompile project(':dd-java-agent:instrumentation:okhttp-3') // used in the tests
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
}

MODIFY
dd-java-agent/instrumentation/servlet-2/src/test/groovy/JettyServletTest.groovy
dd-java-agent/instrumentation/servlet-2/src/test/groovy/JettyServletTest.groovy
@@ -93,7 +93,8 @@ class JettyServletTest extends AgentTestRunner {
expect:
response.body().string().trim() == expectedResponse
- writer.size() == 2 // second (parent) trace is the okhttp call above...
+ writer.waitForTraces(1)
+ writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1
def span = trace[0]
@@ -103,7 +104,7 @@ class JettyServletTest extends AgentTestRunner {
span.context().resourceName == "GET /$path"
span.context().spanType == DDSpanTypes.WEB_SERVLET
!span.context().getErrorFlag()
- span.context().parentId != 0 // parent should be the okhttp call.
+ span.context().parentId == 0
span.context().tags["http.url"] == "http://localhost:$PORT/$path"
span.context().tags["http.method"] == "GET"
span.context().tags["span.kind"] == "server"
@@ -129,7 +130,8 @@ class JettyServletTest extends AgentTestRunner {
expect:
response.body().string().trim() != expectedResponse
- writer.size() == 2 // second (parent) trace is the okhttp call above...
+ writer.waitForTraces(1)
+ writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1
def span = trace[0]
@@ -138,7 +140,7 @@ class JettyServletTest extends AgentTestRunner {
span.context().resourceName == "GET /$path"
span.context().spanType == DDSpanTypes.WEB_SERVLET
span.context().getErrorFlag()
- span.context().parentId != 0 // parent should be the okhttp call.
+ span.context().parentId == 0
span.context().tags["http.url"] == "http://localhost:$PORT/$path"
span.context().tags["http.method"] == "GET"
span.context().tags["span.kind"] == "server"

MODIFY
dd-java-agent/instrumentation/servlet-3/src/test/groovy/JettyServletTest.groovy
dd-java-agent/instrumentation/servlet-3/src/test/groovy/JettyServletTest.groovy
@@ -94,6 +94,7 @@ class JettyServletTest extends AgentTestRunner {
expect:
response.body().string().trim() == expectedResponse
+ writer.waitForTraces(1)
writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1
@@ -131,6 +132,7 @@ class JettyServletTest extends AgentTestRunner {
expect:
response.body().string().trim() != expectedResponse
+ writer.waitForTraces(1)
writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1
@@ -172,6 +174,7 @@ class JettyServletTest extends AgentTestRunner {
expect:
response.body().string().trim() != expectedResponse
+ writer.waitForTraces(1)
writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1

MODIFY
dd-java-agent/instrumentation/servlet-3/src/test/groovy/TomcatServletTest.groovy
dd-java-agent/instrumentation/servlet-3/src/test/groovy/TomcatServletTest.groovy
@@ -93,6 +93,7 @@ class TomcatServletTest extends AgentTestRunner {
expect:
response.body().string().trim() == expectedResponse
+ writer.waitForTraces(1)
writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1
@@ -130,6 +131,7 @@ class TomcatServletTest extends AgentTestRunner {
expect:
response.body().string().trim() != expectedResponse
+ writer.waitForTraces(1)
writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1
@@ -171,6 +173,7 @@ class TomcatServletTest extends AgentTestRunner {
expect:
response.body().string().trim() != expectedResponse
+ writer.waitForTraces(1)
writer.size() == 1
def trace = writer.firstTrace()
trace.size() == 1

Remove okhttp instrumentation from servlet tests

seems to cause some confusion.