|
14 | 14 | import com.fasterxml.jackson.databind.ObjectMapper; |
15 | 15 | import com.google.common.collect.Multimap; |
16 | 16 | import datadog.environment.JavaVirtualMachine; |
| 17 | +import datadog.environment.OperatingSystem; |
| 18 | +import datadog.environment.SystemProperties; |
17 | 19 | import datadog.trace.api.Pair; |
18 | 20 | import datadog.trace.api.config.ProfilingConfig; |
19 | 21 | import delight.fileupload.FileUpload; |
|
49 | 51 | import org.junit.jupiter.api.DisplayName; |
50 | 52 | import org.junit.jupiter.api.Test; |
51 | 53 | import org.junit.jupiter.api.TestInfo; |
52 | | -import org.junit.jupiter.api.condition.DisabledIf; |
53 | 54 | import org.junit.jupiter.api.condition.DisabledIfSystemProperty; |
| 55 | +import org.junit.jupiter.params.ParameterizedTest; |
| 56 | +import org.junit.jupiter.params.provider.ValueSource; |
54 | 57 | import org.openjdk.jmc.common.IMCStackTrace; |
55 | 58 | import org.openjdk.jmc.common.item.Aggregators; |
56 | 59 | import org.openjdk.jmc.common.item.IAttribute; |
|
68 | 71 | import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs; |
69 | 72 | import org.slf4j.Logger; |
70 | 73 | import org.slf4j.LoggerFactory; |
71 | | -import spock.util.environment.OperatingSystem; |
72 | 74 |
|
73 | 75 | @DisabledIfSystemProperty(named = "java.vm.name", matches = ".*J9.*") |
74 | | -@DisabledIf( |
75 | | - value = "isJavaVersionAtLeast24", |
76 | | - disabledReason = "Failing on Java 24. Skip until we have a fix.") |
77 | 76 | class JFRBasedProfilingIntegrationTest { |
78 | 77 | private static final Logger log = LoggerFactory.getLogger(JFRBasedProfilingIntegrationTest.class); |
79 | 78 | private static final Duration ONE_NANO = Duration.ofNanos(1); |
@@ -155,47 +154,57 @@ void teardown() throws Exception { |
155 | 154 | } |
156 | 155 | } |
157 | 156 |
|
158 | | - @Test |
| 157 | + @ParameterizedTest |
| 158 | + @ValueSource(strings = {"jfr", "ddprof"}) |
159 | 159 | @DisplayName("Test continuous recording - no jmx delay, default compression") |
160 | | - public void testContinuousRecording_no_jmx_delay(final TestInfo testInfo) throws Exception { |
| 160 | + public void testContinuousRecording_no_jmx_delay(String profiler, final TestInfo testInfo) |
| 161 | + throws Exception { |
| 162 | + Assumptions.assumeTrue("jfr".equals(profiler) || OperatingSystem.isLinux()); |
161 | 163 | testWithRetry( |
162 | 164 | () -> |
163 | 165 | testContinuousRecording( |
164 | | - 0, ENDPOINT_COLLECTION_ENABLED, OperatingSystem.getCurrent().isLinux(), false), |
| 166 | + 0, ENDPOINT_COLLECTION_ENABLED, "ddprof".equals(profiler), false), |
165 | 167 | testInfo, |
166 | 168 | 5); |
167 | 169 | } |
168 | 170 |
|
169 | | - @Test |
| 171 | + @ParameterizedTest |
| 172 | + @ValueSource(strings = {"jfr", "ddprof"}) |
170 | 173 | @DisplayName("Test continuous recording - no jmx delay, zstd compression") |
171 | | - public void testContinuousRecording_no_jmx_delay_jmethodid_cache(final TestInfo testInfo) |
| 174 | + public void testContinuousRecording_no_jmx_delay_zstd(String profiler, final TestInfo testInfo) |
172 | 175 | throws Exception { |
| 176 | + Assumptions.assumeTrue("jfr".equals(profiler) || OperatingSystem.isLinux()); |
173 | 177 | testWithRetry( |
174 | 178 | () -> |
175 | 179 | testContinuousRecording( |
176 | | - 0, ENDPOINT_COLLECTION_ENABLED, OperatingSystem.getCurrent().isLinux(), true), |
| 180 | + 0, ENDPOINT_COLLECTION_ENABLED, "ddprof".equals(profiler), true), |
177 | 181 | testInfo, |
178 | 182 | 5); |
179 | 183 | } |
180 | 184 |
|
181 | | - @Test |
| 185 | + @ParameterizedTest |
| 186 | + @ValueSource(strings = {"jfr", "ddprof"}) |
182 | 187 | @DisplayName("Test continuous recording - 1 sec jmx delay, default compression") |
183 | | - public void testContinuousRecording(final TestInfo testInfo) throws Exception { |
| 188 | + public void testContinuousRecording(String profiler, final TestInfo testInfo) throws Exception { |
| 189 | + Assumptions.assumeTrue("jfr".equals(profiler) || OperatingSystem.isLinux()); |
184 | 190 | testWithRetry( |
185 | 191 | () -> |
186 | 192 | testContinuousRecording( |
187 | | - 1, ENDPOINT_COLLECTION_ENABLED, OperatingSystem.getCurrent().isLinux(), false), |
| 193 | + 1, ENDPOINT_COLLECTION_ENABLED, "ddprof".equals(profiler), false), |
188 | 194 | testInfo, |
189 | 195 | 5); |
190 | 196 | } |
191 | 197 |
|
192 | | - @Test |
| 198 | + @ParameterizedTest |
| 199 | + @ValueSource(strings = {"jfr", "ddprof"}) |
193 | 200 | @DisplayName("Test continuous recording - 1 sec jmx delay, zstd compression") |
194 | | - public void testContinuousRecording_zstd(final TestInfo testInfo) throws Exception { |
| 201 | + public void testContinuousRecording_zstd(String profiler, final TestInfo testInfo) |
| 202 | + throws Exception { |
| 203 | + Assumptions.assumeTrue("jfr".equals(profiler) || OperatingSystem.isLinux()); |
195 | 204 | testWithRetry( |
196 | 205 | () -> |
197 | 206 | testContinuousRecording( |
198 | | - 1, ENDPOINT_COLLECTION_ENABLED, OperatingSystem.getCurrent().isLinux(), true), |
| 207 | + 1, ENDPOINT_COLLECTION_ENABLED, "ddprof".equals(profiler), true), |
199 | 208 | testInfo, |
200 | 209 | 5); |
201 | 210 | } |
@@ -368,6 +377,15 @@ private static void verifyJdkEventsDisabled(IItemCollection events) { |
368 | 377 | assertFalse(events.apply(ItemFilters.type("jdk.ThreadPark")).hasItems()); |
369 | 378 | } |
370 | 379 |
|
| 380 | + private static void verifyJdkEvents(IItemCollection events) { |
| 381 | + String cpuSampleType = "jdk.ExecutionSample"; |
| 382 | + if (JavaVirtualMachine.isJavaVersionAtLeast(25) && OperatingSystem.isLinux()) { |
| 383 | + // for Java 25+ we are defaulting to 'jdk.CPUTimeSample' on Linux |
| 384 | + cpuSampleType = "jdk.CPUTimeSample"; |
| 385 | + } |
| 386 | + assertTrue(events.apply(ItemFilters.type(cpuSampleType)).hasItems()); |
| 387 | + } |
| 388 | + |
371 | 389 | private static void verifyDatadogEventsNotCorrupt(IItemCollection events) { |
372 | 390 | // if we emit any of these events during the test they mustn't have corrupted context |
373 | 391 | for (String eventName : |
@@ -621,6 +639,7 @@ private void assertRecordingEvents( |
621 | 639 | // TODO ddprof (async) profiler seems to be having some issues with stack depth limit and |
622 | 640 | // native frames |
623 | 641 | } else { |
| 642 | + verifyJdkEvents(events); |
624 | 643 | // make sure the stack depth limit is respected |
625 | 644 | for (IItemIterable lane : events.apply(ItemFilters.type(JdkTypeIDs.EXECUTION_SAMPLE))) { |
626 | 645 | IMemberAccessor<IMCStackTrace, IItem> stackTraceAccessor = |
@@ -838,8 +857,7 @@ private static ProcessBuilder createProcessBuilder( |
838 | 857 | } |
839 | 858 |
|
840 | 859 | private static String javaPath() { |
841 | | - final String separator = System.getProperty("file.separator"); |
842 | | - return System.getProperty("java.home") + separator + "bin" + separator + "java"; |
| 860 | + return Paths.get(SystemProperties.getOrDefault("java.home", ""), "bin", "java").toString(); |
843 | 861 | } |
844 | 862 |
|
845 | 863 | private static String buildDirectory() { |
|
0 commit comments