jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java
author jbachorik
Mon, 18 Nov 2013 15:25:15 +0100
changeset 21802 b36494ddf19e
parent 21404 0e54d286d846
child 21822 12f13ba496cd
permissions -rw-r--r--
8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support Reviewed-by: sla
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
/*
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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.nio.file.FileSystem;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    28
import java.nio.file.FileSystems;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    29
import java.nio.file.Files;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    30
import java.nio.file.Path;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    31
import java.util.ArrayList;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    32
import java.util.List;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    33
import java.util.concurrent.TimeUnit;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    34
import java.util.concurrent.atomic.AtomicReference;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    35
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    36
/**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    37
 * @test
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
    38
 * @library /lib/testlibrary
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    39
 * @bug 5016507 6173612 6319776 6342019 6484550 8004926
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    40
 * @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
    41
 *          without connection or username/password details.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    42
 *          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
    43
 *          both agent properties and jvmstat buffer.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    44
 * @build TestManager TestApplication
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
    45
 * @run main/othervm/timeout=300 LocalManagementTest
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    46
 */
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
import jdk.testlibrary.ProcessTools;
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 class LocalManagementTest {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    51
    private static final  String TEST_CLASSES = System.getProperty("test.classes");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    52
    private static final  String TEST_JDK = System.getProperty("test.jdk");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    53
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    54
    public static void main(String[] args) throws Exception {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    55
        int failures = 0;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    56
        for(Method m : LocalManagementTest.class.getDeclaredMethods()) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    57
            if (Modifier.isStatic(m.getModifiers()) &&
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    58
                m.getName().startsWith("test")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    59
                m.setAccessible(true);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    60
                try {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    61
                    System.out.println(m.getName());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    62
                    System.out.println("==========");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    63
                    Boolean rslt = (Boolean)m.invoke(null);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    64
                    if (!rslt) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    65
                        System.err.println(m.getName() + " failed");
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
                } catch (Exception e) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    69
                    e.printStackTrace();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    70
                    failures++;
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
            }
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
        if (failures > 0) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    75
            throw new Error("Test failed");
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
    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
    80
        return doTest("1", "-Dcom.sun.management.jmxremote");
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    81
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    82
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    83
    private static boolean test2() throws Exception {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    84
        Path agentPath = findAgent();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    85
        if (agentPath != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    86
            String agent = agentPath.toString();
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
    87
            return doTest("2", "-javaagent:" + agent);
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    88
        } else {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    89
            return false;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    90
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    91
    }
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
    /**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    94
     * no args (blank) - manager should attach and start agent
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    95
     */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    96
    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
    97
        return doTest("3", null);
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    98
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    99
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   100
    /**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   101
     * sanity check arguments to management-agent.jar
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   102
     */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   103
    private static boolean test4() throws Exception {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   104
        Path agentPath = findAgent();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   105
        if (agentPath != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   106
            ProcessBuilder builder = ProcessTools.createJavaProcessBuilder(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   107
                "-javaagent:" + agentPath.toString() +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   108
                "=com.sun.management.jmxremote.port=7775," +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   109
                "com.sun.management.jmxremote.authenticate=false," +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   110
                "com.sun.management.jmxremote.ssl=false",
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
   111
                "-cp",
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
   112
                TEST_CLASSES,
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   113
                "TestApplication",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   114
                "-exit"
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   115
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   116
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   117
            Process prc = null;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   118
            try {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   119
                prc = ProcessTools.startProcess(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   120
                    "TestApplication",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   121
                    builder
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   122
                );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   123
                int exitCode = prc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   124
                return exitCode == 0;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   125
            } finally {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   126
                if (prc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   127
                    prc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   128
                    prc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   129
                }
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
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   132
        return false;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   133
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   134
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   135
    /**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   136
     * use DNS-only name service
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   137
     */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   138
    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
   139
        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
   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
    private static Path findAgent() {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   143
        FileSystem FS = FileSystems.getDefault();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   144
        Path agentPath = FS.getPath(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   145
            TEST_JDK, "jre", "lib", "management-agent.jar"
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
        if (!isFileOk(agentPath)) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   148
            agentPath = FS.getPath(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   149
                TEST_JDK, "lib", "management-agent.jar"
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   150
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   151
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   152
        if (!isFileOk(agentPath)) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   153
            System.err.println("Can not locate management-agent.jar");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   154
            return null;
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
        return agentPath;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   157
    }
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
    private static boolean isFileOk(Path path) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   160
        return Files.isRegularFile(path) && Files.isReadable(path);
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
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21404
diff changeset
   163
    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
   164
        List<String> args = new ArrayList<>();
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
   165
        args.add("-cp");
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
   166
        args.add(TEST_CLASSES);
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
   167
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   168
        if (arg != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   169
            args.add(arg);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   170
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   171
        args.add("TestApplication");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   172
        ProcessBuilder server = ProcessTools.createJavaProcessBuilder(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   173
            args.toArray(new String[args.size()])
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   174
        );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   175
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   176
        Process serverPrc = null, clientPrc = null;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   177
        try {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   178
            final AtomicReference<String> port = new AtomicReference<>();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   179
            final AtomicReference<String> pid = new AtomicReference<>();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   180
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   181
            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
   182
                "TestApplication(" + testId + ")",
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   183
                server,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   184
                (String line) -> {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   185
                    if (line.startsWith("port:")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   186
                         port.set(line.split("\\:")[1]);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   187
                     } else  if (line.startsWith("pid:")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   188
                         pid.set(line.split("\\:")[1]);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   189
                     } else if (line.startsWith("waiting")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   190
                         return true;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   191
                     }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   192
                     return false;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   193
                },
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   194
                5,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   195
                TimeUnit.SECONDS
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   196
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   197
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   198
            System.out.println("Attaching test manager:");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   199
            System.out.println("=========================");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   200
            System.out.println("  PID           : " + pid.get());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   201
            System.out.println("  shutdown port : " + port.get());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   202
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   203
            ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   204
                "-cp",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   205
                TEST_CLASSES +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   206
                    File.pathSeparator +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   207
                    TEST_JDK +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   208
                    File.separator +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   209
                    "lib" +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   210
                    File.separator +
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   211
                    "tools.jar",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   212
                "TestManager",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   213
                pid.get(),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   214
                port.get(),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   215
                "true"
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   216
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   217
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   218
            clientPrc = ProcessTools.startProcess(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   219
                "TestManager",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   220
                client,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   221
                (String line) -> line.startsWith("Starting TestManager for PID"),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   222
                10,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   223
                TimeUnit.SECONDS
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   224
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   225
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   226
            int clientExitCode = clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   227
            int serverExitCode = serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   228
            return clientExitCode == 0 && serverExitCode == 0;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   229
        } finally {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   230
            if (clientPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   231
                System.out.println("Stopping process " + clientPrc);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   232
                clientPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   233
                clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   234
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   235
            if (serverPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   236
                System.out.println("Stopping process " + serverPrc);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   237
                serverPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   238
                serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   239
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   240
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   241
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   242
}