jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
author alanb
Thu, 17 Mar 2016 19:04:16 +0000
changeset 36511 9d0388c6b336
parent 31455 412ba247f8df
child 40261 86a49ba76f52
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: alanb, mchung, naoto, rriggs, psandoz, plevart, mullan, ascarpino, vinnie, prr, sherman, dfuchs, mhaupt Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, chris.hegarty@oracle.com, alexandr.scherbatiy@oracle.com, amy.lu@oracle.com, calvin.cheung@oracle.com, daniel.fuchs@oracle.com, erik.joelsson@oracle.com, harold.seigel@oracle.com, jaroslav.bachorik@oracle.com, jean-francois.denise@oracle.com, jan.lahoda@oracle.com, james.laskey@oracle.com, lois.foltan@oracle.com, miroslav.kos@oracle.com, huaming.li@oracle.com, sean.mullan@oracle.com, naoto.sato@oracle.com, masayoshi.okutsu@oracle.com, peter.levart@gmail.com, philip.race@oracle.com, claes.redestad@oracle.com, sergey.bylokhov@oracle.com, alexandre.iline@oracle.com, volker.simonis@gmail.com, staffan.larsen@oracle.com, stuart.marks@oracle.com, semyon.sadetsky@oracle.com, serguei.spitsyn@oracle.com, sundararajan.athijegannathan@oracle.com, valerie.peng@oracle.com, vincent.x.ryan@oracle.com, weijun.wang@oracle.com, yuri.nesterenko@oracle.com, yekaterina.kantserova@oracle.com, alexander.kulyakhtin@oracle.com, felix.yang@oracle.com, andrei.eremeev@oracle.com, frank.yuan@oracle.com, sergei.pikalev@oracle.com, sibabrata.sahoo@oracle.com, tiantian.du@oracle.com, sha.jiang@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     1
/*
30359
b2b7b66cd9eb 8077402: JMXStartStopTest fails intermittently on slow hosts
jbachorik
parents: 28760
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     4
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     7
 * published by the Free Software Foundation.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     8
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    13
 * accompanied this code).
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    14
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    18
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    21
 * questions.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    22
 */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    23
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    24
import java.lang.reflect.Method;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    25
import java.lang.reflect.Modifier;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    26
import java.util.ArrayList;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    27
import java.util.List;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    28
import java.util.concurrent.atomic.AtomicReference;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    29
31455
412ba247f8df 8085973: The targeted processes in javax/management tests should be launched with -XX:+UsePerfData flag in order to work on embedded platforms
ykantser
parents: 30376
diff changeset
    30
import jdk.testlibrary.ProcessTools;
412ba247f8df 8085973: The targeted processes in javax/management tests should be launched with -XX:+UsePerfData flag in order to work on embedded platforms
ykantser
parents: 30376
diff changeset
    31
import jdk.testlibrary.Utils;
412ba247f8df 8085973: The targeted processes in javax/management tests should be launched with -XX:+UsePerfData flag in order to work on embedded platforms
ykantser
parents: 30376
diff changeset
    32
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    33
/**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    34
 * @test
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
    35
 * @library /lib/testlibrary
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    36
 * @bug 5016507 6173612 6319776 6342019 6484550 8004926
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    37
 * @summary Start a managed VM and test that a management tool can connect
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    38
 *          without connection or username/password details.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    39
 *          TestManager will attempt a connection to the address obtained from
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    40
 *          both agent properties and jvmstat buffer.
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 30359
diff changeset
    41
 * @modules java.management/sun.management
24509
5d02a6d25f78 8043520: Serviceability tests using @library failing with java.lang.NoClassDefFoundError
ykantser
parents: 23031
diff changeset
    42
 * @build jdk.testlibrary.* TestManager TestApplication
31455
412ba247f8df 8085973: The targeted processes in javax/management tests should be launched with -XX:+UsePerfData flag in order to work on embedded platforms
ykantser
parents: 30376
diff changeset
    43
 * @run main/othervm/timeout=300 LocalManagementTest
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    44
 */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    45
