8266410: jdk/jfr/javaagent/TestLoadedAgent.java failed with "Mismatch in TestEvent count"
Reviewed-by: mgronlun
This commit is contained in:
parent
5523ddebd5
commit
6179e13b08
@ -24,6 +24,7 @@
|
||||
package jdk.jfr.javaagent;
|
||||
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@ -31,6 +32,7 @@ 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;
|
||||
@ -38,7 +40,7 @@ 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 @@ public class EventEmitterAgent {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user