8195819: Remove recording=x from jcmd JFR.check output

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2018-05-23 00:21:58 +02:00
parent 6e9b05acb2
commit 6602c862c1
6 changed files with 13 additions and 29 deletions

View File

@ -32,6 +32,7 @@ import java.nio.file.Path;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import jdk.jfr.FlightRecorder;
@ -105,7 +106,7 @@ abstract class AbstractDCmd {
protected final List<Recording> 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;
}

View File

@ -99,8 +99,7 @@ final class DCmdCheck extends AbstractDCmd {
}
private void printGeneral(Recording recording) {
String format = "Recording: recording=%d name=\"%s\"";
print(format, recording.getId(), recording.getName());
print("Recording " + recording.getId() + ": name=" + recording.getName());
Duration duration = recording.getDuration();
if (duration != null) {

View File

@ -125,9 +125,7 @@ final class DCmdStart extends AbstractDCmd {
}
Recording recording = new Recording();
if (name == null) {
recording.setName("Recording-" + recording.getId());
} else {
if (name != null) {
recording.setName(name);
}

View File

@ -102,18 +102,18 @@ public class JcmdAsserts {
public static void assertRecordingIsUnstarted(OutputAnalyzer output,
String name, String duration) {
output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
+ "\"\\s+duration=" + duration + "\\s+.*\\W{1}unstarted\\W{1}");
output.stdoutShouldMatch("^Recording \\d+: name=" + name
+ " duration=" + duration + " .*\\W{1}unstarted\\W{1}");
}
public static void assertRecordingIsStopped(OutputAnalyzer output, String name) {
output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
+ "\"\\s+.*\\W{1}stopped\\W{1}");
output.stdoutShouldMatch("^Recording \\d+: name=" + name
+ " .*\\W{1}stopped\\W{1}");
}
public static void assertRecordingIsStopped(OutputAnalyzer output, String name, String duration) {
output.stdoutShouldMatch("^\\s*Recording: recording=\\d+\\s+name=\"" + name
+ "\"\\s+duration=" + duration + "\\s+.*\\W{1}stopped\\W{1}");
output.stdoutShouldMatch("^Recording \\d+: name=" + name
+ " duration=" + duration + " .*\\W{1}stopped\\W{1}");
}
public static void assertStartTimeGreaterOrEqualThanMBeanValue(String name,

View File

@ -43,9 +43,9 @@ public class JcmdHelper {
OutputAnalyzer output = jcmdCheck(name, false);
try {
// The expected output can look like this:
// Recording: recording=1 name="Recording 1" (running)
output.shouldMatch("^Recording: recording=\\d+\\s+name=\"" + name
+ "\".*\\W{1}running\\W{1}");
// Recording 1: name=1 (running)
output.shouldMatch("^Recording \\d+: name=" + name
+ " .*\\W{1}running\\W{1}");
return;
} catch (RuntimeException e) {
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 {
jcmd("JFR.stop", "name=\"" + name + "\"");
assertRecordingNotRunning(name);

View File

@ -49,7 +49,6 @@ public class TestJcmdStartStopDefault {
JcmdAsserts.assertRecordingHasStarted(output);
String name = parseRecordingName(output);
name= "Recording-" + name;
JcmdHelper.waitUntilRunning(name);
output = JcmdHelper.jcmd("JFR.dump",