< prev index next >

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

Print this page
@  rev 57586 : Review changes
|
o  rev 57585 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
|  Reviewed-by: bobv
~
o  rev 56863 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
|  Reviewed-by: bobv
~

@@ -19,10 +19,11 @@
  * 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,14 +57,25 @@
             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");

@@ -131,15 +143,10 @@
         if (oa.getStderr().contains("kernel memory accounting disabled")) {
             System.out.println("Kernel memory accounting disabled, " +
                                        "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!!!");
     }
 
     private static void testOomKillFlag(String value, boolean oomKillFlag) throws Exception {

@@ -153,16 +160,10 @@
         }
         opts.addJavaOpts("-cp", "/test-classes/")
                 .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!!!");
     }
 
     private static void testMemorySoftLimit(String mem, String softLimit) throws Exception {
         Common.logNewTestCase("testMemorySoftLimit, memory = " + mem + ", soft limit = " + softLimit);
< prev index next >