[jboss-cvs] JBossAS SVN: r57457 - branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 5 18:57:34 EDT 2006


Author: bstansberry at jboss.com
Date: 2006-10-05 18:57:33 -0400 (Thu, 05 Oct 2006)
New Revision: 57457

Modified:
   branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/DRMTestCase.java
Log:
Ensure the deployers get the semaphore

Modified: branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/DRMTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/DRMTestCase.java	2006-10-05 22:47:40 UTC (rev 57456)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/cluster/test/DRMTestCase.java	2006-10-05 22:57:33 UTC (rev 57457)
@@ -277,7 +277,7 @@
       DistributedReplicantManager.ReplicantListener listener;
       String key;
       Exception ex;
-      int count = 0;
+      int count = -1;
       Logger log;
       
       DeployerThread(MockDeployer deployer, 
@@ -346,7 +346,7 @@
       String[] keys;
       String nodeName;
       Exception ex;
-      int count;
+      int count = -1;
       int weightFactor;
       
       JGroupsThread(DistributedReplicantManagerImpl drm, 
@@ -1015,16 +1015,33 @@
          // Launch the threads
          semaphore.release(count + 1);
          
-         // Give the threads time to acquire the semaphore
-         sleepThread(100);
-         
          boolean reacquired = false;
          try
          {
+            // Give the threads 5 secs to acquire the semaphore
+            long maxElapsed = System.currentTimeMillis() + 5000;
+            for (int i = 0; i < keys.length; i++)
+            {
+               if (deployers[i].getCount() < 0)
+               {
+                  assertTrue("Thread " + keys[i] + " started in time",
+                              maxElapsed - System.currentTimeMillis() > 0);
+                  sleepThread(10);
+                  i--; // try again
+               }   
+            }
+            
+            while (jgThread.getCount() < 0)
+            {
+               assertTrue("jgThread started in time",
+                           maxElapsed - System.currentTimeMillis() > 0);
+               sleepThread(10);               
+            }
+            
             // Reaquire all the permits, thus showing the threads didn't deadlock
             
             // Give them 500 ms per loop
-            long maxElapsed = System.currentTimeMillis() + (500 * LOOP_COUNT);
+            maxElapsed = System.currentTimeMillis() + (500 * LOOP_COUNT);
             for (int i = 0; i <= count; i++)
             {
                long waitTime = maxElapsed - System.currentTimeMillis();
@@ -1083,7 +1100,7 @@
                {
                   deployers[i].interrupt();
                   sleepThread(5);
-                  printStackTrace(deployers[i].getName(), jgThread.getException());
+                  printStackTrace(deployers[i].getName(), deployers[i].getException());
                }
             }
                




More information about the jboss-cvs-commits mailing list