felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guilla...@apache.org
Subject svn commit: r1529782 - /felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java
Date Mon, 07 Oct 2013 07:56:31 GMT
Author: guillaume
Date: Mon Oct  7 07:56:31 2013
New Revision: 1529782

URL: http://svn.apache.org/r1529782
Log:
Try to stabilize concurrent TestCase
Lower assertions level (this is to dependent on the thread pool behavior and the OS).

Modified:
    felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java

Modified: felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java?rev=1529782&r1=1529781&r2=1529782&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java
(original)
+++ felix/trunk/ipojo/runtime/core/src/test/java/org/apache/felix/ipojo/extender/internal/queue/ExecutorQueueServiceTestCase.java
Mon Oct  7 07:56:31 2013
@@ -100,7 +100,12 @@ public class ExecutorQueueServiceTestCas
         ExecutorQueueService queueService = new ExecutorQueueService(m_bundleContext, 2);
         queueService.start();
 
-        // We create 4 job, so that we have the 2 first execution while the 2 others are
waiting
+        // Ensure we start at 0
+        assertEquals(0, queueService.getWaiters());
+        assertEquals(0, queueService.getCurrents());
+        assertEquals(0, queueService.getFinished());
+
+        // We create 4 job, so that we have the 2 first executed while the 2 others are waiting
         Future<String> one = queueService.submit(new SleepingCallable(50, "1"), m_callback,
"First");
         Future<String> two = queueService.submit(new SleepingCallable(50, "2"), m_callback,
"Second");
         Future<String> three = queueService.submit(new SleepingCallable(50, "3"), m_callback,
"Third");
@@ -109,12 +114,18 @@ public class ExecutorQueueServiceTestCas
         // Wait for callable to finish
         one.get();
         two.get();
-        assertEquals(2, queueService.getFinished());
-        assertEquals(2, queueService.getCurrents());
+
+        // Minimal assertion (do not test exact values)
+        assertTrue(queueService.getCurrents() > 0);
+        assertTrue(queueService.getFinished() > 0);
 
         three.get();
         four.get();
 
+        // Note: we cannot assert statistics reliably during the jobs execution: since when
one
+        // is finished, another queued one will be executed in a row...
+        // So we have to wait until the end of all executions and hope for the best.
+
         assertEquals(4, queueService.getFinished());
         assertEquals(0, queueService.getCurrents());
         assertEquals(0, queueService.getWaiters());



Mime
View raw message