public class LocalManagementTest {
23031
995cf5c2eb55 7195249: Some jtreg tests use hard coded ports
sla
parents: 23002
diff changeset
    46
    private static final String TEST_CLASSPATH = System.getProperty("test.class.path");
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    47
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    48
    public static void main(String[] args) throws Exception {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    49
        int failures = 0;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    50
        for(Method m : LocalManagementTest.class.getDeclaredMethods()) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    51
            if (Modifier.isStatic(m.getModifiers()) &&
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    52
                m.getName().startsWith("test")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    53
                m.setAccessible(true);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    54
                try {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    55
                    System.out.println(m.getName());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    56
                    System.out.println("==========");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    57
                    Boolean rslt = (Boolean)m.invoke(null);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    58
                    if (!rslt) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    59
                        System.err.println(m.getName() + " failed");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    60
                        failures++;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    61
                    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    62
                } catch (Exception e) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    63
                    e.printStackTrace();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    64
                    failures++;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    65
                }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    66
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    67
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    68
        if (failures > 0) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    69
            throw new Error("Test failed");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    70
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    71
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    72
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
    73
    @SuppressWarnings("unused")
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    74
    private static boolean test1() throws Exception {
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
    75
        return doTest("1", "-Dcom.sun.management.jmxremote");
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    76
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    77
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    78
    /**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    79
     * no args (blank) - manager should attach and start agent
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    80
     */
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
    81
    @SuppressWarnings("unused")
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    82
    private static boolean test3() throws Exception {
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
    83
        return doTest("3", null);
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    84
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    85
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    86
    /**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    87
     * use DNS-only name service
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    88
     */
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
    89
    @SuppressWarnings("unused")
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    90
    private static boolean test5() throws Exception {
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
    91
        return doTest("5", "-Dsun.net.spi.namservice.provider.1=\"dns,sun\"");
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    92
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    93
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
    94
    private static boolean doTest(String testId, String arg) throws Exception {
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    95
        List<String> args = new ArrayList<>();
31455
412ba247f8df 8085973: The targeted processes in javax/management tests should be launched with -XX:+UsePerfData flag in order to work on embedded platforms
ykantser
parents: 30376
diff changeset
    96
        args.add("-XX:+UsePerfData");
412ba247f8df 8085973: The targeted processes in javax/management tests should be launched with -XX:+UsePerfData flag in order to work on embedded platforms
ykantser
parents: 30376
diff changeset
    97
        args.addAll(Utils.getVmOptions());
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
    98
        args.add("-cp");
21822
12f13ba496cd 8028141: test/sun/management/jmxremote/bootstrap/LocalManagementTest|CustomLauncherTest.java failing again
rriggs
parents: 21802
diff changeset
    99
        args.add(TEST_CLASSPATH);
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
   100
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   101
        if (arg != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   102
            args.add(arg);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   103
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   104
        args.add("TestApplication");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   105
        ProcessBuilder server = ProcessTools.createJavaProcessBuilder(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   106
            args.toArray(new String[args.size()])
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   107
        );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   108
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   109
        Process serverPrc = null, clientPrc = null;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   110
        try {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   111
            final AtomicReference<String> port = new AtomicReference<>();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   112
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   113
            serverPrc = ProcessTools.startProcess(
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
   114
                "TestApplication(" + testId + ")",
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   115
                server,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   116
                (String line) -> {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   117
                    if (line.startsWith("port:")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   118
                         port.set(line.split("\\:")[1]);
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   119
                    } else if (line.startsWith("waiting")) {
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   120
                        return true;
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   121
                    }
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   122
                    return false;
30359
b2b7b66cd9eb 8077402: JMXStartStopTest fails intermittently on slow hosts
jbachorik
parents: 28760
diff changeset
   123
                }
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   124
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   125
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   126
            System.out.println("Attaching test manager:");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   127
            System.out.println("=========================");
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   128
            System.out.println("  PID           : " + serverPrc.getPid());
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   129
            System.out.println("  shutdown port : " + port.get());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   130
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   131
            ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   132
                "-cp",
28760
b83d51c77b31 8067945: SVC jdk/test/* should be cleaned from JRE layout dependency
ykantser
parents: 25182
diff changeset
   133
                TEST_CLASSPATH,
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 31455
diff changeset
   134
                "-XaddExports:java.management/sun.management=ALL-UNNAMED",
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   135
                "TestManager",
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   136
                String.valueOf(serverPrc.getPid()),
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   137
                port.get(),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   138
                "true"
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   139
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   140
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   141
            clientPrc = ProcessTools.startProcess(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   142
                "TestManager",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   143
                client,
30359
b2b7b66cd9eb 8077402: JMXStartStopTest fails intermittently on slow hosts
jbachorik
parents: 28760
diff changeset
   144
                (String line) -> line.startsWith("Starting TestManager for PID")
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   145
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   146
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   147
            int clientExitCode = clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   148
            int serverExitCode = serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   149
            return clientExitCode == 0 && serverExitCode == 0;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   150
        } finally {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   151
            if (clientPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   152
                System.out.println("Stopping process " + clientPrc);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   153
                clientPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   154
                clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   155
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   156
            if (serverPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   157
                System.out.println("Stopping process " + serverPrc);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   158
                serverPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   159
                serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   160
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   161
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   162
    }
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
   163
}