Skip to content

Commit

Permalink
8331153: JFR: Improve logging of jdk/jfr/api/consumer/filestream/Test…
Browse files Browse the repository at this point in the history
…Ordered.java

Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Apr 26, 2024
1 parent 07facd0 commit f3bb3e2
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,46 +88,60 @@ public static void main(String... args) throws Exception {

private static void testSetOrderedTrue(Path p) throws Exception {
for (boolean reuse : BOOLEAN_STATES) {
System.out.println();
System.out.println("Testing: testSetOrderedTrue reuse = " + reuse);
AtomicReference<Instant> timestamp = new AtomicReference<>(Instant.MIN);
AtomicBoolean unordered = new AtomicBoolean(false);
try (EventStream es = EventStream.openFile(p)) {
es.setReuse(reuse);
es.setOrdered(true);
es.onEvent(e -> {
Instant endTime = e.getEndTime();
printTimestamp(endTime);
if (endTime.isBefore(timestamp.get())) {
throw new Error("Events are not ordered! Reuse = " + reuse);
unordered.set(true);
}
timestamp.set(endTime);
});
es.start();
}
if (unordered.get()) {
throw new Exception("Events are not ordered! Reuse = " + reuse);
}
}
}

private static void testSetOrderedFalse(Path p) throws Exception {
for (boolean reuse : BOOLEAN_STATES) {
System.out.println();
System.out.println("Testing: testSetOrderedFalse reuse = " + reuse);
AtomicReference<Instant> timestamp = new AtomicReference<>(Instant.MIN);
AtomicBoolean unoreded = new AtomicBoolean(false);
AtomicBoolean unordered = new AtomicBoolean(false);
try (EventStream es = EventStream.openFile(p)) {
es.setReuse(reuse);
es.setOrdered(false);
es.onEvent(e -> {
Instant endTime = e.getEndTime();
System.out.println("testSetOrderedFalse: endTime: " + endTime);
printTimestamp(endTime);
if (endTime.isBefore(timestamp.get())) {
unoreded.set(true);
es.close();
unordered.set(true);
}
timestamp.set(endTime);
});
es.start();
if (!unoreded.get()) {
if (!unordered.get()) {
throw new Exception("Expected at least some events to be out of order! Reuse = " + reuse);
}
}
}
}

private static void printTimestamp(Instant timestamp) {
long seconds = timestamp.getEpochSecond();
long nanos = timestamp.getNano();
System.out.println(timestamp + " seconds = " + seconds + " nanos = " + nanos);
}

private static Path makeUnorderedRecording() throws Exception {
CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1);

Expand Down

5 comments on commit f3bb3e2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on f3bb3e2 Aug 13, 2024

Choose a reason for hiding this comment

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

@sendaoYan the backport was successfully created on the branch backport-sendaoYan-f3bb3e21-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f3bb3e21 from the openjdk/jdk repository.

The commit being backported was authored by Erik Gahlin on 26 Apr 2024 and was reviewed by Markus Grönlund.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-sendaoYan-f3bb3e21-master:backport-sendaoYan-f3bb3e21-master
$ git checkout backport-sendaoYan-f3bb3e21-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-sendaoYan-f3bb3e21-master

@openjdk
Copy link

@openjdk openjdk bot commented on f3bb3e2 Aug 13, 2024

Choose a reason for hiding this comment

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

@sendaoYan Could not automatically backport f3bb3e21 to openjdk/jdk17u-dev due to conflicts in the following files:

  • test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-sendaoYan-f3bb3e21-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git f3bb3e21704dd47c6c5d5753ca5882520a538c06

# Backport the commit
$ git cherry-pick --no-commit f3bb3e21704dd47c6c5d5753ca5882520a538c06
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport f3bb3e21704dd47c6c5d5753ca5882520a538c06'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport f3bb3e21704dd47c6c5d5753ca5882520a538c06.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f3bb3e21 from the openjdk/jdk repository.

The commit being backported was authored by Erik Gahlin on 26 Apr 2024 and was reviewed by Markus Grönlund.

Thanks!

Please sign in to comment.