--- old/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java 2020-01-09 20:39:20.892147387 +0100 +++ new/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java 2020-01-09 20:39:20.761147250 +0100 @@ -21,6 +21,7 @@ * 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; @@ -58,10 +59,21 @@ testMemoryAndSwapLimit("200m", "1g"); testMemoryAndSwapLimit("100m", "200m"); - testKernelMemoryLimit("100m"); - testKernelMemoryLimit("1g"); - - testOomKillFlag("100m", false); + 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"); @@ -133,11 +145,6 @@ "skipping the test case"); return; } - if (oa.getStderr().contains("cannot set kernel memory with cgroupv2")) { - System.out.println("Kernel memory settings not possible with cgroupv2, " + - "skipping the test case"); - return; - } oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!"); } @@ -155,12 +162,6 @@ .addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED") .addClassOptions("memory", value, oomKillFlag + ""); OutputAnalyzer oa = DockerTestUtils.dockerRunJava(opts); - if (oa.getStderr().contains("cannot disable OOM killer with cgroupv2")) { - System.out.println("Disabling OOM killer not possible with cgroupv2, " + - "skipping the test case"); - return; - } - oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!"); }