Skip to content

Commit 1deb0cd

Browse files
committed
Merge remote-tracking branch 'origin/master' into bdu/pr-gate
2 parents f6df319 + ff2b2e9 commit 1deb0cd

File tree

50 files changed

+918
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+918
-15
lines changed

.gitlab-ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ stages:
2020
- generate-signing-key
2121

2222
variables:
23+
# Gitlab runner features; see https://docs.gitlab.com/runner/configuration/feature-flags.html
24+
# Fold and time all script sections
25+
FF_SCRIPT_SECTIONS: 1
26+
2327
REGISTRY: 486234852809.dkr.ecr.us-east-1.amazonaws.com
2428
BUILD_JOB_NAME: "build"
2529
DEPENDENCY_CACHE_POLICY: pull
@@ -133,8 +137,14 @@ default:
133137
before_script:
134138
- source .gitlab/gitlab-utils.sh
135139
- export GRADLE_USER_HOME=`pwd`/.gradle
140+
- |
141+
# Don't put jvm args here as it will be picked up by child gradle processes used in tests
142+
cat << EOF > $GRADLE_USER_HOME/gradle.properties
143+
mavenRepositoryProxy=$MAVEN_REPOSITORY_PROXY
144+
gradlePluginProxy=$GRADLE_PLUGIN_PROXY
145+
EOF
136146
- export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx$GRADLE_MEM -Xms$GRADLE_MEM -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
137-
- export GRADLE_ARGS=" --build-cache --stacktrace --no-daemon --parallel --max-workers=$GRADLE_WORKERS -PmavenRepositoryProxy=$MAVEN_REPOSITORY_PROXY -PgradlePluginProxy=$GRADLE_PLUGIN_PROXY"
147+
- export GRADLE_ARGS=" --build-cache --stacktrace --no-daemon --parallel --max-workers=$GRADLE_WORKERS"
138148
- *normalize_node_index
139149
# for weird reasons, gradle will always "chmod 700" the .gradle folder
140150
# with Gitlab caching, .gradle is always owned by root and thus gradle's chmod invocation fails

.gitlab/one-pipeline.locked.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# DO NOT EDIT THIS FILE MANUALLY
22
# This file is auto-generated by automation.
33
include:
4-
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/05e116339b9780a138a474d0348e97debfca97f27bbc4ca489cf4e4c90d9cc94/one-pipeline.yml
4+
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/f2050f53c1f5aed62a24e6b406c746e7d593230ce02b5d56d2a2296db763ebf4/one-pipeline.yml

benchmark/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Petclinic download and compilation stage
22
FROM eclipse-temurin:17-jammy as petclinic
33

