@@ -3,11 +3,14 @@ import com.lambdaworks.redis.RedisClient
33import com.lambdaworks.redis.api.StatefulConnection
44import com.lambdaworks.redis.api.async.RedisAsyncCommands
55import com.lambdaworks.redis.api.sync.RedisCommands
6+ import com.sun.management.HotSpotDiagnosticMXBean
67import datadog.trace.agent.test.naming.VersionedNamingTestBase
78import datadog.trace.agent.test.utils.PortUtils
89import redis.embedded.RedisServer
910import spock.lang.Shared
1011
12+ import javax.management.MBeanServer
13+ import java.lang.management.ManagementFactory
1114import java.util.concurrent.Executors
1215import java.util.concurrent.ScheduledExecutorService
1316import java.util.concurrent.ScheduledFuture
@@ -122,8 +125,13 @@ abstract class Lettuce4ClientTestBase extends VersionedNamingTestBase {
122125 }
123126
124127 void start () {
128+ new File (outputDir, " ${ System.currentTimeMillis()} -start-mark.txt" ) << testName
129+ heapDump(" initial" )
130+
125131 task = scheduler. scheduleAtFixedRate({
126- def reportFile = new File (outputDir, " thread-dump-${ System.currentTimeMillis()} .log" )
132+ heapDump(" test" )
133+
134+ def reportFile = new File (outputDir, " ${ System.currentTimeMillis()} -thread-dump.log" )
127135 try (def writer = new FileWriter (reportFile)) {
128136 writer. write(" === Test: ${ testName} ===\n " )
129137 writer. write(" === Thread Dump Triggered at ${ new Date()} ===\n " )
@@ -133,7 +141,15 @@ abstract class Lettuce4ClientTestBase extends VersionedNamingTestBase {
133141 }
134142 writer. write(" ==============================================\n " )
135143 }
136- }, 10001 , 60000 , TimeUnit . MILLISECONDS )
144+ }, 10000 , 60000 , TimeUnit . MILLISECONDS )
145+ }
146+
147+ void heapDump (String kind ) {
148+ def heapDumpFile = new File (outputDir, " ${ System.currentTimeMillis()} -heap-dump-${ kind} .hprof" ). absolutePath
149+ MBeanServer server = ManagementFactory . getPlatformMBeanServer()
150+ HotSpotDiagnosticMXBean mxBean = ManagementFactory . newPlatformMXBeanProxy(
151+ server, " com.sun.management:type=HotSpotDiagnostic" , HotSpotDiagnosticMXBean . class)
152+ mxBean. dumpHeap(heapDumpFile, true )
137153 }
138154
139155 void stop () {
0 commit comments