8220674: [TESTBUG] MetricsMemoryTester failcount test in docker container only works with debug JVMs
Reviewed-by: sspitsyn, sgehwolf
--- a/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java Thu Mar 21 17:38:41 2019 +0000
+++ b/test/jdk/jdk/internal/platform/docker/MetricsMemoryTester.java Thu Mar 21 14:40:04 2019 -0400
@@ -64,10 +64,15 @@
long count = Metrics.systemMetrics().getMemoryFailCount();
// Allocate 512M of data
- long[][] longs = new long[64][];
- for (int i = 1; i <= 64; i++) {
+ byte[][] bytes = new byte[64][];
+ for (int i = 0; i < 64; i++) {
try {
- longs[i] = new long[8 * 1024 * 1024];
+ bytes[i] = new byte[8 * 1024 * 1024];
+ // Break out as soon as we see an increase in failcount
+ // to avoid getting killed by the OOM killer.
+ if (Metrics.systemMetrics().getMemoryFailCount() > count) {
+ break;
+ }
} catch (Error e) { // OOM error
break;
}
--- a/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java Thu Mar 21 17:38:41 2019 +0000
+++ b/test/jdk/jdk/internal/platform/docker/TestDockerMemoryMetrics.java Thu Mar 21 14:40:04 2019 -0400
@@ -90,6 +90,7 @@
new DockerRunOptions(imageName, "/jdk/bin/java", "MetricsMemoryTester");
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
.addDockerOpts("--memory=" + value)
+ .addJavaOpts("-Xmx" + value)
.addJavaOpts("-cp", "/test-classes/")
.addJavaOpts("--add-exports", "java.base/jdk.internal.platform=ALL-UNNAMED")
.addClassOptions("failcount");