4+
ARG SPRING_PETCLINIC_COMMIT=cefaf55dd124d0635abfe857c3c99a3d3ea62017
5+
46
RUN apt-get update \
57
&& apt-get -y install git \
68
&& apt-get -y clean \
79
&& rm -rf /var/lib/apt/lists/*
810

9-
RUN git clone --depth 1 --branch main --single-branch https://github.com/spring-projects/spring-petclinic.git \
10-
&& cd spring-petclinic \
11-
&& ./mvnw dependency:go-offline
11+
RUN set -eux;\
12+
git init spring-petclinic;\
13+
cd spring-petclinic;\
14+
git remote add origin https://github.com/spring-projects/spring-petclinic.git;\
15+
git fetch --depth 1 origin ${SPRING_PETCLINIC_COMMIT};\
16+
git checkout ${SPRING_PETCLINIC_COMMIT};\
17+
./mvnw dependency:go-offline
1218

1319
RUN cd spring-petclinic \
1420
&& ./mvnw package -Dmaven.test.skip=true \

dd-java-agent/src/main/java/datadog/trace/bootstrap/AgentBootstrap.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
public final class AgentBootstrap {
4747
static final String LIB_INJECTION_ENABLED_ENV_VAR = "DD_INJECTION_ENABLED";
4848
static final String LIB_INJECTION_FORCE_SYS_PROP = "dd.inject.force";
49+
static final String LIB_INSTRUMENTATION_SOURCE_SYS_PROP = "dd.instrumentation.source";
4950

5051
private static final Class<?> thisClass = AgentBootstrap.class;
5152
private static final int MAX_EXCEPTION_CHAIN_LENGTH = 99;
@@ -134,6 +135,12 @@ private static void agentmainImpl(
134135
return;
135136
}
136137

138+
if (getConfig(LIB_INJECTION_ENABLED_ENV_VAR)) {
139+
recordInstrumentationSource("ssi");
140+
} else {
141+
recordInstrumentationSource("cmd_line");
142+
}
143+
137144
final URL agentJarURL = installAgentJar(inst);
138145
final Class<?> agentClass;
139146
try {
@@ -164,6 +171,10 @@ static boolean getConfig(String configName) {
164171
}
165172
}
166173

174+
private static void recordInstrumentationSource(String source) {
175+
SystemUtils.trySetProperty(LIB_INSTRUMENTATION_SOURCE_SYS_PROP, source);
176+
}
177+
167178
static boolean exceptionCauseChainContains(Throwable ex, String exClassName) {
168179
Set<Throwable> stack = Collections.newSetFromMap(new IdentityHashMap<>());
169180
Throwable t = ex;

dd-java-agent/src/main/java/datadog/trace/bootstrap/SystemUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public static String tryGetProperty(String property) {
2323
}
2424
}
2525

26+
public static String trySetProperty(String property, String value) {
27+
try {
28+
return System.setProperty(property, value);
29+
} catch (SecurityException e) {
30+
return null;
31+
}
32+
}
33+
2634
public static String getPropertyOrDefault(String property, String defaultValue) {
2735
try {
2836
return System.getProperty(property, defaultValue);

dd-java-agent/src/test/groovy/datadog/trace/agent/InstrumenterUnloadTest.groovy

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,26 @@ class InstrumenterUnloadTest extends Specification {
2626
, ["DD_API_KEY": API_KEY]
2727
, new PrintStream(testOutput))
2828

29-
int unloadCount = 0
29+
boolean canaryUnloaded = false
30+
int unloadedInstrumentationCount = 0
3031
new ByteArrayInputStream((testOutput.toByteArray())).eachLine {
3132
System.out.println(it)
33+
if (it =~ /(?i)unload.*Canary/) {
34+
canaryUnloaded = true
35+
}
3236
if (it =~ /(?i)unload.* datadog.trace.instrumentation./) {
33-
unloadCount++
37+
unloadedInstrumentationCount++
3438
}
3539
}
3640

41+
if (!canaryUnloaded) {
42+
System.out.println("WARNING: Canary class was not unloaded!")
43+
}
44+
3745
then:
3846
returnCode == 0
39-
unloadCount > 0
47+
// skip check if we couldn't even unload our Canary class, as that
48+
// indicates full GC didn't happen enough to trigger any unloading
49+
!canaryUnloaded || unloadedInstrumentationCount > 0
4050
}
4151
}
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
package jvmbootstraptest;
22

3+
import static java.util.concurrent.TimeUnit.MINUTES;
4+
35
import datadog.trace.test.util.GCUtils;
6+
import java.lang.management.ClassLoadingMXBean;
7+
import java.lang.management.ManagementFactory;
48

59
public class UnloadingChecker {
6-
public static void main(final String[] args) {
7-
try {
8-
GCUtils.awaitGC();
9-
} catch (InterruptedException e) {
10-
e.printStackTrace();
10+
static class Canary {}
11+
12+
public static void main(final String[] args) throws Exception {
13+
ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();
14+
long initialUnloadCount = classLoadingMXBean.getUnloadedClassCount();
15+
16+
// load an isolated class which we know can be unloaded after a full GC
17+
new IsolatingClassLoader().loadClass("jvmbootstraptest.UnloadingChecker$Canary");
18+
19+
long waitNanos = MINUTES.toNanos(2);
20+
long startNanos = System.nanoTime();
21+
22+
while (System.nanoTime() - startNanos < waitNanos) {
23+
try {
24+
GCUtils.awaitGC();
25+
} catch (Throwable ignore) {
26+
}
27+
if (initialUnloadCount < classLoadingMXBean.getUnloadedClassCount()) {
28+
break; // some class unloading has taken place, stop and check results
29+
}
1130
}
1231
}
1332
}

dd-smoke-tests/gradle/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ test {
1818
events "passed", "skipped", "failed", "standardOut", "standardError"
1919
}
2020

21+
if (project.hasProperty("mavenRepositoryProxy")) {
22+
// propagate proxy URL to tests, to then propagate it to nested Gradle builds
23+
environment "MAVEN_REPOSITORY_PROXY", project.property("mavenRepositoryProxy")
24+
}
25+
2126
// overriding the default timeout of 9 minutes set in configure_tests.gradle,
2227
// as Gradle smoke tests might run for a longer duration
2328
timeout = Duration.of(15, ChronoUnit.MINUTES)

dd-smoke-tests/gradle/src/test/groovy/datadog/smoketest/GradleDaemonSmokeTest.groovy

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class GradleDaemonSmokeTest extends AbstractGradleTest {
9898

9999
where:
100100
gradleVersion | projectName | flakyTests | expectedOrder | eventsNumber
101-
"5.1" | "test-succeed-junit-4-class-ordering" | [
101+
"7.6.4" | "test-succeed-junit-4-class-ordering" | [
102102
test("datadog.smoke.TestSucceedB", "test_succeed"),
103103
test("datadog.smoke.TestSucceedB", "test_succeed_another"),
104104
test("datadog.smoke.TestSucceedA", "test_succeed")
@@ -239,12 +239,19 @@ class GradleDaemonSmokeTest extends AbstractGradleTest {
239239
}
240240

241241
private runGradle(String gradleVersion, List<String> arguments, boolean successExpected) {
242+
def buildEnv = ["GRADLE_VERSION": gradleVersion]
243+
244+
def mavenRepositoryProxy = System.getenv("MAVEN_REPOSITORY_PROXY")
245+
if (mavenRepositoryProxy != null) {
246+
buildEnv += ["MAVEN_REPOSITORY_PROXY": System.getenv("MAVEN_REPOSITORY_PROXY")]
247+
}
248+
242249
GradleRunner gradleRunner = GradleRunner.create()
243250
.withTestKitDir(testKitFolder.toFile())
244251
.withProjectDir(projectFolder.toFile())
245252
.withGradleVersion(gradleVersion)
246253
.withArguments(arguments)
247-
.withEnvironment(["GRADLE_VERSION": gradleVersion])
254+
.withEnvironment(buildEnv)
248255
.forwardOutput()
249256

250257
println "${new Date()}: $specificationContext.currentIteration.displayName - Starting Gradle run"

dd-smoke-tests/gradle/src/test/resources/test-corrupted-config-legacy-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-corrupted-config-new-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-failed-flaky-retries/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-failed-legacy-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-failed-new-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-skip-legacy-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-skip-new-instrumentation/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-succeed-gradle-plugin-test/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ gradlePlugin {
1414

1515
repositories {
1616
mavenLocal()
17+
18+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
19+
if (proxyUrl) {
20+
println "Using proxy repository: $proxyUrl"
21+
maven {
22+
url = proxyUrl
23+
allowInsecureProtocol = true
24+
}
25+
}
26+
1727
mavenCentral()
1828
}
1929

dd-smoke-tests/gradle/src/test/resources/test-succeed-junit-4-class-ordering/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ apply plugin: 'java'
22

33
repositories {
44
mavenLocal()
5+
6+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
7+
if (proxyUrl) {
8+
println "Using proxy repository: $proxyUrl"
9+
maven {
10+
url = proxyUrl
11+
allowInsecureProtocol = true
12+
}
13+
}
14+
515
mavenCentral()
616
}
717

dd-smoke-tests/gradle/src/test/resources/test-succeed-junit-5/build.gradleTest

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ apply plugin: 'jvm-test-suite'
33

44
repositories {
55
mavenLocal()
6+
7+
def proxyUrl = System.getenv("MAVEN_REPOSITORY_PROXY")
8+
if (proxyUrl) {
9+
println "Using proxy repository: $proxyUrl"
10+
maven {
11+
url = proxyUrl
12+
allowInsecureProtocol = true
13+
}
14+
}
15+
616
mavenCentral()
717
}
818

0 commit comments

Comments
 (0)