Skip to content
Permalink
Browse files
8244500: jtreg test error in test/hotspot/jtreg/containers/docker/Tes…
…tMemoryAwareness.java

When the kernel doesn't support swap limits, expect host values instead.

Reviewed-by: sgehwolf
Backport-of: fb5132254d834ba01a4b65ce64143843e83c674e
  • Loading branch information
ebaron authored and jerboaa committed Mar 28, 2022
1 parent 2bb6a3b commit 2049fca2aacbf0f0fc73b43d242d7ad188e64ef6
Showing 3 changed files with 21 additions and 2 deletions.
@@ -24,11 +24,20 @@

import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;
import jdk.internal.platform.Metrics;

public class CheckOperatingSystemMXBean {

public static void main(String[] args) {
System.out.println("Checking OperatingSystemMXBean");
Metrics metrics = jdk.internal.platform.Container.metrics();
System.out.println("Metrics instance: " + (metrics == null ? "null" : "non-null"));
if (metrics != null) {
System.out.println("Metrics.getMemoryAndSwapLimit() == " + metrics.getMemoryAndSwapLimit());
System.out.println("Metrics.getMemoryLimit() == " + metrics.getMemoryLimit());
System.out.println("Metrics.getMemoryAndSwapUsage() == " + metrics.getMemoryAndSwapUsage());
System.out.println("Metrics.getMemoryUsage() == " + metrics.getMemoryUsage());
}

OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
System.out.println(String.format("Runtime.availableProcessors: %d", Runtime.getRuntime().availableProcessors()));
@@ -28,6 +28,7 @@
* @requires docker.support
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.base/jdk.internal.platform
* java.management
* jdk.jartool/sun.tools.jar
* @build PrintContainerInfo CheckOperatingSystemMXBean
@@ -237,7 +238,11 @@ private static void testOperatingSystemMXBeanAwareness(String cpuAllocation, Str
DockerRunOptions opts = Common.newOpts(imageName, "CheckOperatingSystemMXBean")
.addDockerOpts(
"--cpus", cpuAllocation
);
)
// CheckOperatingSystemMXBean uses Metrics (jdk.internal.platform) for
// diagnostics
.addJavaOpts("--add-exports")
.addJavaOpts("java.base/jdk.internal.platform=ALL-UNNAMED");

DockerTestUtils.dockerRunJava(opts)
.shouldHaveExitValue(0)
@@ -28,6 +28,7 @@
* @requires docker.support
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.base/jdk.internal.platform
* java.management
* jdk.jartool/sun.tools.jar
* @build AttemptOOM sun.hotspot.WhiteBox PrintContainerInfo CheckOperatingSystemMXBean
@@ -142,7 +143,11 @@ private static void testOperatingSystemMXBeanAwareness(String memoryAllocation,
.addDockerOpts(
"--memory", memoryAllocation,
"--memory-swap", swapAllocation
);
)
// CheckOperatingSystemMXBean uses Metrics (jdk.internal.platform) for
// diagnostics
.addJavaOpts("--add-exports")
.addJavaOpts("java.base/jdk.internal.platform=ALL-UNNAMED");

OutputAnalyzer out = DockerTestUtils.dockerRunJava(opts);
out.shouldHaveExitValue(0)

1 comment on commit 2049fca

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 2049fca Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.