< prev index next >
test/hotspot/jtreg/containers/docker/TestMisc.java
Print this page
@ rev 56576 : 8230305: Cgroups v2: Container awareness
| Summary: Implement Cgroups v2 container awareness in hotspot
~ Reviewed-by: bobv
*** 32,41 ****
--- 32,42 ----
* jdk.jartool/sun.tools.jar
* @build CheckContainerized sun.hotspot.WhiteBox PrintContainerInfo
* @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;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
*** 87,116 ****
Common.logNewTestCase("Test print_container_info()");
DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo");
Common.addWhiteBoxOpts(opts);
! checkContainerInfo(Common.run(opts));
}
! private static void checkContainerInfo(OutputAnalyzer out) throws Exception {
String[] expectedToContain = new String[] {
"cpuset.cpus",
"cpuset.mems",
"CPU Shares",
"CPU Quota",
"CPU Period",
"OSContainer::active_processor_count",
"Memory Limit",
"Memory Soft Limit",
"Memory Usage",
- "Maximum Memory Usage",
"memory_max_usage_in_bytes"
};
for (String s : expectedToContain) {
out.shouldContain(s);
}
}
}
--- 88,131 ----
Common.logNewTestCase("Test print_container_info()");
DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo");
Common.addWhiteBoxOpts(opts);
! OutputAnalyzer out = Common.run(opts);
! checkContainerInfoCommon(out);
! checkContainerInfoCgroupSpecific(out);
}
! private static void checkContainerInfoCommon(OutputAnalyzer out) throws Exception {
String[] expectedToContain = new String[] {
"cpuset.cpus",
"cpuset.mems",
"CPU Shares",
"CPU Quota",
"CPU Period",
"OSContainer::active_processor_count",
"Memory Limit",
"Memory Soft Limit",
"Memory Usage",
"memory_max_usage_in_bytes"
};
for (String s : expectedToContain) {
out.shouldContain(s);
}
}
+ private static void checkContainerInfoCgroupSpecific(OutputAnalyzer out) throws Exception {
+ Optional<String> 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
+ }
+ }
+ }
+
}
< prev index next >