1 /*
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
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");
|
1 /*
2 * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
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");
|