Jaroslav, Staffan, thanks for the reviews!
Jaroslav, could you please be my sponsor and apply the patch attached to
this mail?
Best regards,
Katja
On 04/04/2014 04:04 PM, Jaroslav Bachorik wrote:
No more comments.
-JB-
# HG changeset patch
# User ykantser
# Date 1396880023 -7200
# Node ID 1f077692bb4352e45684356dc1319ebc2663bcb4
# Parent e04006ff88f4c49603e15faa6dffd5705ce8c9dc
8031766: jstatd nightly tests failing with Expected one jstatd process, got 2. Test will be canceled.
Reviewed-by: jbachorik, sla
diff --git a/test/sun/tools/jstatd/JstatdTest.java b/test/sun/tools/jstatd/JstatdTest.java
--- a/test/sun/tools/jstatd/JstatdTest.java
+++ b/test/sun/tools/jstatd/JstatdTest.java
@@ -27,6 +27,7 @@
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Arrays;
+import java.util.regex.Pattern;
import static jdk.testlibrary.Asserts.*;
import jdk.testlibrary.JDKToolLauncher;
@@ -34,6 +35,7 @@
import jdk.testlibrary.ProcessThread;
import jdk.testlibrary.TestThread;
import jdk.testlibrary.Utils;
+import jdk.testlibrary.ProcessTools;
/**
* The base class for tests of jstatd.
@@ -93,8 +95,11 @@
if (tool == "rmiregistry") {
processName = "registryimpl";
}
+
+ Pattern toolInJpsPattern =
+ Pattern.compile("^\\d+\\s{1}" + processName + "\\s{1}.*-dparent\\.pid\\." + ProcessTools.getProcessId() + ".*");
for (String line : lines) {
- if (line.toLowerCase().matches("^\\d+\\s{1}" + processName + "$")) {
+ if (toolInJpsPattern.matcher(line.toLowerCase()).matches()) {
pid = line.split(" ")[0];
count++;
}
@@ -167,6 +172,8 @@
private OutputAnalyzer runJps() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jps");
launcher.addVMArg("-XX:+UsePerfData");
+ // Run jps with -v flag to obtain -Dparent.pid.<pid>
+ launcher.addToolArg("-v");
launcher.addToolArg(getDestination());
String[] cmd = launcher.getCommand();
@@ -286,7 +293,7 @@
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -n serverName
* jstatd -J-XX:+UsePerfData -J-Djava.security.policy=all.policy -p port -n serverName
*/
- private String[] getJstatdCmd() throws UnknownHostException {
+ private String[] getJstatdCmd() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstatd");
launcher.addVMArg("-XX:+UsePerfData");
String testSrc = System.getProperty("test.src");
@@ -294,6 +301,8 @@
assertTrue(policy.exists() && policy.isFile(),
"Security policy " + policy.getAbsolutePath() + " does not exist or not a file");
launcher.addVMArg("-Djava.security.policy=" + policy.getAbsolutePath());
+ // -Dparent.pid.<pid> will help to identify jstad process started by this test
+ launcher.addVMArg("-Dparent.pid." + ProcessTools.getProcessId());
if (port != null) {
launcher.addToolArg("-p");
launcher.addToolArg(port);