[jboss-svn-commits] JBL Code SVN: r28045 - in labs/jbosstm/trunk/ArjunaJTA/jta: tests and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jul 15 07:47:39 EDT 2009


Author: adinn
Date: 2009-07-15 07:47:39 -0400 (Wed, 15 Jul 2009)
New Revision: 28045

Added:
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/byteman-scripts/
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/byteman-scripts/recovery.txt
Modified:
   labs/jbosstm/trunk/ArjunaJTA/jta/build.xml
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/CrashRecovery.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/RecoveryManagerTest.java
Log:
fixed CrashRecovery test to actually start recovery manager and scripted it using byteman so that the recovery pass runs while the TX is in mid-commit. also lowered recovery backoff wait in RecoveryManagerTest to avoid unnecessary delay in running test - fix for JBTM-576

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/build.xml	2009-07-15 11:09:27 UTC (rev 28044)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/build.xml	2009-07-15 11:47:39 UTC (rev 28045)
@@ -48,9 +48,19 @@
     </target>
 
     <target name="run.tests">
+        <!-- we need to run the CrashRecovery test using a byteman script -->
+        <run.tests.macro script="recovery.txt">
+            <tests>
+                <fileset dir="tests/classes" includes="**/recovery/CrashRecovery.java">
+                </fileset>
+            </tests>
+        </run.tests.macro>
         <run.tests.macro>
             <tests>
                 <fileset dir="tests/classes" includes="**/*.java">
+                    <!-- exclude tests which were run above using byteman scripts -->
+                    <exclude name="**/recovery/CrashRecovery.java"/>
+                    <!-- exclude tests which we don't want to run -->
                     <exclude name="**/common/**"/>
                     <exclude name="**/LastOnePhaseResource.java"/>
                     <exclude name="**/DummyXARecoveryResource.java"/>

Copied: labs/jbosstm/trunk/ArjunaJTA/jta/tests/byteman-scripts/recovery.txt (from rev 27952, labs/jbosstm/trunk/ArjunaCore/arjuna/tests/byteman-scripts/recovery.txt)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/byteman-scripts/recovery.txt	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/byteman-scripts/recovery.txt	2009-07-15 11:47:39 UTC (rev 28045)
@@ -0,0 +1,88 @@
+########################################################################
+#
+# byteman script used to ensure that tests can synchronize with various
+# actions performed by the recovery code
+
+#########################################################################
+# rules to identify progress of the periodic recovery listener thread
+#
+
+# if a test has set up a rendezvous under key "PR recovery pass begin" then
+# enter the rendezvous before starting the recovery run
+RULE periodic recovery rendezvous before recovery begin
+CLASS com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery
+METHOD doWorkInternal
+AT ENTRY
+BIND pr : PeriodicRecovery = $0
+IF isRendezvous("PR recovery pass begin", 2)
+DO debug("PR rendezvous at recovery pass begin @ " + System.currentTimeMillis()),
+   rendezvous("PR recovery pass begin")
+ENDRULE
+
+# if a test has set up a rendezvous under key "PR recovery pass end" then
+# enter the rendezvous after completing the recovery run
+RULE periodic recovery rendezvous after recovery end
+CLASS com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery
+METHOD doWorkInternal
+AT EXIT
+BIND pr : PeriodicRecovery = $0
+IF isRendezvous("PR recovery pass end", 2)
+DO debug("PR rendezvous at recovery pass end @ " + System.currentTimeMillis()),
+   rendezvous("PR recovery pass end")
+ENDRULE
+
+#########################################################################
+#
+# rules appropriate to specific tests
+
+#########################################################################
+# CrashRecovery wants periodic recovery to pause until the second
+# resource is told to commit and run a recovery scan at that point.
+# the commit should not return until the recovery scan has completed
+#
+
+# at test start create a rendezvous to be entered when the recovery thread
+# begins a recovery pass and another for when it ends. also create a CountDown
+# which will fire at the second call to countDown
+
+RULE CrashRecovery set up
+CLASS com.hp.mwtests.ts.jta.recovery.CrashRecovery
+METHOD test()
+AT ENTRY
+BIND NOTHING
+IF TRUE
+DO createRendezvous("PR recovery pass begin", 2),
+   createRendezvous("PR recovery pass end", 2),
+   addCountDown("CrashRecovery countdown", 1)
+ENDRULE
+
+# the second call to the resource commit method will count down
+# and fire this rule. the thread rendezvous with the PR thread
+# allowing it to perform a recovery scan and rendezvous again
+# ensuring that the commit call does not return until the scan has
+# completed
+RULE CrashRecovery rendezvous at commit
+CLASS com.hp.mwtests.ts.jta.common.CrashXAResource
+METHOD commit(Xid, boolean)
+AT ENTRY
+BIND NOTHING
+IF countDown("CrashRecovery countdown")
+DO debug("CrashRecovery rendezvous at recovery pass begin @ " + System.currentTimeMillis()),
+   rendezvous("PR recovery pass begin"),
+   debug("CrashRecovery rendezvous at recovery pass end @ " + System.currentTimeMillis()),
+   rendezvous("PR recovery pass end"),
+   RETURN
+ENDRULE
+
+# if the previous rule did not fire then we want to return
+# anyway to avoid the resource waiting
+
+RULE CrashRecovery don't sleep at commit
+CLASS com.hp.mwtests.ts.jta.common.CrashXAResource
+METHOD commit(Xid, boolean)
+AT CALL Thread.sleep
+BIND NOTHING
+IF TRUE
+DO RETURN
+ENDRULE
+

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/CrashRecovery.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/CrashRecovery.java	2009-07-15 11:09:27 UTC (rev 28044)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/CrashRecovery.java	2009-07-15 11:47:39 UTC (rev 28045)
@@ -32,6 +32,9 @@
 package com.hp.mwtests.ts.jta.recovery;
 
 import com.hp.mwtests.ts.jta.common.*;
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.common.Environment;
 
 import javax.transaction.xa.*;
 
@@ -43,6 +46,21 @@
     @Test
     public void test() throws Exception
     {
+        // this test is supposed to leave a record around in the log store during a commit long enough
+        // that the periodic recovery thread runs and detects it. rather than rely on delays to make
+        // this happen (placing us at the mercy of the schduler) we use a byteman script to enforce
+        // the thread sequence we need
+
+        // set the smallest possible backoff period so we don't have to wait too long for the test to run
+        
+        arjPropertyManager.getPropertyManager().setProperty(Environment.RECOVERY_BACKOFF_PERIOD, "1");
+
+        // start the recovery manager
+
+        RecoveryManager.manager().initialize();
+
+        // ok, now drive a TX to completion. the script should ensure that the recovery 
+
         XAResource firstResource = new CrashXAResource();
         XAResource secondResource = new CrashXAResource();
 

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/RecoveryManagerTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/RecoveryManagerTest.java	2009-07-15 11:09:27 UTC (rev 28044)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/RecoveryManagerTest.java	2009-07-15 11:47:39 UTC (rev 28045)
@@ -32,6 +32,7 @@
 package com.hp.mwtests.ts.jta.recovery;
 
 import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.common.Environment;
 
 import org.junit.Test;
 import static org.junit.Assert.*;
@@ -41,6 +42,7 @@
     @Test
     public void test()
     {
+        System.setProperty(Environment.RECOVERY_BACKOFF_PERIOD, "1");
         System.setProperty("com.arjuna.ats.jta.xaRecoveryNode", "1");
         System.setProperty("XAResourceRecovery1", "com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource");
 




More information about the jboss-svn-commits mailing list