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 */ 23 24 25 /* 26 * @test 27 * @summary Test JVM's CPU resource awareness when running inside docker container 28 * @requires docker.support 29 * @library /test/lib 30 * @modules java.base/jdk.internal.misc 31 * java.management 32 * jdk.jartool/sun.tools.jar 33 * @build Common 34 * @run driver TestCPUAwareness 35 */ 36 import java.util.List; 37 import jdk.test.lib.containers.docker.DockerRunOptions; 38 import jdk.test.lib.containers.docker.DockerTestUtils; 39 40 41 public class TestCPUAwareness { 42 private static final String imageName = Common.imageName("cpu"); 43 private static final int availableCPUs = Runtime.getRuntime().availableProcessors(); 44 45 public static void main(String[] args) throws Exception { 46 if (!DockerTestUtils.canTestDocker()) { 47 return; 48 } 49 50 System.out.println("Test Environment: detected availableCPUs = " + availableCPUs); 51 DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker"); 52 53 try { 54 // cpuset, period, shares, expected Active Processor Count 55 testComboWithCpuSets(); 56 57 // cpu shares - it should be safe to use CPU shares exceeding available CPUs 58 testCpuShares(256, 1); 59 testCpuShares(2048, 2); | 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 */ 23 24 25 /* 26 * @test 27 * @summary Test JVM's CPU resource awareness when running inside docker container 28 * @requires docker.support 29 * @library /test/lib 30 * @modules java.base/jdk.internal.misc 31 * java.management 32 * jdk.jartool/sun.tools.jar 33 * @run driver TestCPUAwareness 34 */ 35 import java.util.List; 36 import jdk.test.lib.containers.docker.Common; 37 import jdk.test.lib.containers.docker.DockerRunOptions; 38 import jdk.test.lib.containers.docker.DockerTestUtils; 39 import jdk.test.lib.containers.cgroup.CPUSetsReader; 40 41 public class TestCPUAwareness { 42 private static final String imageName = Common.imageName("cpu"); 43 private static final int availableCPUs = Runtime.getRuntime().availableProcessors(); 44 45 public static void main(String[] args) throws Exception { 46 if (!DockerTestUtils.canTestDocker()) { 47 return; 48 } 49 50 System.out.println("Test Environment: detected availableCPUs = " + availableCPUs); 51 DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker"); 52 53 try { 54 // cpuset, period, shares, expected Active Processor Count 55 testComboWithCpuSets(); 56 57 // cpu shares - it should be safe to use CPU shares exceeding available CPUs 58 testCpuShares(256, 1); 59 testCpuShares(2048, 2); |