Skip to content

Commit

Permalink
8268297: jdk/jfr/api/consumer/streaming/TestLatestEvent.java times out
Browse files Browse the repository at this point in the history
Backport-of: 730f67081dcda37df7fc40eda99ebd39028be15f
  • Loading branch information
GoeLin committed Sep 19, 2022
1 parent 027be49 commit 3880076
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp
Expand Up @@ -47,6 +47,8 @@ static jlong nanos_now() {
const jlong now = seconds * 1000000000 + nanos;
if (now > last) {
last = now;
} else {
++last;
}
return last;
}
Expand Down
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Expand Up @@ -817,7 +817,6 @@ jdk/jfr/event/compiler/TestCodeSweeper.java 8225209 gener
jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-all
jdk/jfr/startupargs/TestStartName.java 8214685 windows-x64
jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-x64
jdk/jfr/api/consumer/streaming/TestLatestEvent.java 8268297 windows-x64

############################################################################

Expand Down
24 changes: 21 additions & 3 deletions test/jdk/jdk/jfr/api/consumer/streaming/TestLatestEvent.java
Expand Up @@ -23,8 +23,12 @@

package jdk.jfr.api.consumer.streaming;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -34,6 +38,7 @@
import jdk.jfr.Name;
import jdk.jfr.Recording;
import jdk.jfr.consumer.EventStream;
import jdk.jfr.consumer.RecordingFile;
import jdk.jfr.consumer.RecordingStream;

/**
Expand Down Expand Up @@ -65,7 +70,8 @@ public static void main(String... args) throws Exception {
CountDownLatch beginChunks = new CountDownLatch(1);

try (RecordingStream r = new RecordingStream()) {
r.onEvent("MakeChunks", event-> {
r.setMaxSize(1_000_000_000);
r.onEvent("MakeChunks", event -> {
System.out.println(event);
beginChunks.countDown();
});
Expand Down Expand Up @@ -100,13 +106,25 @@ public static void main(String... args) throws Exception {
// This latch ensures thatNotLatest has been
// flushed and a new valid position has been written
// to the chunk header
notLatestEvent.await(80, TimeUnit.SECONDS);
boolean timeout = notLatestEvent.await(80, TimeUnit.SECONDS);
if (notLatestEvent.getCount() != 0) {
System.out.println("timeout = " + timeout);
Path repo = Path.of(System.getProperty("jdk.jfr.repository"));
System.out.println("repo = " + repo);
List<Path> files = new ArrayList<>(Files.list(repo).toList());
files.sort(Comparator.comparing(Path::toString));
for (Path f : files) {
System.out.println("------------");
System.out.println("File: " + f);
for (var event : RecordingFile.readAllEvents(f)) {
System.out.println(event);
}
}
Recording rec = FlightRecorder.getFlightRecorder().takeSnapshot();
Path p = Paths.get("error-not-latest.jfr").toAbsolutePath();
rec.dump(p);
System.out.println("Dumping repository as a file for inspection at " + p);
throw new Exception("Timeout 80 s. Expected 6 event, but got " + notLatestEvent.getCount());
throw new Exception("Timeout 80 s. Expected 6 event, but got " + (6 - notLatestEvent.getCount()));
}

try (EventStream s = EventStream.openRepository()) {
Expand Down

1 comment on commit 3880076

@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.