[jboss-svn-commits] JBL Code SVN: r13353 - labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jul 11 06:55:45 EDT 2007


Author: adinn
Date: 2007-07-11 06:55:44 -0400 (Wed, 11 Jul 2007)
New Revision: 13353

Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java
Log:
partial resolution of JBTM-255 : upgraded reaper unit test to ensure that a wedged reaper worker thread detects it has been marked as a zombie and exits

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java	2007-07-11 09:53:23 UTC (rev 13352)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java	2007-07-11 10:55:44 UTC (rev 13353)
@@ -63,7 +63,7 @@
 	SlowReapable reapable1 = new SlowReapable(new Uid(), 2000, 0, true, true);
 	SlowReapable reapable2 = new SlowReapable(new Uid(), 0, 0, true, true);
 	SlowReapable reapable3 = new SlowReapable(new Uid(), 100, 2000, false, true);
-	SlowReapable reapable4 = new SlowReapable(new Uid(), 0, 0, false, false);
+	SlowReapable reapable4 = new SlowReapable(new Uid(), 1000, 1000, false, false);
 
 	// insert reapables so they timeout at 1 second intervals then
 	// check progress of cancellations and rollbacks
@@ -172,6 +172,23 @@
 
 	assertTrue(reapable4.getCancelTried());
 	assertTrue(reapable4.getRollbackTried());
+
+	// we should have a zombie worker so check that the thread
+	// which tried the cancel is still runnning then sleep a bit
+	// to give it time to complete and check it has exited
+
+	Thread worker = reapable4.getCancelThread();
+
+	assertTrue(worker.isAlive());
+
+	count = 0;
+
+	while (worker.isAlive() && count < 30) {
+	    count++;
+	    Thread.sleep(100);
+	}
+
+	assertTrue(count < 30);
     }
 
     public class SlowReapable implements Reapable
@@ -206,6 +223,11 @@
 
 	    setCancelTried();
 
+	    // track the worker trying to do the cancel so we can
+	    // detect if it becomes a zombie
+
+	    setCancelThread(Thread.currentThread());
+
 	    if (callDelay > 0) {
 		try {
 		    Thread.sleep(callDelay);
@@ -241,6 +263,7 @@
 	private boolean cancelTried;
 	private boolean rollbackTried;
 	private boolean running;
+	private Thread cancelThread;
 
 	public synchronized void setCancelTried()
 	{
@@ -250,6 +273,14 @@
 	{
 	    return cancelTried;
 	}
+	public synchronized void setCancelThread(Thread cancelThread)
+	{
+	    this.cancelThread = cancelThread;
+	}
+	public synchronized Thread getCancelThread()
+	{
+	    return cancelThread;
+	}
 	public synchronized void setRollbackTried()
 	{
 	    rollbackTried = true;




More information about the jboss-svn-commits mailing list