Skip to content

Commit d1fdec0

Browse files
Merge branch 'master' into alexeyk/fixed-flaky-pekko-test
2 parents 45aabcb + 1a9af7b commit d1fdec0

File tree

5 files changed

+53
-11
lines changed

5 files changed

+53
-11
lines changed

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/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/jboss-modules/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
ext {
3+
// see https://datadoghq.atlassian.net/wiki/x/H4S2NQE
4+
excludeJdk = ['IBM8']
5+
}
6+
27
apply from: "$rootDir/gradle/java.gradle"
38
description = 'JBoss Modules Smoke Tests.'
49

utils/test-utils/src/main/java/datadog/trace/test/util/GCUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public static void awaitGC(final WeakReference<?> ref) throws InterruptedExcepti
2222

2323
public static void awaitGC(final WeakReference<?> ref, final long duration, final TimeUnit unit)
2424
throws InterruptedException {
25+
System.gc();
26+
System.runFinalization();
2527
final long waitNanos = unit.toNanos(duration);
2628
final long start = System.nanoTime();
2729
while (System.nanoTime() - start < waitNanos) {

0 commit comments

Comments
 (0)