--- old/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java 2020-02-11 18:28:48.072645185 +0100 +++ new/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java 2020-02-11 18:28:47.864644496 +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"); @@ -69,7 +81,9 @@ testMemorySoftLimit("500m","200m"); } finally { - DockerTestUtils.removeDockerImage(imageName); + if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) { + DockerTestUtils.removeDockerImage(imageName); + } } } @@ -147,7 +161,8 @@ 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!!!"); + OutputAnalyzer oa = DockerTestUtils.dockerRunJava(opts); + oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!"); } private static void testMemorySoftLimit(String mem, String softLimit) throws Exception {