< prev index next >

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

Print this page
o  rev 57733 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
|  Reviewed-by: bobv, mchung
~
o  rev 56862 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
|  Reviewed-by: bobv
~

*** 19,28 **** --- 19,29 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ + import jdk.internal.platform.Metrics; import jdk.test.lib.Utils; import jdk.test.lib.containers.docker.Common; import jdk.test.lib.containers.docker.DockerRunOptions; import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.process.OutputAnalyzer;
*** 56,79 **** --- 57,93 ---- testMemoryLimit("1g"); testMemoryAndSwapLimit("200m", "1g"); testMemoryAndSwapLimit("100m", "200m"); + Metrics m = Metrics.systemMetrics(); + // kernel memory, '--kernel-memory' switch, and OOM killer, + // '--oom-kill-disable' switch, tests not supported by cgroupv2 + // runtimes + if (m != null) { + if ("cgroupv1".equals(m.getProvider())) { testKernelMemoryLimit("100m"); testKernelMemoryLimit("1g"); testOomKillFlag("100m", false); + } else { + System.out.println("kernel memory tests and OOM Kill flag tests not " + + "possible with cgroupv2."); + } + } testOomKillFlag("100m", true); testMemoryFailCount("64m"); testMemorySoftLimit("500m","200m"); } finally { + if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) { DockerTestUtils.removeDockerImage(imageName); } } + } private static void testMemoryLimit(String value) throws Exception { Common.logNewTestCase("testMemoryLimit, value = " + value); DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsMemoryTester");
*** 145,155 **** opts.addDockerOpts("--oom-kill-disable"); } opts.addJavaOpts("-cp", "/test-classes/") .addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED") .addClassOptions("memory", value, oomKillFlag + ""); ! DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!"); } private static void testMemorySoftLimit(String mem, String softLimit) throws Exception { Common.logNewTestCase("testMemorySoftLimit, memory = " + mem + ", soft limit = " + softLimit); DockerRunOptions opts = --- 159,170 ---- opts.addDockerOpts("--oom-kill-disable"); } opts.addJavaOpts("-cp", "/test-classes/") .addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED") .addClassOptions("memory", value, oomKillFlag + ""); ! OutputAnalyzer oa = DockerTestUtils.dockerRunJava(opts); ! oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!"); } private static void testMemorySoftLimit(String mem, String softLimit) throws Exception { Common.logNewTestCase("testMemorySoftLimit, memory = " + mem + ", soft limit = " + softLimit); DockerRunOptions opts =
< prev index next >