From b0b0cb50d63e2f831196fc9219858467a07d8302 Mon Sep 17 00:00:00 2001 From: Stephan Ewen Date: Mon, 13 Jul 2015 16:22:04 +0200 Subject: [PATCH] [FLINK-2235] Fix tests to allow exception in 'EnvironmentInformationTest.getSizeOfFreeHeapMemory()' if Xmx is not set. --- .../runtime/util/EnvironmentInformationTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java index 771c57cb8f0..3890a81cd4d 100644 --- a/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java +++ b/flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java @@ -30,12 +30,20 @@ public class EnvironmentInformationTest { public void testJavaMemory() { try { long fullHeap = EnvironmentInformation.getMaxJvmHeapMemory(); - long free = EnvironmentInformation.getSizeOfFreeHeapMemory(); long freeWithGC = EnvironmentInformation.getSizeOfFreeHeapMemoryWithDefrag(); assertTrue(fullHeap > 0); - assertTrue(free >= 0); assertTrue(freeWithGC >= 0); + + try { + long free = EnvironmentInformation.getSizeOfFreeHeapMemory(); + assertTrue(free >= 0); + } + catch (RuntimeException e) { + // this may only occur if the Xmx is not set + assertEquals(Long.MAX_VALUE, EnvironmentInformation.getMaxJvmHeapMemory()); + } + // we cannot make these assumptions, because the test JVM may grow / shrink during the GC // assertTrue(free <= fullHeap); -- GitLab