# HG changeset patch # User hseigel # Date 1601054198 0 # Node ID 48a018a40f074d64508753f9e50e44d934c8280b # Parent 21cf022ac5505ad620d64bab2a8c62c0cce2e46a 8250984: Memory Docker tests fail on some Linux kernels w/o cgroupv1 swap limit capabilities Reviewed-by: bobv, sgehwolf, phh diff -r 21cf022ac550 -r 48a018a40f07 test/runtime/containers/docker/TestMemoryAwareness.java --- a/test/runtime/containers/docker/TestMemoryAwareness.java Fri Aug 30 11:11:33 2019 +0200 +++ b/test/runtime/containers/docker/TestMemoryAwareness.java Fri Sep 25 17:16:38 2020 +0000 @@ -34,6 +34,7 @@ import com.oracle.java.testlibrary.Common; import com.oracle.java.testlibrary.DockerRunOptions; import com.oracle.java.testlibrary.DockerTestUtils; +import com.oracle.java.testlibrary.OutputAnalyzer; public class TestMemoryAwareness { @@ -128,14 +129,26 @@ "--memory-swap", swapAllocation ); - DockerTestUtils.dockerRunJava(opts) - .shouldHaveExitValue(0) - .shouldContain("Checking OperatingSystemMXBean") - .shouldContain("OperatingSystemMXBean.getTotalPhysicalMemorySize: " + expectedMemory) - .shouldMatch("OperatingSystemMXBean\\.getFreePhysicalMemorySize: [1-9][0-9]+") - .shouldContain("OperatingSystemMXBean.getTotalSwapSpaceSize: " + expectedSwap) - .shouldMatch("OperatingSystemMXBean\\.getFreeSwapSpaceSize: [1-9][0-9]+") - ; + OutputAnalyzer out = DockerTestUtils.dockerRunJava(opts); + out.shouldHaveExitValue(0) + .shouldContain("Checking OperatingSystemMXBean") + .shouldContain("OperatingSystemMXBean.getTotalPhysicalMemorySize: " + expectedMemory) + .shouldMatch("OperatingSystemMXBean\\.getFreePhysicalMemorySize: [1-9][0-9]+"); + // in case of warnings like : "Your kernel does not support swap limit capabilities + // or the cgroup is not mounted. Memory limited without swap." + // the getTotalSwapSpaceSize and getFreeSwapSpaceSize return the system + // values as the container setup isn't supported in that case. + try { + out.shouldContain("OperatingSystemMXBean.getTotalSwapSpaceSize: " + expectedSwap); + } catch(RuntimeException ex) { + out.shouldMatch("OperatingSystemMXBean.getTotalSwapSpaceSize: [0-9]+"); + } + + try { + out.shouldMatch("OperatingSystemMXBean\\.getFreeSwapSpaceSize: [1-9][0-9]+"); + } catch(RuntimeException ex) { + out.shouldMatch("OperatingSystemMXBean\\.getFreeSwapSpaceSize: 0"); + } } }