changeset 14040:76464abf8c6e

Be less optimistic as to how threads will actually do any work
author dsimms
date Thu, 17 Mar 2016 12:59:56 +0100
parents 047bfab10c75
children f0f28425e3e8
files test/valhalla/test/valhalla/anyutil/SimplePipelineTest.java
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/valhalla/test/valhalla/anyutil/SimplePipelineTest.java	Wed Mar 16 12:20:32 2016 +0000
+++ b/test/valhalla/test/valhalla/anyutil/SimplePipelineTest.java	Thu Mar 17 12:59:56 2016 +0100
@@ -26,6 +26,8 @@
 
 import org.testng.annotations.Test;
 
+import java.util.concurrent.ForkJoinPool;
+
 import java.anyutil.stream.*;
 import java.anyutil.*;
 import java.anyutil.function.*;
@@ -123,7 +125,10 @@
                             .map(i -> 1)
                             .reduce(0, Integer::sum, Integer::sum);
         assertEquals(count, 100000);
-        assertTrue(threads.size() >= 4);
+        if (ForkJoinPool.getCommonPoolParallelism() > 1) {
+            // No guarantee, may be flaky with loaded system
+            assertTrue(threads.size() > 1);
+        }
     }
 
     @Test(enabled = false)
@@ -136,7 +141,10 @@
                              .distinct()
                              .count();
         assertEquals(count, 1);
-        assertTrue(threads1.size() >= 4);
+        if (ForkJoinPool.getCommonPoolParallelism() > 1) {
+            // No guarantee, may be flaky with loaded system
+            assertTrue(threads1.size() > 1);
+        }
     }
 
 //    public void testLimit() {