Skip to content

Commit

Permalink
Issue #12396 remove non reliable test from LowResourcesMonitorTest
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Lamy <[email protected]>
  • Loading branch information
olamy committed Oct 23, 2024
1 parent c457132 commit 319b9c1
Showing 1 changed file with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -161,29 +158,6 @@ public void testNotAccepting() throws Exception
}
}

@Disabled("not reliable")
@Test
public void testLowOnMemory() throws Exception
{
_lowResourcesMonitor.setMaxMemory(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() + (100 * 1024 * 1024));
Thread.sleep(1200);
assertFalse(_lowResourcesMonitor.isLowOnResources(), _lowResourcesMonitor.getReasons());

byte[] data = new byte[100 * 1024 * 1024];
Arrays.fill(data, (byte)1);
int hash = Arrays.hashCode(data);
assertThat(hash, not(equalTo(0)));

Thread.sleep(1200);
assertTrue(_lowResourcesMonitor.isLowOnResources());
data = null;
System.gc();
System.gc();

Thread.sleep(1200);
assertFalse(_lowResourcesMonitor.isLowOnResources(), _lowResourcesMonitor.getReasons());
}

@Test
public void testMaxLowResourcesTime() throws Exception
{
Expand Down

0 comments on commit 319b9c1

Please sign in to comment.