8227317: [TESTBUG] jdk docker/TestDockerMemoryMetrics.java fails on systems w/o kernel memory accounting
authormseledtsov
Thu, 24 Oct 2019 12:18:32 -0700
changeset 58790 5a9dba5a3eeb
parent 58789 a2dfaae89445
child 58793 81ad1da857f6
8227317: [TESTBUG] jdk docker/TestDockerMemoryMetrics.java fails on systems w/o kernel memory accounting Summary: skipping the test case if kernel memory acct not supported Reviewed-by: sgehwolf, lmesnik
test/jdk/ProblemList.txt
test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java
--- a/test/jdk/ProblemList.txt	Thu Oct 24 11:25:53 2019 -0700
+++ b/test/jdk/ProblemList.txt	Thu Oct 24 12:18:32 2019 -0700
@@ -890,6 +890,4 @@
 
 # jdk_internal
 
-jdk/internal/platform/docker/TestDockerMemoryMetrics.java       8227317    linux-x64
-
 ############################################################################
--- a/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java	Thu Oct 24 11:25:53 2019 -0700
+++ b/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java	Thu Oct 24 12:18:32 2019 -0700
@@ -25,6 +25,7 @@
 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;
 
 /*
  * @test
@@ -119,7 +120,19 @@
                 .addJavaOpts("-cp", "/test-classes/")
                 .addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED")
                 .addClassOptions("kernelmem", value);
-        DockerTestUtils.dockerRunJava(opts).shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
+        OutputAnalyzer oa = DockerTestUtils.dockerRunJava(opts);
+
+        // Some container runtimes (e.g. runc, docker 18.09)
+        // have been built without kernel memory accounting. In
+        // that case, the runtime issues a message on stderr saying
+        // so. Skip the test in that case.
+        if (oa.getStderr().contains("kernel memory accounting disabled")) {
+            System.out.println("Kernel memory accounting disabled, " +
+                                       "skipping the test case");
+            return;
+        }
+
+        oa.shouldHaveExitValue(0).shouldContain("TEST PASSED!!!");
     }
 
     private static void testOomKillFlag(String value, boolean oomKillFlag) throws Exception {