hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java
author dcubed
Tue, 05 Jul 2016 14:00:21 -0700
changeset 39696 80c9894e18f9
parent 39438 206a712f8f16
child 40059 c2304140ed64
permissions -rw-r--r--
8160739: quarantine tests failing due to -XX:TieredStopAtLevel=1 8160743: quarantine tests that can't attach symbolicator to the process on MacOS X Reviewed-by: sspitsyn, dholmes, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     1
/*
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     4
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     8
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    13
 * accompanied this code).
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    14
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    18
 *
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    21
 * questions.
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    22
 */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    23
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    24
/*
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    25
 * @test
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    26
 * @bug 8137167
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    27
 * @summary Tests jcmd to be able to add a lot of huge directive files with
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    28
 *          parallel executed jcmds until timeout has reached
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 36796
diff changeset
    29
 * @modules java.base/jdk.internal.misc
39438
206a712f8f16 8132920: use package in compiler testlibraries
iignatyev
parents: 38152
diff changeset
    30
 * @library /testlibrary /test/lib ../share /
35597
0174e7c4489f 8148136: compile control tests have incorrect @build directives
iignatyev
parents: 34215
diff changeset
    31
 * @build compiler.compilercontrol.jcmd.StressAddMultiThreadedTest
0174e7c4489f 8148136: compile control tests have incorrect @build directives
iignatyev
parents: 34215
diff changeset
    32
 *        pool.sub.* pool.subpack.* sun.hotspot.WhiteBox
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    33
 *        compiler.testlibrary.CompilerUtils
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    34
 *        compiler.compilercontrol.share.actions.*
36796
c751f445f5d4 8150054: Make compilercontrol test ignore xcomp
neliasso
parents: 36549
diff changeset
    35
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
39438
206a712f8f16 8132920: use package in compiler testlibraries
iignatyev
parents: 38152
diff changeset
    36
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
36549
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    37
 * @run driver compiler.compilercontrol.jcmd.StressAddMultiThreadedTest
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    38
 */
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    39
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    40
package compiler.compilercontrol.jcmd;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    41
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    42
import jdk.test.lib.dcmd.PidJcmdExecutor;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    43
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    44
import java.util.concurrent.ArrayBlockingQueue;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    45
import java.util.concurrent.BlockingQueue;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    46
import java.util.concurrent.ExecutorService;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    47
import java.util.concurrent.ThreadPoolExecutor;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    48
import java.util.concurrent.TimeUnit;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    49
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    50
public class StressAddMultiThreadedTest extends StressAddJcmdBase {
36549
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    51
    private static final int THREADS = Integer.getInteger(
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    52
            "compiler.compilercontrol.jcmd.StressAddMultiThreadedTest.threads",
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    53
            5);
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    54
    private volatile int commands = Integer.getInteger(
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    55
            "compiler.compilercontrol.jcmd.StressAddMultiThreadedTest.commands",
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    56
            20);
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    57
    private final BlockingQueue<Runnable> queue;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    58
    private final ExecutorService executor;
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    59
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    60
    public StressAddMultiThreadedTest() {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    61
        queue = new ArrayBlockingQueue<>(THREADS);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    62
        executor = new ThreadPoolExecutor(THREADS, THREADS, 100,
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    63
                TimeUnit.MILLISECONDS, queue,
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    64
                new ThreadPoolExecutor.CallerRunsPolicy());
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    65
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    66
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    67
    public static void main(String[] args) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    68
        new StressAddMultiThreadedTest().test();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    69
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    70
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    71
    @Override
36549
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    72
    protected boolean makeConnection(int pid) {
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    73
        executor.submit(() -> new PidJcmdExecutor(String.valueOf(pid))
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    74
                .execute(nextCommand()));
d191b3de2ad3 8148563: compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java timesout
ppunegov
parents: 35833
diff changeset
    75
        return (--commands != 0);
34215
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    76
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    77
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    78
    @Override
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    79
    protected void finish() {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    80
        executor.shutdown();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    81
        try {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    82
            executor.awaitTermination(10, TimeUnit.SECONDS);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    83
        } catch (InterruptedException e) {
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    84
            throw new Error("Interrupted while awaiting for termination: " + e,
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    85
                    e);
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    86
        }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    87
        executor.shutdownNow();
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    88
    }
ae6ba67d6420 8066156: JEP-JDK-8046155: Test task: stress by dcmd
ppunegov
parents:
diff changeset
    89
}