jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
author ykantser
Fri, 23 Jan 2015 14:20:52 +0100
changeset 28760 b83d51c77b31
parent 25182 1f6766bac82c
child 30359 b2b7b66cd9eb
permissions -rw-r--r--
8067945: SVC jdk/test/* should be cleaned from JRE layout dependency Reviewed-by: sla Contributed-by: alexander.kulyakhtin@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
/*
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
     2
 * Copyright (c) 2013, 2014, 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.io.File;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    25
import java.lang.reflect.Method;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    26
import java.lang.reflect.Modifier;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    27
import java.util.ArrayList;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    28
import java.util.List;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    29
import java.util.concurrent.TimeUnit;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    30
import java.util.concurrent.atomic.AtomicReference;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    31
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    32
/**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    33
 * @test
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
    34
 * @library /lib/testlibrary
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    35
 * @bug 5016507 6173612 6319776 6342019 6484550 8004926
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    36
 * @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
    37
 *          without connection or username/password details.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    38
 *          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
    39
 *          both agent properties and jvmstat buffer.
24509
5d02a6d25f78 8043520: Serviceability tests using @library failing with java.lang.NoClassDefFoundError
ykantser
parents: 23031
diff changeset
    40
 * @build jdk.testlibrary.* TestManager TestApplication
23002
b66277a59feb 8033787: [TESTBUG] Few jdk regression management tests should be improved with -XX:+UsePerfData usage
jbachorik
parents: 21822
diff changeset
    41
 * @run main/othervm/timeout=300 -XX:+UsePerfData LocalManagementTest
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    42
 */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    43
23031
995cf5c2eb55 7195249: Some jtreg tests use hard coded ports
sla
parents: 23002
diff changeset
    44
import jdk.testlibrary.ProcessTools;
995cf5c2eb55 7195249: Some jtreg tests use hard coded ports
sla
parents: 23002
diff changeset
    45
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    46
public class LocalManagementTest {
23031
995cf5c2eb55 7195249: Some jtreg tests use hard coded ports
sla
parents: 23002
diff changeset
    47
    private static final String TEST_CLASSPATH = System.getProperty("test.class.path");
995cf5c2eb55 7195249: Some jtreg tests use hard coded ports
sla
parents: 23002
diff changeset
    48
    private static final String TEST_JDK = System.getProperty("test.jdk");
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    49
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    50
    public static void main(String[] args) throws Exception {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    51
        int failures = 0;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    52
        for(Method m : LocalManagementTest.class.getDeclaredMethods()) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    53
            if (Modifier.isStatic(m.getModifiers()) &&
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    54
                m.getName().startsWith("test")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    55
                m.setAccessible(true);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    56
                try {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    57
                    System.out.println(m.getName());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    58
                    System.out.println("==========");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    59
                    Boolean rslt = (Boolean)m.invoke(null);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    60
                    if (!rslt) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    61
                        System.err.println(m.getName() + " failed");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    62
                        failures++;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    63
                    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    64
                } catch (Exception e) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    65
                    e.printStackTrace();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    66
                    failures++;
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
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    69
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    70
        if (failures > 0) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    71
            throw new Error("Test failed");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    72
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    73
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    74
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
    75
    @SuppressWarnings("unused")
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    76
    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
    77
        return doTest("1", "-Dcom.sun.management.jmxremote");
21367
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
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    80
    /**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    81
     * no args (blank) - manager should attach and start agent
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    82
     */
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
    83
    @SuppressWarnings("unused")
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    84
    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
    85
        return doTest("3", null);
21367
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
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    88
    /**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    89
     * use DNS-only name service
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    90
     */
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
    91
    @SuppressWarnings("unused")
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    92
    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
    93
        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
    94
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    95
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
    96
    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
    97
        List<String> args = new ArrayList<>();
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;
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   123
                },
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   124
                5,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   125
                TimeUnit.SECONDS
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   126
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   127
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   128
            System.out.println("Attaching test manager:");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   129
            System.out.println("=========================");
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   130
            System.out.println("  PID           : " + serverPrc.getPid());
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   131
            System.out.println("  shutdown port : " + port.get());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   132
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   133
            ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   134
                "-cp",
28760
b83d51c77b31 8067945: SVC jdk/test/* should be cleaned from JRE layout dependency
ykantser
parents: 25182
diff changeset
   135
                TEST_CLASSPATH,
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   136
                "TestManager",
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24870
diff changeset
   137
                String.valueOf(serverPrc.getPid()),
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   138
                port.get(),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   139
                "true"
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
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   142
            clientPrc = ProcessTools.startProcess(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   143
                "TestManager",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   144
                client,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   145
                (String line) -> line.startsWith("Starting TestManager for PID"),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   146
                10,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   147
                TimeUnit.SECONDS
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   148
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   149
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   150
            int clientExitCode = clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   151
            int serverExitCode = serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   152
            return clientExitCode == 0 && serverExitCode == 0;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   153
        } finally {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   154
            if (clientPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   155
                System.out.println("Stopping process " + clientPrc);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   156
                clientPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   157
                clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   158
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   159
            if (serverPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   160
                System.out.println("Stopping process " + serverPrc);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   161
                serverPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   162
                serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   163
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   164
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   165
    }
24870
5d567113d043 8044135: Add API to start JMX agent from attach framework
sla
parents: 24509
diff changeset
   166
}