Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8266410: jdk/jfr/javaagent/TestLoadedAgent.java failed with "Mismatch in TestEvent count" #7141

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java
Original file line number Diff line number Diff line change
@@ -24,21 +24,23 @@
package jdk.jfr.javaagent;

import java.lang.instrument.Instrumentation;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import jdk.jfr.Configuration;
import jdk.jfr.Event;
import jdk.jfr.Name;
import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
import jdk.jfr.consumer.RecordingFile;
import jdk.test.lib.Asserts;
import jdk.test.lib.jfr.EventNames;

// Java agent that emits events
public class EventEmitterAgent {

private static final long EVENTS = 150_000;
private static final long EVENTS = 15_000;
private static final Path DUMP_PATH = Paths.get("dump.jfr").toAbsolutePath();

// Called when agent is loaded from command line
@@ -88,10 +90,21 @@ static class TestEvent extends Event {
}

public static void validateRecording() throws Exception {
long testEventCount = RecordingFile.readAllEvents(DUMP_PATH)
.stream()
.filter(e -> e.getEventType().getName().equals("Test"))
.count();
long testEventCount = 0;
try (RecordingFile rf = new RecordingFile(DUMP_PATH)) {
while (rf.hasMoreEvents()) {
RecordedEvent e = rf.readEvent();
switch (e.getEventType().getName()) {
case "Test":
testEventCount++;
break;
case "jdk.DataLoss":
System.out.println(e);
break;
}
}
}
System.out.println("File size: " + Files.size(DUMP_PATH));
Asserts.assertEquals(testEventCount, EVENTS, "Mismatch in TestEvent count");
}
}