8195819: Remove recording=x from jcmd JFR.check output
Reviewed-by: mgronlun
This commit is contained in:
parent
6e9b05acb2
commit
6602c862c1
@ -32,6 +32,7 @@ import java.nio.file.Path;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jdk.jfr.FlightRecorder;
|
import jdk.jfr.FlightRecorder;
|
||||||
@ -105,7 +106,7 @@ abstract class AbstractDCmd {
|
|||||||
|
|
||||||
protected final List<Recording> getRecordings() {
|
protected final List<Recording> getRecordings() {
|
||||||
List<Recording> list = new ArrayList<>(getFlightRecorder().getRecordings());
|
List<Recording> list = new ArrayList<>(getFlightRecorder().getRecordings());
|
||||||
Collections.sort(list, (a, b) -> a.getName().compareTo(b.getName()));
|
Collections.sort(list, Comparator.comparing(Recording::getId));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +99,7 @@ final class DCmdCheck extends AbstractDCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void printGeneral(Recording recording) {
|
private void printGeneral(Recording recording) {
|
||||||
String format = "Recording: recording=%d name=\"%s\"";
|
print("Recording " + recording.getId() + ": name=" + recording.getName());
|
||||||
print(format, recording.getId(), recording.getName());
|
|
||||||
|
|
||||||
Duration duration = recording.getDuration();
|
Duration duration = recording.getDuration();
|
||||||
if (duration != null) {
|
if (duration != null) {
|
||||||
|
@ -125,9 +125,7 @@ final class DCmdStart extends AbstractDCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Recording recording = new Recording();
|
Recording recording = new Recording();
|
||||||
if (name == null) {
|
if (name != null) {
|
||||||
recording.setName("Recording-" + recording.getId());
|
|
||||||
} else {
|
|
||||||
recording.setName(name);
|
recording.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,18 +102,18 @@ public class JcmdAsserts {
|
|||||||
|
|
||||||
public static void assertRecordingIsUnstarted(OutputAnalyzer output,
|
public static void assertRecordingIsUnstarted(OutputAnalyzer output,
|
||||||
String name, String duration) {
|
String name, String duration) {
|
||||||
output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
|
output.stdoutShouldMatch("^Recording \\d+: name=" + name
|
||||||
+ "\"\\s+duration=" + duration + "\\s+.*\\W{1}unstarted\\W{1}");
|
+ " duration=" + duration + " .*\\W{1}unstarted\\W{1}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertRecordingIsStopped(OutputAnalyzer output, String name) {
|
public static void assertRecordingIsStopped(OutputAnalyzer output, String name) {
|
||||||
output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
|
output.stdoutShouldMatch("^Recording \\d+: name=" + name
|
||||||
+ "\"\\s+.*\\W{1}stopped\\W{1}");
|
+ " .*\\W{1}stopped\\W{1}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertRecordingIsStopped(OutputAnalyzer output, String name, String duration) {
|
public static void assertRecordingIsStopped(OutputAnalyzer output, String name, String duration) {
|
||||||
output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
|
output.stdoutShouldMatch("^Recording \\d+: name=" + name
|
||||||
+ "\"\\s+duration=" + duration + "\\s+.*\\W{1}stopped\\W{1}");
|
+ " duration=" + duration + " .*\\W{1}stopped\\W{1}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertStartTimeGreaterOrEqualThanMBeanValue(String name,
|
public static void assertStartTimeGreaterOrEqualThanMBeanValue(String name,
|
||||||
|
@ -43,9 +43,9 @@ public class JcmdHelper {
|
|||||||
OutputAnalyzer output = jcmdCheck(name, false);
|
OutputAnalyzer output = jcmdCheck(name, false);
|
||||||
try {
|
try {
|
||||||
// The expected output can look like this:
|
// The expected output can look like this:
|
||||||
// Recording: recording=1 name="Recording 1" (running)
|
// Recording 1: name=1 (running)
|
||||||
output.shouldMatch("^Recording: recording=\\d+\\s+name=\"" + name
|
output.shouldMatch("^Recording \\d+: name=" + name
|
||||||
+ "\".*\\W{1}running\\W{1}");
|
+ " .*\\W{1}running\\W{1}");
|
||||||
return;
|
return;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
if (System.currentTimeMillis() > timeoutAt) {
|
if (System.currentTimeMillis() > timeoutAt) {
|
||||||
@ -56,19 +56,6 @@ public class JcmdHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait until default recording's state became running
|
|
||||||
public static void waitUntilDefaultRecordingRunning() throws Exception {
|
|
||||||
while (true) {
|
|
||||||
OutputAnalyzer output = jcmd("JFR.check", "recording=0");
|
|
||||||
try {
|
|
||||||
output.shouldContain("Recording: recording=0 name=\"HotSpot default\" (running)");
|
|
||||||
return;
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
Thread.sleep(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void stopAndCheck(String name) throws Exception {
|
public static void stopAndCheck(String name) throws Exception {
|
||||||
jcmd("JFR.stop", "name=\"" + name + "\"");
|
jcmd("JFR.stop", "name=\"" + name + "\"");
|
||||||
assertRecordingNotRunning(name);
|
assertRecordingNotRunning(name);
|
||||||
|
@ -49,7 +49,6 @@ public class TestJcmdStartStopDefault {
|
|||||||
JcmdAsserts.assertRecordingHasStarted(output);
|
JcmdAsserts.assertRecordingHasStarted(output);
|
||||||
|
|
||||||
String name = parseRecordingName(output);
|
String name = parseRecordingName(output);
|
||||||
name= "Recording-" + name;
|
|
||||||
JcmdHelper.waitUntilRunning(name);
|
JcmdHelper.waitUntilRunning(name);
|
||||||
|
|
||||||
output = JcmdHelper.jcmd("JFR.dump",
|
output = JcmdHelper.jcmd("JFR.dump",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user