test/compiler/compilercontrol/jcmd/StressAddJcmdBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff test/compiler/compilercontrol/jcmd

test/compiler/compilercontrol/jcmd/StressAddJcmdBase.java

Print this page
rev 10233 : 8149060: [TESTBUG] compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java spawns tens of thousands of threads
Summary: Change test to use a small limited amount of threads
Reviewed-by:


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.compilercontrol.jcmd;
  25 
  26 import compiler.compilercontrol.parser.HugeDirectiveUtil;
  27 import compiler.compilercontrol.share.AbstractTestBase;
  28 import compiler.compilercontrol.share.method.MethodDescriptor;
  29 import compiler.compilercontrol.share.scenario.Executor;
  30 import jdk.test.lib.OutputAnalyzer;
  31 import jdk.test.lib.TimeLimitedRunner;
  32 import jdk.test.lib.Utils;
  33 import pool.PoolHelper;
  34 
  35 import java.util.List;
  36 import java.util.stream.Collectors;
  37 import java.util.stream.Stream;
  38 
  39 public abstract class StressAddJcmdBase {
  40     private static final int DIRECTIVES_AMOUNT = Integer.getInteger(
  41             "compiler.compilercontrol.jcmd.StressAddJcmdBase.directivesAmount",
  42             1000);
  43     private static final int DIRECTIVE_FILES = Integer.getInteger(
  44             "compiler.compilercontrol.jcmd.StressAddJcmdBase.directiveFiles",
  45             5);
  46     private static final List<MethodDescriptor> DESCRIPTORS = new PoolHelper()
  47             .getAllMethods().stream()
  48                     .map(pair -> AbstractTestBase
  49                             .getValidMethodDescriptor(pair.first))
  50                     .collect(Collectors.toList());
  51 
  52     /**
  53      * Performs test
  54      */
  55     public void test() {
  56         List<String> commands = prepareCommands();
  57         Executor executor = new TimeLimitedExecutor(commands);
  58         List<OutputAnalyzer> outputAnalyzers = executor.execute();
  59         outputAnalyzers.get(0).shouldHaveExitValue(0);
  60     }
  61 
  62     /**
  63      * Makes connection to the test VM
  64      *
  65      * @param pid      a pid of the VM under test


  79             files[i] = "directives" + i + ".json";
  80             HugeDirectiveUtil.createHugeFile(DESCRIPTORS, files[i],
  81                     DIRECTIVES_AMOUNT);
  82         }
  83         return Stream.of(files)
  84                 .map(file -> "Compiler.directives_add " + file)
  85                 .collect(Collectors.toList());
  86     }
  87 
  88     private class TimeLimitedExecutor extends Executor {
  89         private final List<String> jcmdCommands;
  90 
  91         public TimeLimitedExecutor(List<String> jcmdCommands) {
  92             /* There are no need to check the state */
  93             super(true, null, null, jcmdCommands);
  94             this.jcmdCommands = jcmdCommands;
  95         }
  96 
  97         @Override
  98         protected OutputAnalyzer[] executeJCMD(int pid) {
  99             TimeLimitedRunner runner = new TimeLimitedRunner(
 100                     Utils.DEFAULT_TEST_TIMEOUT,
 101                     Utils.TIMEOUT_FACTOR,
 102                     () -> makeConnection(pid, jcmdCommands));
 103             try {
 104                 runner.call();
 105             } catch (Exception e) {
 106                 throw new Error("Exception during the execution: " + e, e);
 107             }
 108             finish();
 109             return new OutputAnalyzer[0];
 110         }
 111     }
 112 }


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.compilercontrol.jcmd;
  25 
  26 import compiler.compilercontrol.parser.HugeDirectiveUtil;
  27 import compiler.compilercontrol.share.AbstractTestBase;
  28 import compiler.compilercontrol.share.method.MethodDescriptor;
  29 import compiler.compilercontrol.share.scenario.Executor;
  30 import jdk.test.lib.OutputAnalyzer;
  31 import jdk.test.lib.TimeLimitedRunner;
  32 import jdk.test.lib.Utils;
  33 import pool.PoolHelper;
  34 
  35 import java.util.List;
  36 import java.util.stream.Collectors;
  37 import java.util.stream.Stream;
  38 
  39 public abstract class StressAddJcmdBase {
  40     protected static int DIRECTIVES_AMOUNT = Integer.getInteger(
  41             "compiler.compilercontrol.jcmd.StressAddJcmdBase.directivesAmount",
  42             100);
  43     private static final int DIRECTIVE_FILES = Integer.getInteger(
  44             "compiler.compilercontrol.jcmd.StressAddJcmdBase.directiveFiles",
  45             4);
  46     private static final List<MethodDescriptor> DESCRIPTORS = new PoolHelper()
  47             .getAllMethods().stream()
  48                     .map(pair -> AbstractTestBase
  49                             .getValidMethodDescriptor(pair.first))
  50                     .collect(Collectors.toList());
  51 
  52     /**
  53      * Performs test
  54      */
  55     public void test() {
  56         List<String> commands = prepareCommands();
  57         Executor executor = new TimeLimitedExecutor(commands);
  58         List<OutputAnalyzer> outputAnalyzers = executor.execute();
  59         outputAnalyzers.get(0).shouldHaveExitValue(0);
  60     }
  61 
  62     /**
  63      * Makes connection to the test VM
  64      *
  65      * @param pid      a pid of the VM under test


  79             files[i] = "directives" + i + ".json";
  80             HugeDirectiveUtil.createHugeFile(DESCRIPTORS, files[i],
  81                     DIRECTIVES_AMOUNT);
  82         }
  83         return Stream.of(files)
  84                 .map(file -> "Compiler.directives_add " + file)
  85                 .collect(Collectors.toList());
  86     }
  87 
  88     private class TimeLimitedExecutor extends Executor {
  89         private final List<String> jcmdCommands;
  90 
  91         public TimeLimitedExecutor(List<String> jcmdCommands) {
  92             /* There are no need to check the state */
  93             super(true, null, null, jcmdCommands);
  94             this.jcmdCommands = jcmdCommands;
  95         }
  96 
  97         @Override
  98         protected OutputAnalyzer[] executeJCMD(int pid) {




  99             try {
 100                 makeConnection(pid, jcmdCommands);
 101             } catch (Exception e) {
 102                 throw new Error("Exception during the execution: " + e, e);
 103             }
 104             finish();
 105             return new OutputAnalyzer[0];
 106         }
 107     }
 108 }
test/compiler/compilercontrol/jcmd/StressAddJcmdBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File