< prev index next >
test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java
Print this page
rev 55912 : 8229182: runtime/containers/docker/TestMemoryAwareness.java test fails on SLES12
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -35,11 +35,11 @@
* @run driver TestMemoryAwareness
*/
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;
public class TestMemoryAwareness {
private static final String imageName = Common.imageName("memory");
public static void main(String[] args) throws Exception {
@@ -96,17 +96,28 @@
// provoke OOM inside the container, see how VM reacts
private static void testOOM(String dockerMemLimit, int sizeToAllocInMb) throws Exception {
Common.logNewTestCase("OOM");
+ // add "--memory-swappiness 0" so as to disable anonymous page swapping.
DockerRunOptions opts = Common.newOpts(imageName, "AttemptOOM")
- .addDockerOpts("--memory", dockerMemLimit, "--memory-swap", dockerMemLimit);
+ .addDockerOpts("--memory", dockerMemLimit, "--memory-swappiness", "0", "--memory-swap", dockerMemLimit);
opts.classParams.add("" + sizeToAllocInMb);
- DockerTestUtils.dockerRunJava(opts)
- .shouldHaveExitValue(1)
- .shouldContain("Entering AttemptOOM main")
+ // make sure we avoid inherited Xmx settings from the jtreg vmoptions
+ // set Xmx ourselves instead
+ System.out.println("sizeToAllocInMb is:" + sizeToAllocInMb + " sizeToAllocInMb/2 is:" + sizeToAllocInMb/2);
+ String javaHeapSize = sizeToAllocInMb/2 + "m";
+ opts.addJavaOptsAppended("-Xmx" + javaHeapSize);
+
+ OutputAnalyzer out = DockerTestUtils.dockerRunJava(opts);
+
+ if (out.getExitValue() == 0) {
+ throw new RuntimeException("We exited successfully, but we wanted to provoke an OOM inside the container");
+ }
+
+ out.shouldContain("Entering AttemptOOM main")
.shouldNotContain("AttemptOOM allocation successful")
.shouldContain("java.lang.OutOfMemoryError");
}
}
< prev index next >