author | jbachorik |
Mon, 04 Jan 2016 10:07:08 +0100 | |
changeset 35267 | 8f0a2a0b4d96 |
parent 35263 | 4f66e1eabbe3 |
child 35615 | 4df484cc4761 |
permissions | -rw-r--r-- |
35263
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
1 |
/* |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Red Hat Inc |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
4 |
* |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
8 |
* |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
13 |
* accompanied this code). |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
14 |
* |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
18 |
* |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
21 |
* questions. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
22 |
*/ |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
23 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
24 |
import java.io.File; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
25 |
import java.net.InetAddress; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
26 |
import java.net.UnknownHostException; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
27 |
import java.util.ArrayList; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
28 |
import java.util.List; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
29 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
30 |
import jdk.testlibrary.ProcessThread; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
31 |
import jdk.testlibrary.ProcessTools; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
32 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
33 |
/** |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
34 |
* NOTE: |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
35 |
* This test requires at least a setup similar to the following in |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
36 |
* /etc/hosts file (or the windows equivalent). I.e. it expects it to |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
37 |
* be multi-homed and not both being the loop-back interface. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
38 |
* For example: |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
39 |
* ----->8-------- /etc/hosts ----------->8--- |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
40 |
* 127.0.0.1 localhost |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
41 |
* 192.168.0.1 localhost |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
42 |
* ----->8-------- /etc/hosts ----------->8--- |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
43 |
* |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
44 |
* @test |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
45 |
* @bug 6425769 |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
46 |
* @summary Test JMX agent host address binding. Same ports but different |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
47 |
* interfaces to bind to (using plain sockets and SSL sockets). |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
48 |
* |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
49 |
* @modules java.management/sun.management |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
50 |
* java.management/sun.management.jmxremote |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
51 |
* @library /lib/testlibrary |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
52 |
* @build jdk.testlibrary.* JMXAgentInterfaceBinding |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
53 |
* @run main/timeout=5 JMXInterfaceBindingTest |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
54 |
*/ |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
55 |
public class JMXInterfaceBindingTest { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
56 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
57 |
public static final int COMMUNICATION_ERROR_EXIT_VAL = 1; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
58 |
public static final int STOP_PROCESS_EXIT_VAL = 143; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
59 |
public static final int JMX_PORT = 9111; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
60 |
public static final int RMI_PORT = 9112; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
61 |
public static final String READY_MSG = "MainThread: Ready for connections"; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
62 |
public static final String TEST_CLASS = JMXAgentInterfaceBinding.class.getSimpleName(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
63 |
public static final String KEYSTORE_LOC = System.getProperty("test.src", ".") + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
64 |
File.separator + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
65 |
"ssl" + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
66 |
File.separator + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
67 |
"keystore"; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
68 |
public static final String TRUSTSTORE_LOC = System.getProperty("test.src", ".") + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
69 |
File.separator + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
70 |
"ssl" + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
71 |
File.separator + |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
72 |
"truststore"; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
73 |
public static final String TEST_CLASSPATH = System.getProperty("test.classes", "."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
74 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
75 |
public void run(InetAddress[] addrs) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
76 |
System.out.println("DEBUG: Running tests with plain sockets."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
77 |
runTests(addrs, false); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
78 |
System.out.println("DEBUG: Running tests with SSL sockets."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
79 |
runTests(addrs, true); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
80 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
81 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
82 |
private void runTests(InetAddress[] addrs, boolean useSSL) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
83 |
ProcessThread[] jvms = new ProcessThread[addrs.length]; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
84 |
for (int i = 0; i < addrs.length; i++) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
85 |
System.out.println(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
86 |
String msg = String.format("DEBUG: Launching java tester for triplet (HOSTNAME,JMX_PORT,RMI_PORT) == (%s,%d,%d)", |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
87 |
addrs[i].getHostAddress(), |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
88 |
JMX_PORT, |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
89 |
RMI_PORT); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
90 |
System.out.println(msg); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
91 |
jvms[i] = runJMXBindingTest(addrs[i], useSSL); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
92 |
jvms[i].start(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
93 |
System.out.println("DEBUG: Started " + (i + 1) + " Process(es)."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
94 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
95 |
int failedProcesses = 0; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
96 |
for (ProcessThread pt: jvms) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
97 |
try { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
98 |
pt.stopProcess(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
99 |
pt.join(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
100 |
} catch (InterruptedException e) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
101 |
System.err.println("Failed to stop process: " + pt.getName()); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
102 |
throw new RuntimeException("Test failed", e); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
103 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
104 |
int exitValue = pt.getOutput().getExitValue(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
105 |
// If there is a communication error (the case we care about) |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
106 |
// we get a exit code of 1 |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
107 |
if (exitValue == COMMUNICATION_ERROR_EXIT_VAL) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
108 |
// Failure case since the java processes should still be |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
109 |
// running. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
110 |
System.err.println("Test FAILURE on " + pt.getName()); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
111 |
failedProcesses++; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
112 |
} else if (exitValue == STOP_PROCESS_EXIT_VAL) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
113 |
System.out.println("DEBUG: OK. Spawned java process terminated with expected exit code of " + STOP_PROCESS_EXIT_VAL); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
114 |
} else { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
115 |
System.err.println("Test FAILURE on " + pt.getName() + " reason: Unexpected exit code => " + exitValue); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
116 |
failedProcesses++; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
117 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
118 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
119 |
if (failedProcesses > 0) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
120 |
throw new RuntimeException("Test FAILED. " + failedProcesses + " out of " + addrs.length + " process(es) failed to start the JMX agent."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
121 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
122 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
123 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
124 |
private ProcessThread runJMXBindingTest(InetAddress a, boolean useSSL) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
125 |
List<String> args = new ArrayList<>(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
126 |
args.add("-classpath"); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
127 |
args.add(TEST_CLASSPATH); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
128 |
args.add("-Dcom.sun.management.jmxremote.host=" + a.getHostAddress()); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
129 |
args.add("-Dcom.sun.management.jmxremote.port=" + JMX_PORT); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
130 |
args.add("-Dcom.sun.management.jmxremote.rmi.port=" + RMI_PORT); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
131 |
args.add("-Dcom.sun.management.jmxremote.authenticate=false"); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
132 |
args.add("-Dcom.sun.management.jmxremote.ssl=" + Boolean.toString(useSSL)); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
133 |
if (useSSL) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
134 |
args.add("-Dcom.sun.management.jmxremote.registry.ssl=true"); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
135 |
args.add("-Djavax.net.ssl.keyStore=" + KEYSTORE_LOC); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
136 |
args.add("-Djavax.net.ssl.trustStore=" + TRUSTSTORE_LOC); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
137 |
args.add("-Djavax.net.ssl.keyStorePassword=password"); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
138 |
args.add("-Djavax.net.ssl.trustStorePassword=trustword"); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
139 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
140 |
args.add(TEST_CLASS); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
141 |
args.add(a.getHostAddress()); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
142 |
args.add(Integer.toString(JMX_PORT)); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
143 |
args.add(Integer.toString(RMI_PORT)); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
144 |
args.add(Boolean.toString(useSSL)); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
145 |
try { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
146 |
ProcessBuilder builder = ProcessTools.createJavaProcessBuilder(args.toArray(new String[] {})); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
147 |
System.out.println(ProcessTools.getCommandLine(builder)); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
148 |
ProcessThread jvm = new ProcessThread("JMX-Tester-" + a.getHostAddress(), JMXInterfaceBindingTest::isJMXAgentResponseAvailable, builder); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
149 |
return jvm; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
150 |
} catch (Exception e) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
151 |
throw new RuntimeException("Test failed", e); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
152 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
153 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
154 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
155 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
156 |
private static boolean isJMXAgentResponseAvailable(String line) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
157 |
if (line.equals(READY_MSG)) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
158 |
System.out.println("DEBUG: Found expected READY_MSG."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
159 |
return true; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
160 |
} else if (line.startsWith("Error:")) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
161 |
// Allow for a JVM process that exits with |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
162 |
// "Error: JMX connector server communication error: ..." |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
163 |
// to continue as well since we handle that case elsewhere. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
164 |
// This has the effect that the test does not timeout and |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
165 |
// fails with an exception in the test. |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
166 |
System.err.println("PROBLEM: JMX agent of target JVM did not start as it should."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
167 |
return true; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
168 |
} else { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
169 |
return false; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
170 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
171 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
172 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
173 |
public static void main(String[] args) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
174 |
InetAddress[] addrs = getAddressesForLocalHost(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
175 |
if (addrs.length < 2) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
176 |
System.out.println("Ignoring manual test since no more than one IPs are configured for 'localhost'"); |
35267
8f0a2a0b4d96
8145982: JMXInterfaceBindingTest is failing intermittently
jbachorik
parents:
35263
diff
changeset
|
177 |
return; |
35263
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
178 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
179 |
JMXInterfaceBindingTest test = new JMXInterfaceBindingTest(); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
180 |
test.run(addrs); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
181 |
System.out.println("All tests PASSED."); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
182 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
183 |
|
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
184 |
private static InetAddress[] getAddressesForLocalHost() { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
185 |
InetAddress[] addrs; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
186 |
try { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
187 |
addrs = InetAddress.getAllByName("localhost"); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
188 |
} catch (UnknownHostException e) { |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
189 |
throw new RuntimeException("Test failed", e); |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
190 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
191 |
return addrs; |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
192 |
} |
4f66e1eabbe3
6425769: Allow specifying an address to bind JMX remote connector
sgehwolf
parents:
diff
changeset
|
193 |
} |