From 5991dc76a4d074f600defc8c2615f0a2a00ed1ee Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 21 May 2020 13:10:40 +0200 Subject: [PATCH] Increase tolerance in repo cache heap usage test This is needed because TestRepositoryCache.test900HeapUsage failed occasionally on Jenkins. --- .../midpoint/repo/cache/TestRepositoryCache.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java index 6e112bc2241..f6bf0232031 100644 --- a/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java +++ b/repo/repo-cache/src/test/java/com/evolveum/midpoint/repo/cache/TestRepositoryCache.java @@ -304,12 +304,12 @@ public void test900HeapUsage() throws Exception { OperationResult result = new OperationResult("testHeapUsage"); int size = 2_000_000; - int count = 300; + int count = 400; // 50 is the default "step" in paged iterative search, so we can expect we always have 50 objects in memory - // And "times 2" is the safety margin. It might or might not be sufficient, as System.gc() is not guaranteed to + // And "times 3" is the safety margin. It might or might not be sufficient, as System.gc() is not guaranteed to // really execute the garbage collection (only suggests JVM to do it). - long tolerance = (50 * size) * 2; + long tolerance = (50 * size) * 3; showMemory("Initial"); dumpHeap("initial"); @@ -337,9 +337,12 @@ public void test900HeapUsage() throws Exception { dumpHeap("final"); long difference = usedInLastIteration.get() - usedBefore; - display(String.format("Difference: %,d KB (tolerating %,d KB)", difference / 1024, tolerance / 1024)); - if (difference > tolerance) { - fail("Used too much memory during iterative search: " + difference / 1024 + " KB"); + + long differenceKb = difference / 1024; + long toleranceKb = tolerance / 1024; + System.out.printf("Difference: %,d KB (tolerating %,d KB)", differenceKb, toleranceKb); + if (differenceKb > toleranceKb) { + fail("Used too much memory during iterative search: " + differenceKb + " KB (accepting up to " + toleranceKb + " KB)"); } }