Skip to content

Commit 87d7340

Browse files
committed
8364756: JFR: Improve slow tests
Reviewed-by: mgronlun
1 parent d023982 commit 87d7340

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

test/jdk/jdk/jfr/api/consumer/streaming/TestFilledChunks.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.Random;
2727

2828
import jdk.jfr.Event;
29+
import jdk.jfr.StackTrace;
2930
import jdk.jfr.consumer.RecordingStream;
3031

3132
/**
@@ -38,6 +39,7 @@
3839
*/
3940
public class TestFilledChunks {
4041

42+
@StackTrace(false)
4143
static class FillEvent extends Event {
4244
String message;
4345
int value;

test/jdk/jdk/jfr/api/consumer/streaming/TestStartMultiChunk.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
*/
4545
public class TestStartMultiChunk {
4646

47-
@Period("10 s")
47+
@Period("2 s")
4848
@Name("Zebra")
4949
static class ZebraEvent extends Event {
5050
}
@@ -65,7 +65,7 @@ public static void main(String... args) throws Exception {
6565
CountDownLatch dogLatch = new CountDownLatch(1);
6666
CountDownLatch catLatch = new CountDownLatch(1);
6767
CountDownLatch mouseLatch = new CountDownLatch(1);
68-
CountDownLatch zebraLatch = new CountDownLatch(3);
68+
CountDownLatch zebraLatch = new CountDownLatch(2);
6969

7070
FlightRecorder.addPeriodicEvent(ZebraEvent.class, () -> {
7171
ZebraEvent ze = new ZebraEvent();

test/jdk/jdk/jfr/event/runtime/StressJavaMonitorEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353
public class StressJavaMonitorEvents {
5454

55-
static final int RUN_TIME_MS = 10000;
55+
static final int RUN_TIME_MS = 5000;
5656
static final int GC_EVERY_MS = 500;
5757
static final int THREADS = 4;
5858
static final int NUM_LOCKS = 1024;

test/jdk/jdk/jfr/jmx/streaming/TestMaxSize.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
3333
import javax.management.MBeanServerConnection;
3434

3535
import jdk.jfr.Event;
36+
import jdk.jfr.StackTrace;
3637
import jdk.management.jfr.RemoteRecordingStream;
3738

3839
/**
@@ -45,6 +46,7 @@
4546
*/
4647
public class TestMaxSize {
4748

49+
@StackTrace(false)
4850
static class Monkey extends Event {
4951
}
5052

@@ -92,7 +94,7 @@ private static void emitEvents(int count) throws InterruptedException {
9294
m.commit();
9395
}
9496
System.out.println("Emitted " + count + " events");
95-
Thread.sleep(1000);
97+
Thread.sleep(100);
9698
}
9799

98100
private static int fileCount(Path dir) throws IOException {

test/jdk/jdk/jfr/jmx/streaming/TestRemoteDump.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static void testClosed() throws Exception {
9797
}
9898
}
9999

100-
private static List<RecordedEvent> recordWithPolicy(String filename, Consumer<RemoteRecordingStream> policy) throws Exception {
100+
private static List<RecordedEvent> recordWithPolicy(String filename, boolean awaitEvents, Consumer<RemoteRecordingStream> policy) throws Exception {
101101
CountDownLatch latch1 = new CountDownLatch(1);
102102
CountDownLatch latch2 = new CountDownLatch(2);
103103
CountDownLatch latch3 = new CountDownLatch(3);
@@ -111,14 +111,18 @@ private static List<RecordedEvent> recordWithPolicy(String filename, Consumer<Re
111111
rs.startAsync();
112112
DumpEvent e1 = new DumpEvent();
113113
e1.commit();
114-
latch1.await();
114+
if (awaitEvents) {
115+
latch1.await();
116+
}
115117
// Force chunk rotation
116118
try (Recording r = new Recording()) {
117119
r.start();
118120
DumpEvent e2 = new DumpEvent();
119121
e2.commit();
120122
}
121-
latch2.await();
123+
if (awaitEvents) {
124+
latch2.await();
125+
}
122126
DumpEvent e3 = new DumpEvent();
123127
e3.commit();
124128
latch3.await();
@@ -129,7 +133,7 @@ private static List<RecordedEvent> recordWithPolicy(String filename, Consumer<Re
129133
}
130134

131135
private static void testSetMaxSize() throws Exception {
132-
var events = recordWithPolicy("max-size.jfr", rs -> {
136+
var events = recordWithPolicy("max-size.jfr", false, rs -> {
133137
// keeps all events for the dump
134138
rs.setMaxSize(100_000_000);
135139
});
@@ -140,7 +144,7 @@ private static void testSetMaxSize() throws Exception {
140144
}
141145

142146
private static void testSetMaxAge() throws Exception {
143-
var events = recordWithPolicy("max-age.jfr", rs -> {
147+
var events = recordWithPolicy("max-age.jfr", false, rs -> {
144148
// keeps all events for the dump
145149
rs.setMaxAge(Duration.ofDays(1));
146150
});
@@ -151,7 +155,7 @@ private static void testSetMaxAge() throws Exception {
151155
}
152156

153157
private static void testSetNoPolicy() throws Exception {
154-
var events = recordWithPolicy("no-policy.jfr", rs -> {
158+
var events = recordWithPolicy("no-policy.jfr", true, rs -> {
155159
// use default policy, remove after consumption
156160
});
157161
// Since latch3 have been triggered at least two events/chunks

test/jdk/jdk/jfr/jvm/TestWaste.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void main(String... args) throws Exception {
6161
try (Recording r = new Recording(c)) {
6262
// Old objects that are cleared out should not create waste
6363
r.enable("jdk.OldObjectSample")
64-
.with("cutoff", "infinity")
64+
.with("cutoff", "2 s")
6565
.withStackTrace();
6666
// No stack trace waste from allocation sample
6767
r.enable("jdk.ObjectAllocationSample")

test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ private static void launchTernary(String options1, String options2, String optio
7474
test(pb, "Started recording 1", "Started recording 2", "Started recording 3");
7575
}
7676

77-
private static void testDefault() throws Exception {
78-
System.out.println("testDefault");
79-
launchUnary(null);
80-
launchBinary(null, null);
81-
launchTernary(null, null, null);
82-
}
83-
8477
private static void testColonDelimited() throws Exception {
8578
launchBinary(":name=myrecording1,filename=myrecording1.jfr", ":filename=myrecording2.jfr,name=myrecording2");
8679
}
@@ -99,7 +92,6 @@ private static void testWithFlightRecorderOptions() throws Exception {
9992
}
10093

10194
public static void main(String[] args) throws Exception {
102-
testDefault();
10395
testColonDelimited();
10496
testMixed();
10597
testWithFlightRecorderOptions();

0 commit comments

Comments
 (0)