--- old/test/hotspot/jtreg/containers/docker/TestMisc.java 2019-10-18 18:16:12.739134015 +0200 +++ new/test/hotspot/jtreg/containers/docker/TestMisc.java 2019-10-18 18:16:12.605133668 +0200 @@ -34,6 +34,7 @@ * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * @run driver TestMisc */ +import java.util.Optional; import jdk.test.lib.containers.docker.Common; import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.containers.docker.DockerRunOptions; @@ -89,11 +90,13 @@ DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo"); Common.addWhiteBoxOpts(opts); - checkContainerInfo(Common.run(opts)); + OutputAnalyzer out = Common.run(opts); + checkContainerInfoCommon(out); + checkContainerInfoCgroupSpecific(out); } - private static void checkContainerInfo(OutputAnalyzer out) throws Exception { + private static void checkContainerInfoCommon(OutputAnalyzer out) throws Exception { String[] expectedToContain = new String[] { "cpuset.cpus", "cpuset.mems", @@ -104,7 +107,6 @@ "Memory Limit", "Memory Soft Limit", "Memory Usage", - "Maximum Memory Usage", "memory_max_usage_in_bytes" }; @@ -113,4 +115,17 @@ } } + private static void checkContainerInfoCgroupSpecific(OutputAnalyzer out) throws Exception { + Optional cgroupVersString = out.asLines() + .stream() + .filter( l -> l.startsWith("Detected CGroups version is:") ) + .findFirst(); + if (cgroupVersString.isPresent()) { // only non-product builds have this + String cgroupVers = cgroupVersString.get().split(": ")[1].trim(); + if ("cgroupv1".equals(cgroupVers)) { + out.shouldContain("Maximum Memory Usage"); // only supported for cgroups v1 + } + } + } + }