File tree Expand file tree Collapse file tree 5 files changed +53
-11
lines changed
groovy/datadog/trace/agent
dd-smoke-tests/jboss-modules
utils/test-utils/src/main/java/datadog/trace/test/util Expand file tree Collapse file tree 5 files changed +53
-11
lines changed Original file line number Diff line number Diff line change 11# Petclinic download and compilation stage
22FROM eclipse-temurin:17-jammy as petclinic
33
4+ ARG SPRING_PETCLINIC_COMMIT=cefaf55dd124d0635abfe857c3c99a3d3ea62017
5+
46RUN 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
1319RUN cd spring-petclinic \
1420 && ./mvnw package -Dmaven.test.skip=true \
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 11package jvmbootstraptest ;
22
3+ import static java .util .concurrent .TimeUnit .MINUTES ;
4+
35import datadog .trace .test .util .GCUtils ;
6+ import java .lang .management .ClassLoadingMXBean ;
7+ import java .lang .management .ManagementFactory ;
48
59public 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}
Original file line number Diff line number Diff line change 11
2+ ext {
3+ // see https://datadoghq.atlassian.net/wiki/x/H4S2NQE
4+ excludeJdk = [' IBM8' ]
5+ }
6+
27apply from : " $rootDir /gradle/java.gradle"
38description = ' JBoss Modules Smoke Tests.'
49
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments