author | jbachorik |
Mon, 17 Feb 2014 09:43:12 +0100 | |
changeset 22975 | 1a8002758a3d |
parent 22349 | 2aa385c1c4d8 |
child 23004 | 09124a80451a |
permissions | -rw-r--r-- |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
1 |
/* |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
4 |
* |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
8 |
* |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
13 |
* accompanied this code). |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
14 |
* |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
18 |
* |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
21 |
* questions. |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
22 |
*/ |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
23 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
24 |
import java.io.File; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
25 |
import java.io.IOException; |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
26 |
import java.lang.reflect.Method; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
27 |
import java.net.ConnectException; |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
28 |
import java.net.ServerSocket; |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
29 |
import java.rmi.NoSuchObjectException; |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
30 |
import java.rmi.registry.LocateRegistry; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
31 |
import java.rmi.registry.Registry; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
32 |
import java.util.ArrayList; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
33 |
import java.util.Arrays; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
34 |
import java.util.HashMap; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
35 |
import java.util.Iterator; |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
36 |
import java.util.List; |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
37 |
import java.util.Map; |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
38 |
import java.util.Objects; |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
39 |
import java.util.Set; |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
40 |
import java.util.concurrent.TimeUnit; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
41 |
import java.util.concurrent.TimeoutException; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
42 |
import java.util.concurrent.atomic.AtomicBoolean; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
43 |
import java.util.concurrent.atomic.AtomicReference; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
44 |
import java.util.function.Consumer; |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
45 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
46 |
import javax.management.*; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
47 |
import javax.management.remote.*; |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
48 |
import javax.net.ssl.SSLHandshakeException; |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
49 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
50 |
import jdk.testlibrary.ProcessTools; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
51 |
import jdk.testlibrary.JDKToolLauncher; |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
52 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
53 |
/** |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
54 |
* @test |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
55 |
* @bug 7110104 |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
56 |
* @library /lib/testlibrary |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
57 |
* @build jdk.testlibrary.ProcessTools |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
58 |
* @build jdk.testlibrary.JDKToolLauncher |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
59 |
* @build jdk.testlibrary.Utils |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
60 |
* @build JMXStartStopTest JMXStartStopDoSomething |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
61 |
* @run main/othervm JMXStartStopTest |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
62 |
* @summary Makes sure that enabling/disabling the management agent through |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
63 |
* JCMD achieves the desired results |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
64 |
*/ |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
65 |
public class JMXStartStopTest { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
66 |
private static final String TEST_JDK = System.getProperty("test.jdk"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
67 |
private static final String TEST_SRC = System.getProperty("test.src"); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
68 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
69 |
private static final boolean verbose = false; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
70 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
71 |
private static void dbg_print(String msg){ |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
72 |
if (verbose) { |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
73 |
System.out.println("DBG: " +msg); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
74 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
75 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
76 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
77 |
private static int listMBeans(MBeanServerConnection server, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
78 |
ObjectName pattern, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
79 |
QueryExp query) |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
80 |
throws Exception { |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
81 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
82 |
Set names = server.queryNames(pattern,query); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
83 |
for (Iterator i=names.iterator(); i.hasNext(); ) { |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
84 |
ObjectName name = (ObjectName)i.next(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
85 |
MBeanInfo info = server.getMBeanInfo(name); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
86 |
dbg_print("Got MBean: " + name); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
87 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
88 |
MBeanAttributeInfo[] attrs = info.getAttributes(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
89 |
if (attrs == null) |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
90 |
continue; |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
91 |
for (MBeanAttributeInfo attr : attrs) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
92 |
if (attr.isReadable()) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
93 |
Object o = server.getAttribute(name, attr.getName()); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
94 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
95 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
96 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
97 |
return names.size(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
98 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
99 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
100 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
101 |
private static void testConnectLocal(int pid) |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
102 |
throws Exception { |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
103 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
104 |
String jmxUrlStr = null; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
105 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
106 |
try { |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
107 |
jmxUrlStr = sun.management.ConnectorAddressLink.importFrom(pid); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
108 |
dbg_print("Local Service URL: " +jmxUrlStr); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
109 |
if ( jmxUrlStr == null ) { |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
110 |
throw new Exception("No Service URL. Local agent not started?"); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
111 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
112 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
113 |
JMXServiceURL url = new JMXServiceURL(jmxUrlStr); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
114 |
Map m = new HashMap(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
115 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
116 |
JMXConnector c = JMXConnectorFactory.connect(url,m); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
117 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
118 |
MBeanServerConnection conn = c.getMBeanServerConnection(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
119 |
ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
120 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
121 |
int count = listMBeans(conn,pattern,null); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
122 |
if (count == 0) |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
123 |
throw new Exception("Expected at least one matching "+ |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
124 |
"MBean for "+pattern); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
125 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
126 |
} catch (IOException e) { |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
127 |
dbg_print("Cannot find process : " + pid); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
128 |
throw e; |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
129 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
130 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
131 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
132 |
private static void testNoConnect(int port) throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
133 |
testNoConnect(port, 0); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
134 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
135 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
136 |
private static void testNoConnect(int port, int rmiPort) throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
137 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
138 |
testConnect(port, rmiPort); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
139 |
throw new Exception("Didn't expect the management agent running"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
140 |
} catch (Exception e) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
141 |
Throwable t = e; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
142 |
while (t != null) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
143 |
if (t instanceof NoSuchObjectException || |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
144 |
t instanceof ConnectException || |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
145 |
t instanceof SSLHandshakeException) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
146 |
break; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
147 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
148 |
t = t.getCause(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
149 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
150 |
if (t == null) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
151 |
throw new Exception("Unexpected exception", e); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
152 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
153 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
154 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
155 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
156 |
private static void testConnect(int port) throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
157 |
testConnect(port, 0); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
158 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
159 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
160 |
private static void testConnect(int port, int rmiPort) throws Exception { |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
161 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
162 |
dbg_print("RmiRegistry lookup..."); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
163 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
164 |
dbg_print("Using port: " + port); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
165 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
166 |
dbg_print("Using rmi port: " + rmiPort); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
167 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
168 |
Registry registry = LocateRegistry.getRegistry(port); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
169 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
170 |
// "jmxrmi" |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
171 |
String[] relist = registry.list(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
172 |
for (int i = 0; i < relist.length; ++i) { |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
173 |
dbg_print("Got registry: " + relist[i]); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
174 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
175 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
176 |
String jmxUrlStr = (rmiPort != 0) ? |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
177 |
String.format( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
178 |
"service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
179 |
rmiPort, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
180 |
port) : |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
181 |
String.format( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
182 |
"service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
183 |
port); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
184 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
185 |
JMXServiceURL url = new JMXServiceURL(jmxUrlStr); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
186 |
Map m = new HashMap(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
187 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
188 |
JMXConnector c = JMXConnectorFactory.connect(url,m); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
189 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
190 |
MBeanServerConnection conn = c.getMBeanServerConnection(); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
191 |
ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
192 |
|
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
193 |
int count = listMBeans(conn,pattern,null); |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
194 |
if (count == 0) |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
195 |
throw new Exception("Expected at least one matching " + |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
196 |
"MBean for " + pattern); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
197 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
198 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
199 |
private static class Failure { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
200 |
private final Throwable cause; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
201 |
private final String msg; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
202 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
203 |
public Failure(Throwable cause, String msg) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
204 |
this.cause = cause; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
205 |
this.msg = msg; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
206 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
207 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
208 |
public Failure(String msg) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
209 |
this(null, msg); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
210 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
211 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
212 |
public Throwable getCause() { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
213 |
return cause; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
214 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
215 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
216 |
public String getMsg() { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
217 |
return msg; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
218 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
219 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
220 |
@Override |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
221 |
public int hashCode() { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
222 |
int hash = 7; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
223 |
hash = 97 * hash + Objects.hashCode(this.cause); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
224 |
hash = 97 * hash + Objects.hashCode(this.msg); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
225 |
return hash; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
226 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
227 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
228 |
@Override |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
229 |
public boolean equals(Object obj) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
230 |
if (obj == null) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
231 |
return false; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
232 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
233 |
if (getClass() != obj.getClass()) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
234 |
return false; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
235 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
236 |
final Failure other = (Failure) obj; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
237 |
if (!Objects.equals(this.cause, other.cause)) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
238 |
return false; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
239 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
240 |
if (!Objects.equals(this.msg, other.msg)) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
241 |
return false; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
242 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
243 |
return true; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
244 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
245 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
246 |
@Override |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
247 |
public String toString() { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
248 |
if (cause != null) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
249 |
return msg + "\n" + cause; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
250 |
} else { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
251 |
return msg; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
252 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
253 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
254 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
255 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
256 |
private static List<Failure> failures = new ArrayList<>(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
257 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
258 |
public static void main(String args[]) throws Exception { |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
259 |
for (Method m : JMXStartStopTest.class.getDeclaredMethods()) { |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
260 |
if (m.getName().startsWith("test_")) { |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
261 |
try { |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
262 |
m.invoke(null); |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
263 |
System.out.println("=== PASSED\n"); |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
264 |
} catch (Throwable e) { |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
265 |
failures.add(new Failure(e, m.getName() + " failed")); |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
266 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
267 |
} |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
268 |
} |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
269 |
|
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
270 |
if (!failures.isEmpty()) { |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
271 |
for(Failure f : failures) { |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
272 |
System.err.println(f.getMsg()); |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
273 |
f.getCause().printStackTrace(System.err); |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
274 |
} |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
275 |
throw new Error(); |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
276 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
277 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
278 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
279 |
/** |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
280 |
* Retrieves the PID of the test application using JCMD |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
281 |
* @return The PID of the test application |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
282 |
* @throws InterruptedException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
283 |
* @throws IOException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
284 |
*/ |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
285 |
private static String getPID() throws InterruptedException, IOException { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
286 |
final AtomicReference<String> pid = new AtomicReference<>(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
287 |
jcmd( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
288 |
null, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
289 |
line -> { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
290 |
if (line.endsWith("JMXStartStopDoSomething")) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
291 |
pid.set(line.split(" ")[0]); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
292 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
293 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
294 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
295 |
return pid.get(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
296 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
297 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
298 |
private static class Something { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
299 |
private Process p; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
300 |
private final ProcessBuilder pb; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
301 |
private final String name; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
302 |
private final AtomicBoolean started = new AtomicBoolean(false); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
303 |
private volatile int pid = -1; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
304 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
305 |
public Something(ProcessBuilder pb, String name) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
306 |
this.pb = pb; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
307 |
this.name = name; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
308 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
309 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
310 |
public synchronized void start() throws InterruptedException, IOException, TimeoutException { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
311 |
if (started.compareAndSet(false, true)) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
312 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
313 |
p = ProcessTools.startProcess( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
314 |
"JMXStartStopDoSomething", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
315 |
pb, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
316 |
(line) -> { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
317 |
if (line.toLowerCase().startsWith("pid:")) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
318 |
pid = Integer.parseInt(line.split("\\:")[1]); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
319 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
320 |
return line.equals("main enter"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
321 |
}, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
322 |
5, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
323 |
TimeUnit.SECONDS |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
324 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
325 |
} catch (TimeoutException e) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
326 |
p.destroy(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
327 |
p.waitFor(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
328 |
throw e; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
329 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
330 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
331 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
332 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
333 |
public int getPid() { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
334 |
return pid; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
335 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
336 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
337 |
public synchronized void stop() |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
338 |
throws IOException, InterruptedException { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
339 |
if (started.compareAndSet(true, false)) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
340 |
p.getOutputStream().write(0); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
341 |
p.getOutputStream().flush(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
342 |
int ec = p.waitFor(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
343 |
if (ec != 0) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
344 |
StringBuilder msg = new StringBuilder(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
345 |
msg.append("Test application '").append(name); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
346 |
msg.append("' failed with exit code: "); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
347 |
msg.append(ec); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
348 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
349 |
failures.add(new Failure(msg.toString())); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
350 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
351 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
352 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
353 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
354 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
355 |
/** |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
356 |
* Runs the test application "JMXStartStopDoSomething" |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
357 |
* @param name Test run name |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
358 |
* @param args Additional arguments |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
359 |
* @return Returns a {@linkplain Something} instance representing the run |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
360 |
* @throws IOException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
361 |
* @throws InterruptedException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
362 |
* @throws TimeoutException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
363 |
*/ |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
364 |
private static Something doSomething(String name, String ... args) |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
365 |
throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
366 |
List<String> pbArgs = new ArrayList<>(Arrays.asList( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
367 |
"-cp", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
368 |
System.getProperty("test.class.path") |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
369 |
)); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
370 |
pbArgs.addAll(Arrays.asList(args)); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
371 |
pbArgs.add("JMXStartStopDoSomething"); |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
372 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
373 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
374 |
pbArgs.toArray(new String[pbArgs.size()]) |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
375 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
376 |
Something s = new Something(pb, name); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
377 |
s.start(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
378 |
return s; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
379 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
380 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
381 |
/** |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
382 |
* Run the "jcmd" command |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
383 |
* |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
384 |
* @param command Command with parameters; space separated string |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
385 |
* @throws IOException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
386 |
* @throws InterruptedException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
387 |
*/ |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
388 |
private static void jcmd(String ... command) throws IOException, InterruptedException { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
389 |
if (command.length == 0) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
390 |
jcmd(null, (Consumer<String>)null); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
391 |
} else { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
392 |
jcmd(null, command); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
393 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
394 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
395 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
396 |
/** |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
397 |
* Run the "jcmd" command |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
398 |
* |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
399 |
* @param c {@linkplain Consumer} instance; may be null |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
400 |
* @param command Command with parameters; space separated string |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
401 |
* @throws IOException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
402 |
* @throws InterruptedException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
403 |
*/ |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
404 |
private static void jcmd(Consumer<String> c, String ... command) throws IOException, InterruptedException { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
405 |
jcmd("JMXStartStopDoSomething", c, command); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
406 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
407 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
408 |
/** |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
409 |
* Run the "jcmd" command |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
410 |
* @param target The target application name (or PID) |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
411 |
* @param c {@linkplain Consumer} instance; may be null |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
412 |
* @param command Command with parameters; space separated string |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
413 |
* @throws IOException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
414 |
* @throws InterruptedException |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
415 |
*/ |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
416 |
private static void jcmd(String target, final Consumer<String> c, String ... command) throws IOException, InterruptedException { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
417 |
dbg_print("[jcmd] " + (command.length > 0 ? command[0] : "list")); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
418 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
419 |
JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK("jcmd"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
420 |
l.addToolArg(target); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
421 |
for(String cmd : command) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
422 |
l.addToolArg(cmd); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
423 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
424 |
Process p = ProcessTools.startProcess( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
425 |
"jcmd", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
426 |
new ProcessBuilder(l.getCommand()), |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
427 |
c |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
428 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
429 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
430 |
p.waitFor(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
431 |
dbg_print("[jcmd] --------"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
432 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
433 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
434 |
private static final String CMD_STOP = "ManagementAgent.stop"; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
435 |
private static final String CMD_START= "ManagementAgent.start"; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
436 |
private static final String CMD_START_LOCAL = "ManagementAgent.start_local"; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
437 |
private static final int port1 = 50234; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
438 |
private static final int port2 = 50235; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
439 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
440 |
private static void test_01() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
441 |
// Run an app with JMX enabled stop it and |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
442 |
// restart on other port |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
443 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
444 |
System.out.println("**** Test one ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
445 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
446 |
Something s = doSomething( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
447 |
"test_01", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
448 |
"-Dcom.sun.management.jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
449 |
"-Dcom.sun.management.jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
450 |
"-Dcom.sun.management.jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
451 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
452 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
453 |
testConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
454 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
455 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
456 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
457 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
458 |
jcmd(CMD_START, "jmxremote.port=" + port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
459 |
testConnect(port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
460 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
461 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
462 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
463 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
464 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
465 |
private static void test_02() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
466 |
// Run an app without JMX enabled |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
467 |
// start JMX by jcmd |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
468 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
469 |
System.out.println("**** Test two ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
470 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
471 |
Something s = doSomething("test_02"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
472 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
473 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
474 |
"jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
475 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
476 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
477 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
478 |
testConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
479 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
480 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
481 |
} |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
482 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
483 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
484 |
private static void test_03() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
485 |
// Run an app without JMX enabled |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
486 |
// start JMX by jcmd on one port than on other one |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
487 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
488 |
System.out.println("**** Test three ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
489 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
490 |
Something s = doSomething("test_03"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
491 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
492 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
493 |
"jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
494 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
495 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
496 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
497 |
// Second agent shouldn't start |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
498 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
499 |
"jmxremote.port=" + port2, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
500 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
501 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
502 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
503 |
// First agent should connect |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
504 |
testConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
505 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
506 |
// Second agent should not connect |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
507 |
testNoConnect(port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
508 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
509 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
510 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
511 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
512 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
513 |
private static void test_04() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
514 |
// Run an app without JMX enabled |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
515 |
// start JMX by jcmd on one port, specify rmi port explicitly |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
516 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
517 |
System.out.println("**** Test four ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
518 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
519 |
Something s = doSomething("test_04"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
520 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
521 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
522 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
523 |
"jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
524 |
"jmxremote.rmi.port=" + port2, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
525 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
526 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
527 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
528 |
testConnect(port1, port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
529 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
530 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
531 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
532 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
533 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
534 |
private static void test_05() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
535 |
// Run an app without JMX enabled, it will enable local server |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
536 |
// but should leave remote server disabled |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
537 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
538 |
System.out.println("**** Test five ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
539 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
540 |
Something s = doSomething("test_05"); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
541 |
try { |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
542 |
jcmd(CMD_START_LOCAL); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
543 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
544 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
545 |
testConnectLocal(s.getPid()); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
546 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
547 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
548 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
549 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
550 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
551 |
private static void test_06() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
552 |
// Run an app without JMX enabled |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
553 |
// start JMX by jcmd on one port, specify rmi port explicitly |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
554 |
// attempt to start it again |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
555 |
// 1) with the same port |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
556 |
// 2) with other port |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
557 |
// 3) attempt to stop it twice |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
558 |
// Check for valid messages in the output |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
559 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
560 |
System.out.println("**** Test six ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
561 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
562 |
Something s = doSomething("test_06"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
563 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
564 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
565 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
566 |
"jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
567 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
568 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
569 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
570 |
testConnect(port1, port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
571 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
572 |
final boolean[] checks = new boolean[3]; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
573 |
jcmd( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
574 |
line -> { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
575 |
if (line.equals("java.lang.RuntimeException: Invalid agent state")) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
576 |
checks[0] = true; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
577 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
578 |
}, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
579 |
CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
580 |
"jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
581 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
582 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
583 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
584 |
jcmd( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
585 |
line -> { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
586 |
if (line.equals("java.lang.RuntimeException: Invalid agent state")) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
587 |
checks[1] = true; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
588 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
589 |
}, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
590 |
CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
591 |
"jmxremote.port=" + port2, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
592 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
593 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
594 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
595 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
596 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
597 |
|
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
598 |
ServerSocket ss = new ServerSocket(0); |
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
599 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
600 |
jcmd( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
601 |
line -> { |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
602 |
if (line.contains("Port already in use: " + ss.getLocalPort())) { |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
603 |
checks[2] = true; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
604 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
605 |
}, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
606 |
CMD_START, |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
607 |
"jmxremote.port=" + ss.getLocalPort(), |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
608 |
"jmxremote.rmi.port=" + port2, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
609 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
610 |
"jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
611 |
if (!checks[0]) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
612 |
throw new Exception("Starting agent on port " + port1 + " should " + |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
613 |
"report an invalid agent state"); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
614 |
} |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
615 |
if (!checks[1]) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
616 |
throw new Exception("Starting agent on poprt " + port2 + " should " + |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
617 |
"report an invalid agent state"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
618 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
619 |
if (!checks[2]) { |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
620 |
throw new Exception("Starting agent on port " + ss.getLocalPort() + " should " + |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
621 |
"report port in use"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
622 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
623 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
624 |
s.stop(); |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
625 |
} |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
626 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
627 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
628 |
private static void test_07() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
629 |
// Run an app without JMX enabled, but with some properties set |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
630 |
// in command line. |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
631 |
// make sure these properties overridden corectly |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
632 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
633 |
System.out.println("**** Test seven ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
634 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
635 |
Something s = doSomething( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
636 |
"test_07", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
637 |
"-Dcom.sun.management.jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
638 |
"-Dcom.sun.management.jmxremote.ssl=true"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
639 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
640 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
641 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
642 |
jcmd( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
643 |
CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
644 |
"jmxremote.port=" + port2, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
645 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
646 |
"jmxremote.ssl=false" |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
647 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
648 |
testConnect(port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
649 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
650 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
651 |
} |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
652 |
} |
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
653 |
|
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
654 |
private static void test_08() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
655 |
// Run an app with JMX enabled and with some properties set |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
656 |
// in command line. |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
657 |
// stop JMX agent and then start it again with different property values |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
658 |
// make sure these properties overridden corectly |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
659 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
660 |
System.out.println("**** Test eight ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
661 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
662 |
Something s = doSomething( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
663 |
"test_08", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
664 |
"-Dcom.sun.management.jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
665 |
"-Dcom.sun.management.jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
666 |
"-Dcom.sun.management.jmxremote.ssl=true"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
667 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
668 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
669 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
670 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
671 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
672 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
673 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
674 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
675 |
jcmd( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
676 |
CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
677 |
"jmxremote.port=" + port2, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
678 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
679 |
"jmxremote.ssl=false" |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
680 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
681 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
682 |
testConnect(port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
683 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
684 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
685 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
686 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
687 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
688 |
private static void test_09() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
689 |
// Run an app with JMX enabled and with some properties set |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
690 |
// in command line. |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
691 |
// stop JMX agent and then start it again with different property values |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
692 |
// specifing some property in management config file and some of them |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
693 |
// in command line |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
694 |
// make sure these properties overridden corectly |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
695 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
696 |
System.out.println("**** Test nine ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
697 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
698 |
Something s = doSomething("test_09", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
699 |
"-Dcom.sun.management.config.file=" + |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
700 |
TEST_SRC + File.separator + "management_cl.properties", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
701 |
"-Dcom.sun.management.jmxremote.authenticate=false" |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
702 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
703 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
704 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
705 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
706 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
707 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
708 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
709 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
710 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
711 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
712 |
"config.file=" + TEST_SRC + File.separator + |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
713 |
"management_jcmd.properties", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
714 |
"jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
715 |
"jmxremote.port=" + port2 |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
716 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
717 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
718 |
testConnect(port2); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
719 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
720 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
721 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
722 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
723 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
724 |
private static void test_10() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
725 |
// Run an app with JMX enabled and with some properties set |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
726 |
// in command line. |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
727 |
// stop JMX agent and then start it again with different property values |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
728 |
// stop JMX agent again and then start it without property value |
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
729 |
// make sure these properties overridden corectly |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
730 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
731 |
System.out.println("**** Test ten ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
732 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
733 |
Something s = doSomething( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
734 |
"test_10", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
735 |
"-Dcom.sun.management.jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
736 |
"-Dcom.sun.management.jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
737 |
"-Dcom.sun.management.jmxremote.ssl=true"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
738 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
739 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
740 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
741 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
742 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
743 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
744 |
"jmxremote.ssl=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
745 |
"jmxremote.port=" + port1 |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
746 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
747 |
testConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
748 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
749 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
750 |
jcmd(CMD_START, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
751 |
"jmxremote.port=" + port1 |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
752 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
753 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
754 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
755 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
756 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
757 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
758 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
759 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
760 |
private static void test_11() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
761 |
// Run an app with JMX enabled |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
762 |
// stop remote agent |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
763 |
// make sure local agent is not affected |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
764 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
765 |
System.out.println("**** Test eleven ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
766 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
767 |
Something s = doSomething( |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
768 |
"test_11", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
769 |
"-Dcom.sun.management.jmxremote.port=" + port1, |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
770 |
"-Dcom.sun.management.jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
771 |
"-Dcom.sun.management.jmxremote.ssl=false"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
772 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
773 |
testConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
774 |
jcmd(CMD_STOP); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
775 |
testConnectLocal(s.getPid()); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
776 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
777 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
778 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
779 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
780 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
781 |
private static void test_12() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
782 |
// Run an app with JMX disabled |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
783 |
// start local agent only |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
784 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
785 |
System.out.println("**** Test twelve ****"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
786 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
787 |
Something s = doSomething("test_12"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
788 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
789 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
790 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
791 |
jcmd(CMD_START + "_local"); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
792 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
793 |
testConnectLocal(s.getPid()); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
794 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
795 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
796 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
797 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
798 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
799 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
800 |
private static void test_13() throws Exception { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
801 |
// Run an app with -javaagent make sure it works as expected - |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
802 |
// system properties are ignored |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
803 |
|
22975
1a8002758a3d
8034177: sun/management/jmxremote/startstop/JMXStartStopTest.java should report port in use
jbachorik
parents:
22349
diff
changeset
|
804 |
System.out.println("**** Test thirteen ****"); |
22349
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
805 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
806 |
String agent = TEST_JDK + "/jre/lib/management-agent.jar"; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
807 |
if (!new File(agent).exists()) { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
808 |
agent = TEST_JDK + "/lib/management-agent.jar"; |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
809 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
810 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
811 |
Something s = doSomething("test_14", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
812 |
"-javaagent:" + agent + "=com.sun.management.jmxremote.port=" + |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
813 |
port1 + ",com.sun.management.jmxremote.authenticate=false", |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
814 |
"-Dcom.sun.management.jmxremote.ssl=false" |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
815 |
); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
816 |
|
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
817 |
try { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
818 |
testNoConnect(port1); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
819 |
} finally { |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
820 |
s.stop(); |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
821 |
} |
2aa385c1c4d8
8022221: Intermittent test failures in sun/management/jmxremote/startstop/JMXStartStopTest.sh
jbachorik
parents:
14013
diff
changeset
|
822 |
} |
11991
800d0ff7b043
7110104: It should be possible to stop and start JMX Agent at runtime
dsamersoff
parents:
diff
changeset
|
823 |
} |