Skip to content

Commit 4795008

Browse files
committed
Add profiler integration test assertions
1 parent 3f17bd9 commit 4795008

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

dd-smoke-tests/profiling-integration-tests/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ dependencies {
3636
tasks.withType(Test).configureEach {
3737
dependsOn "shadowJar"
3838
jvmArgs "-Ddatadog.smoketest.profiling.shadowJar.path=${tasks.shadowJar.archiveFile.get()}"
39+
40+
testLogging {
41+
events "started", "passed", "skipped", "failed"
42+
showStandardStreams = true
43+
}
3944
}
4045

4146
shadowJar {

dd-smoke-tests/profiling-integration-tests/src/test/java/datadog/smoketest/JFRBasedProfilingIntegrationTest.java

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void testContinuousRecording(final TestInfo testInfo) throws Exception {
191191

192192
@Test
193193
@DisplayName("Test continuous recording - 1 sec jmx delay, zstd compression")
194-
public void testContinuousRecording_jmethodid_cache(final TestInfo testInfo) throws Exception {
194+
public void testContinuousRecording_zstd(final TestInfo testInfo) throws Exception {
195195
testWithRetry(
196196
() ->
197197
testContinuousRecording(
@@ -461,7 +461,7 @@ void testBogusApiKey(final TestInfo testInfo) throws Exception {
461461
*/
462462
final long ts = System.nanoTime();
463463
while (!checkLogLines(
464-
logFilePath, line -> line.contains("Initializing profiler tracer integrations"))) {
464+
logFilePath, line -> line.contains("Initializing profiler context integration"))) {
465465
Thread.sleep(500);
466466
// Wait at most 30 seconds
467467
if (System.nanoTime() - ts > 30_000_000_000L) {
@@ -584,15 +584,6 @@ private void assertRecordingEvents(
584584
events.apply(ItemFilters.type("jdk.SystemProcess")).hasItems(),
585585
"jdk.SystemProcess events should not be collected");
586586

587-
assertTrue(
588-
events
589-
.apply(
590-
ItemFilters.and(
591-
ItemFilters.type("datadog.ProfilerSetting"),
592-
ItemFilters.equals(JdkAttributes.REC_SETTING_NAME, "Stack Depth"),
593-
ItemFilters.equals(
594-
JdkAttributes.REC_SETTING_VALUE, String.valueOf(STACK_DEPTH_LIMIT))))
595-
.hasItems());
596587
if (expectEndpointEvents) {
597588
// Check endpoint events
598589
final IItemCollection endpointEvents = events.apply(ItemFilters.type("datadog.Endpoint"));
@@ -619,6 +610,8 @@ private void assertRecordingEvents(
619610
}
620611
}
621612
}
613+
assertEquals(asyncProfilerEnabled, hasAuxiliaryDdprof(events));
614+
verifyStackDepthSetting(events, asyncProfilerEnabled);
622615
if (asyncProfilerEnabled) {
623616
verifyJdkEventsDisabled(events);
624617
verifyDatadogEventsNotCorrupt(events);
@@ -662,8 +655,45 @@ private void assertRecordingEvents(
662655
assertEquals(Runtime.getRuntime().availableProcessors(), val);
663656

664657
assertTrue(events.apply(ItemFilters.type("datadog.ProfilerSetting")).hasItems());
665-
// FIXME - for some reason the events are disabled by JFR despite being explicitly enabled
666-
// assertTrue(events.apply(ItemFilters.type("datadog.QueueTime")).hasItems());
658+
// FIXME - for some reason the events are disabled by JFR despite being explicitly enabled
659+
// assertTrue(events.apply(ItemFilters.type("datadog.QueueTime")).hasItems());
660+
}
661+
662+
private static void verifyStackDepthSetting(
663+
IItemCollection events, boolean asyncProfilerEnabled) {
664+
assertTrue(
665+
events
666+
.apply(
667+
ItemFilters.and(
668+
ItemFilters.type("datadog.ProfilerSetting"),
669+
ItemFilters.equals(
670+
JdkAttributes.REC_SETTING_NAME,
671+
(asyncProfilerEnabled ? "ddprof" : "JFR") + " Stack Depth"),
672+
ItemFilters.equals(
673+
JdkAttributes.REC_SETTING_VALUE, String.valueOf(STACK_DEPTH_LIMIT))))
674+
.hasItems());
675+
}
676+
677+
private static boolean hasAuxiliaryDdprof(IItemCollection events) {
678+
events =
679+
events.apply(
680+
ItemFilters.and(
681+
ItemFilters.type("datadog.ProfilerSetting"),
682+
ItemFilters.equals(JdkAttributes.REC_SETTING_NAME, "Auxiliary Profiler")));
683+
if (!events.hasItems()) {
684+
return false;
685+
}
686+
for (IItemIterable event : events) {
687+
IMemberAccessor<String, IItem> valueAccessor =
688+
JdkAttributes.REC_SETTING_VALUE.getAccessor(event.getType());
689+
for (IItem item : event) {
690+
String value = valueAccessor.getMember(item);
691+
if ("ddprof".equals(value)) {
692+
return true;
693+
}
694+
}
695+
}
696+
return false;
667697
}
668698

669699
private static void processExecutionSamples(

0 commit comments

Comments
 (0)