-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b31030
commit b100bc8
Showing
3 changed files
with
74 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
#!/usr/bin/env bash | ||
SERVICE_NAME="dd-trace-java" | ||
PIPELINE_STAGE=$1 | ||
TEST_JVM=$2 | ||
|
||
# JAVA_???_HOME are set in the base image for each used JDK https://github.com/DataDog/dd-trace-java-docker-build/blob/master/Dockerfile#L86 | ||
java_home="JAVA_$2_HOME" | ||
java_bin="${!java_home}/bin/java" | ||
if [ ! -x $java_bin ]; then | ||
java_bin=$(which java) | ||
JAVA_HOME="JAVA_${TEST_JVM}_HOME" | ||
JAVA_BIN="${!JAVA_HOME}/bin/java" | ||
if [ ! -x "$JAVA_BIN" ]; then | ||
JAVA_BIN=$(which java) | ||
fi | ||
|
||
java_props=$($java_bin -XshowSettings:properties -version 2>&1) | ||
java_prop () { | ||
echo "$(echo "$java_props" | grep $1 | head -n1 | cut -d'=' -f2 | xargs)" | ||
# Extract Java properties from the JVM used to run the tests | ||
JAVA_PROPS=$($JAVA_BIN -XshowSettings:properties -version 2>&1) | ||
java_prop() { | ||
local PROP_NAME=$1 | ||
echo "$JAVA_PROPS" | grep "$PROP_NAME" | head -n1 | cut -d'=' -f2 | xargs | ||
} | ||
|
||
# based on tracer implementation: https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/TestDecorator.java#L55-L77 | ||
datadog-ci junit upload --service $SERVICE_NAME \ | ||
--logs \ | ||
--tags "test.traits:{\"marker\":[\"$1\"]}" \ | ||
--tags "runtime.name:$(java_prop java.runtime.name)" \ | ||
--tags "runtime.vendor:$(java_prop java.vendor)" \ | ||
--tags "runtime.version:$(java_prop java.version)" \ | ||
--tags "os.architecture:$(java_prop os.arch)" \ | ||
--tags "os.platform:$(java_prop os.name)" \ | ||
--tags "os.version:$(java_prop os.version)" \ | ||
./results | ||
# Upload test results to CI Visibility | ||
junit_upload() { | ||
# based on tracer implementation: https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/TestDecorator.java#L55-L77 | ||
DD_API_KEY=$1 \ | ||
datadog-ci junit upload --service $SERVICE_NAME \ | ||
--logs \ | ||
--tags "test.traits:{\"marker\":[\"$PIPELINE_STAGE\"]}" \ | ||
--tags "runtime.name:$(java_prop java.runtime.name)" \ | ||
--tags "runtime.vendor:$(java_prop java.vendor)" \ | ||
--tags "runtime.version:$(java_prop java.version)" \ | ||
--tags "os.architecture:$(java_prop os.arch)" \ | ||
--tags "os.platform:$(java_prop os.name)" \ | ||
--tags "os.version:$(java_prop os.version)" \ | ||
./results | ||
} | ||
|
||
# Upload test results to production environment like all other CI jobs | ||
junit_upload "$DATADOG_API_KEY_PROD" | ||
# And also upload to staging environment to benefit from the new features not yet released | ||
junit_upload "$DATADOG_API_KEY_DDSTAGING" |
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