[jboss-cvs] JBossAS SVN: r92115 - branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 7 07:19:23 EDT 2009


Author: istudens at redhat.com
Date: 2009-08-07 07:19:23 -0400 (Fri, 07 Aug 2009)
New Revision: 92115

Modified:
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java
Log:
crash recovery tests now wait for longer time even if there is no unrecovered branch in AS but tx in doubt in DB, JBPAPP-2404

Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java	2009-08-07 11:00:31 UTC (rev 92114)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/crashrecovery/ASCrashRecovery01/TestWithJPA.java	2009-08-07 11:19:23 UTC (rev 92115)
@@ -54,7 +54,7 @@
 public class TestWithJPA extends JUnitClientTest
 {
    // the longest time to wait in millis before declaring a test a failed (overridable)
-   private static final int MAX_TEST_TIME = 180000;
+   private static final int MAX_TEST_TIME = 300000;     // 5 minutes  - allows two intervals of recovery which is 2 minutes by default
 
    private boolean isCMT = false;
    private boolean clientTx = false;
@@ -72,6 +72,7 @@
    private String storeType = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
    private TransactionLog store;
    private int existingUids;
+   private Set<RecoveredXid> existingXidsInDoubt;
 
    private String serverName = "default";
 
@@ -158,9 +159,9 @@
          if (wipeOutTxsInDoubtBeforeTest)
             wipeOutTxsInDoubt();
 
-         Set<RecoveredXid> xidsInDoubt = lookupCrashHelper().checkXidsInDoubt();
+         existingXidsInDoubt = lookupCrashHelper().checkXidsInDoubt();
          if (isDebug)
-            print(xidsInDoubt.size() + " txs in doubt in database before test run");
+            print(existingXidsInDoubt.size() + " txs in doubt in database before test run");
 
          // name of this test will be the primary key for test record in DB
          String testEntityPK = getName();
@@ -181,19 +182,12 @@
          }
          
          Set<RecoveredXid> xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
-         if (isDebug)
-            print(xidsInDoubtAfterTest.size() + " txs in doubt in database after test run");
-         if (xidsInDoubt.size() != xidsInDoubtAfterTest.size()) 
-         {
-            print((xidsInDoubtAfterTest.size() - xidsInDoubt.size()) + " new txs in doubt in database after this test run");
-         }
-         
          if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
-            wipeOutTxsInDoubt(xidsInDoubt, xidsInDoubtAfterTest);
+            wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
 
          assertTrue("Crash recovery failed.", result);
          assertTrue("Incorrect data in database after crash recovery.", dbChanged);
-         assertEquals("There are still unrecovered txs in database after crash recovery.", xidsInDoubt.size(), xidsInDoubtAfterTest.size());
+         assertEquals("There are still unrecovered txs in database after crash recovery.", existingXidsInDoubt.size(), xidsInDoubtAfterTest.size());
       }
       catch (Exception e)
       {
@@ -427,30 +421,46 @@
     */
    private boolean recoverUids() throws IOException
    {
-      int retryPeriod = 30000;
+      int retryPeriod = 60000;    // 1 minute 
       int maxWait = maxTestTime;
+      
+      Set<RecoveredXid> xidsInDoubtAfterTest;
       int pendingUids;
-
+      int pendingXidsInDoubt;
+      int totalExistingXidsInDoubt = existingXidsInDoubt.size();
+      
       // wait for the server to start up the first time through, we will need it for later database checking
-      suspendFor(2000);   // a little waiting is needed sometimes in order to start server again, 2 secs
+      suspendFor(2000);   // a little waiting is needed sometimes in order to be able to start server again, 2 secs
       config.startServer(serverName);
 
       do
       {
          pendingUids = getPendingUids();
+         try 
+         {
+            xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
+         }
+         catch (Exception e)
+         {
+            return false;
+         }
+         pendingXidsInDoubt = xidsInDoubtAfterTest.size();
 
          if (pendingUids == -1)
             return false;   // object store error
 
-         if (pendingUids <= existingUids)
-            return true;    // all uids recovered
+         if (pendingUids <= existingUids && pendingXidsInDoubt <= totalExistingXidsInDoubt)
+            return true;    // all uids in AS and txs in doubt in DB recovered
 
          pendingUids -= existingUids;
+         pendingXidsInDoubt -= totalExistingXidsInDoubt;
 
          print("waiting for " + pendingUids + " branches");
+         print("waiting for " + pendingXidsInDoubt + " txs in doubt");
 
          suspendFor(retryPeriod);
          maxWait -= retryPeriod;
+         
       } while (maxWait > 0);
 
       // the test failed to recover some uids - clear them out ready for the next test
@@ -463,6 +473,14 @@
          e.printStackTrace();
       }
 
+      if (pendingXidsInDoubt > 0) 
+      {
+         print(pendingXidsInDoubt + " new txs in doubt in database after the test");
+         
+         if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
+            wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
+      }
+      
       return false;
    }
 




More information about the jboss-cvs-commits mailing list