Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
8250903: jdk/jfr/javaagent/TestLoadedAgent.java fails with Mismatch i…
…n TestEvent count

Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Jan 7, 2021
1 parent 4f914e2 commit 4a478b8
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions test/jdk/jdk/jfr/javaagent/EventEmitterAgent.java
Expand Up @@ -35,12 +35,10 @@
import jdk.test.lib.Asserts;
import jdk.test.lib.jfr.EventNames;

// Java agent that emits in multiple threads
// Java agent that emits events
public class EventEmitterAgent {

private static final int THREADS = 5;
private static final int EVENTS_PER_THREAD = 150_000;
private static final int EXPECTED_COUNT = THREADS * EVENTS_PER_THREAD;
private static final long EVENTS = 150_000;
private static final Path DUMP_PATH = Paths.get("dump.jfr").toAbsolutePath();

// Called when agent is loaded from command line
Expand All @@ -58,20 +56,13 @@ private static void agentWork() throws Exception {
r.enable(EventNames.JavaExceptionThrow);
r.setDestination(DUMP_PATH);
r.start();
Thread[] threads = new Thread[THREADS];
for (int i = 0; i < THREADS; i++) {
threads[i] = new Thread(EventEmitterAgent::emitEvents);
threads[i].start();
}
for (int i = 0; i < THREADS; i++) {
threads[i].join();
}
emitEvents();
r.stop();
}
}

public static void emitEvents() {
for (int i = 0; i < EVENTS_PER_THREAD; i++) {
for (int i = 0; i < EVENTS; i++) {
TestEvent e = new TestEvent();
e.msg = "Long message that puts pressure on the string pool " + i % 100;
e.count = i;
Expand All @@ -80,7 +71,7 @@ public static void emitEvents() {
e.commit();
if (i % 10000 == 0) {
try {
Thread.sleep(1);
Thread.sleep(10);
} catch (InterruptedException ie) {
// ignore
}
Expand All @@ -101,6 +92,6 @@ public static void validateRecording() throws Exception {
.stream()
.filter(e -> e.getEventType().getName().equals("Test"))
.count();
Asserts.assertTrue(testEventCount == EXPECTED_COUNT, "Mismatch in TestEvent count");
Asserts.assertEquals(testEventCount, EVENTS, "Mismatch in TestEvent count");
}
}

1 comment on commit 4a478b8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.