8291081: Some sun/tools/jstatd/TestJstatd* tests fail with "Not a percentage\: 68.31\: expected true, was false"
Reviewed-by: kevinw, cjplummer
This commit is contained in:
parent
b47438cabc
commit
36ef4c1a92
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,7 +39,7 @@ import jdk.test.lib.Utils;
|
|||||||
public class JstatGCUtilParser {
|
public class JstatGCUtilParser {
|
||||||
|
|
||||||
public enum GcStatisticsType {
|
public enum GcStatisticsType {
|
||||||
INTEGER, DOUBLE, PERCENTAGE, PERCENTAGE_OR_DASH;
|
INTEGER, DOUBLE, PERCENTAGE, PERCENTAGE_OR_DASH, INTEGER_OR_DASH, DOUBLE_OR_DASH;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GcStatistics {
|
public enum GcStatistics {
|
||||||
@ -49,12 +49,12 @@ public class JstatGCUtilParser {
|
|||||||
O(GcStatisticsType.PERCENTAGE),
|
O(GcStatisticsType.PERCENTAGE),
|
||||||
M(GcStatisticsType.PERCENTAGE_OR_DASH),
|
M(GcStatisticsType.PERCENTAGE_OR_DASH),
|
||||||
CCS(GcStatisticsType.PERCENTAGE_OR_DASH),
|
CCS(GcStatisticsType.PERCENTAGE_OR_DASH),
|
||||||
YGC(GcStatisticsType.INTEGER),
|
YGC(GcStatisticsType.INTEGER_OR_DASH),
|
||||||
YGCT(GcStatisticsType.DOUBLE),
|
YGCT(GcStatisticsType.DOUBLE_OR_DASH),
|
||||||
FGC(GcStatisticsType.INTEGER),
|
FGC(GcStatisticsType.INTEGER_OR_DASH),
|
||||||
FGCT(GcStatisticsType.DOUBLE),
|
FGCT(GcStatisticsType.DOUBLE_OR_DASH),
|
||||||
CGC(GcStatisticsType.INTEGER),
|
CGC(GcStatisticsType.INTEGER_OR_DASH),
|
||||||
CGCT(GcStatisticsType.DOUBLE),
|
CGCT(GcStatisticsType.DOUBLE_OR_DASH),
|
||||||
GCT(GcStatisticsType.DOUBLE);
|
GCT(GcStatisticsType.DOUBLE);
|
||||||
|
|
||||||
private final GcStatisticsType type;
|
private final GcStatisticsType type;
|
||||||
@ -93,21 +93,25 @@ public class JstatGCUtilParser {
|
|||||||
for (int i = 0; i < values().length; i++) {
|
for (int i = 0; i < values().length; i++) {
|
||||||
GcStatisticsType type = values()[i].getType();
|
GcStatisticsType type = values()[i].getType();
|
||||||
String value = valueArray[i].trim();
|
String value = valueArray[i].trim();
|
||||||
if (type.equals(GcStatisticsType.INTEGER)) {
|
if ((type.equals(GcStatisticsType.PERCENTAGE_OR_DASH)
|
||||||
|
|| type.equals(GcStatisticsType.INTEGER_OR_DASH)
|
||||||
|
|| type.equals(GcStatisticsType.DOUBLE_OR_DASH))
|
||||||
|
&& value.equals("-")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (type.equals(GcStatisticsType.INTEGER)
|
||||||
|
|| type.equals(GcStatisticsType.INTEGER_OR_DASH)) {
|
||||||
NumberFormat.getInstance().parse(value).intValue();
|
NumberFormat.getInstance().parse(value).intValue();
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
if (type.equals(GcStatisticsType.DOUBLE)) {
|
if (type.equals(GcStatisticsType.DOUBLE)
|
||||||
|
|| type.equals(GcStatisticsType.DOUBLE_OR_DASH)) {
|
||||||
NumberFormat.getInstance().parse(value).doubleValue();
|
NumberFormat.getInstance().parse(value).doubleValue();
|
||||||
break;
|
continue;
|
||||||
}
|
|
||||||
if (type.equals(GcStatisticsType.PERCENTAGE_OR_DASH) &&
|
|
||||||
value.equals("-")) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
double percentage = NumberFormat.getInstance().parse(value).doubleValue();
|
double percentage = NumberFormat.getInstance().parse(value).doubleValue();
|
||||||
assertTrue(0 <= percentage && percentage <= 100,
|
assertTrue(0 <= percentage && percentage <= 100,
|
||||||
"Not a percentage: " + value);
|
"Not a percentage. value: " + value + " percentage: " + percentage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ import jdk.test.lib.thread.ProcessThread;
|
|||||||
* jps -J-XX:+UsePerfData hostname
|
* jps -J-XX:+UsePerfData hostname
|
||||||
*
|
*
|
||||||
* // run jstat and verify its output
|
* // run jstat and verify its output
|
||||||
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname 250 5
|
* jstat -J-XX:+UsePerfData -gcutil pid@hostname 250 5
|
||||||
*
|
*
|
||||||
* // stop jstatd process and verify that no unexpected exceptions have been thrown
|
* // stop jstatd process and verify that no unexpected exceptions have been thrown
|
||||||
* }
|
* }
|
||||||
@ -172,15 +172,14 @@ public final class JstatdTest {
|
|||||||
/**
|
/**
|
||||||
* Depending on test settings command line can look like:
|
* Depending on test settings command line can look like:
|
||||||
*
|
*
|
||||||
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname 250 5
|
* jstat -J-XX:+UsePerfData -gcutil pid@hostname 250 5
|
||||||
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname:port 250 5
|
* jstat -J-XX:+UsePerfData -gcutil pid@hostname:port 250 5
|
||||||
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname/serverName 250 5
|
* jstat -J-XX:+UsePerfData -gcutil pid@hostname/serverName 250 5
|
||||||
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname:port/serverName 250 5
|
* jstat -J-XX:+UsePerfData -gcutil pid@hostname:port/serverName 250 5
|
||||||
*/
|
*/
|
||||||
private OutputAnalyzer runJstat() throws Exception {
|
private OutputAnalyzer runJstat() throws Exception {
|
||||||
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstat");
|
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstat");
|
||||||
launcher.addVMArg("-XX:+UsePerfData");
|
launcher.addVMArg("-XX:+UsePerfData");
|
||||||
launcher.addVMArg("-Duser.language=en");
|
|
||||||
launcher.addToolArg("-gcutil");
|
launcher.addToolArg("-gcutil");
|
||||||
launcher.addToolArg(jstatdPid + "@" + getDestination());
|
launcher.addToolArg(jstatdPid + "@" + getDestination());
|
||||||
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_INTERVAL_MS));
|
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_INTERVAL_MS));
|
||||||
|
Loading…
Reference in New Issue
Block a user