< prev index next >

test/jdk/jdk/internal/platform/docker/TestDockerCpuMetrics.java

Print this page
@  rev 57446 : Review changes
|
~


  61             testCpuSet("0-" + (numCpus - 1));
  62             if (numCpus > 2) {
  63                 testCpuSet("0-" + ((numCpus - 1) / 2));
  64                 testCpuSet((((numCpus - 1) / 2) + 1) + "-" + (numCpus - 1));
  65             }
  66             testCpuSet(IntStream.range(0, numCpus).mapToObj(a -> Integer.toString(a)).collect(Collectors.joining(",")));
  67 
  68             testCpuQuota(50 * 1000, 100 * 1000);
  69             testCpuQuota(100 * 1000, 100 * 1000);
  70             testCpuQuota(150 * 1000, 100 * 1000);
  71             testCpuQuota(400 * 1000, 100 * 1000);
  72 
  73             testCpuShares(256);
  74             testCpuShares(2048);
  75             testCpuShares(4096);
  76 
  77             testCpuThrottling(0.5);// --cpus=<value>
  78 
  79             int[] cpuSetMems = Metrics.systemMetrics().getCpuSetMems();
  80             String memNodes = null;
  81             if (cpuSetMems.length > 1) {
  82                 int endNode = (cpuSetMems[cpuSetMems.length - 1] - cpuSetMems[0]) / 2 + cpuSetMems[0];
  83                 memNodes = cpuSetMems[0] + "-" + endNode;
  84             } else if (cpuSetMems.length == 1) {
  85                 memNodes = cpuSetMems[0] + "";
  86             }
  87 
  88             if(memNodes != null)
  89                 testCpuSetMems(memNodes);
  90 
  91             testComboOptions("0-" + (numCpus - 1), 200 * 1000, 100 * 1000, 4 * 1024);
  92             testComboOptions("0", 200 * 1000, 100 * 1000, 1023);
  93         } finally {
  94             DockerTestUtils.removeDockerImage(imageName);
  95         }
  96     }
  97 
  98     private static void testCpuSetMems(String value) throws Exception {
  99         Common.logNewTestCase("testCpuSetMems, mem nodes = " + value);
 100         DockerRunOptions opts =
 101                 new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsCpuTester");
 102         opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
 103         opts.addDockerOpts("--cpuset-mems=" + value);
 104         opts.addJavaOpts("-cp", "/test-classes/").addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED");




  61             testCpuSet("0-" + (numCpus - 1));
  62             if (numCpus > 2) {
  63                 testCpuSet("0-" + ((numCpus - 1) / 2));
  64                 testCpuSet((((numCpus - 1) / 2) + 1) + "-" + (numCpus - 1));
  65             }
  66             testCpuSet(IntStream.range(0, numCpus).mapToObj(a -> Integer.toString(a)).collect(Collectors.joining(",")));
  67 
  68             testCpuQuota(50 * 1000, 100 * 1000);
  69             testCpuQuota(100 * 1000, 100 * 1000);
  70             testCpuQuota(150 * 1000, 100 * 1000);
  71             testCpuQuota(400 * 1000, 100 * 1000);
  72 
  73             testCpuShares(256);
  74             testCpuShares(2048);
  75             testCpuShares(4096);
  76 
  77             testCpuThrottling(0.5);// --cpus=<value>
  78 
  79             int[] cpuSetMems = Metrics.systemMetrics().getCpuSetMems();
  80             String memNodes = null;
  81             if (cpuSetMems != null && cpuSetMems.length > 1) {
  82                 int endNode = (cpuSetMems[cpuSetMems.length - 1] - cpuSetMems[0]) / 2 + cpuSetMems[0];
  83                 memNodes = cpuSetMems[0] + "-" + endNode;
  84             } else if (cpuSetMems != null && cpuSetMems.length == 1) {
  85                 memNodes = cpuSetMems[0] + "";
  86             }
  87 
  88             if(memNodes != null)
  89                 testCpuSetMems(memNodes);
  90 
  91             testComboOptions("0-" + (numCpus - 1), 200 * 1000, 100 * 1000, 4 * 1024);
  92             testComboOptions("0", 200 * 1000, 100 * 1000, 1023);
  93         } finally {
  94             DockerTestUtils.removeDockerImage(imageName);
  95         }
  96     }
  97 
  98     private static void testCpuSetMems(String value) throws Exception {
  99         Common.logNewTestCase("testCpuSetMems, mem nodes = " + value);
 100         DockerRunOptions opts =
 101                 new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsCpuTester");
 102         opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
 103         opts.addDockerOpts("--cpuset-mems=" + value);
 104         opts.addJavaOpts("-cp", "/test-classes/").addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED");


< prev index next >