[jboss-svn-commits] JBL Code SVN: r37621 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests: classes/com/arjuna/ats/jta/distributed and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 19 17:25:21 EDT 2011
Author: tomjenkinson
Date: 2011-10-19 17:25:20 -0400 (Wed, 19 Oct 2011)
New Revision: 37621
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/byteman-scripts/leaveorphan.txt
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
Log:
JBTM-895 updated to test that a failure in one phase commit with multiple resources on the subordinate can be detected as orphans
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/byteman-scripts/leaveorphan.txt
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/byteman-scripts/leaveorphan.txt 2011-10-19 20:18:14 UTC (rev 37620)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/byteman-scripts/leaveorphan.txt 2011-10-19 21:25:20 UTC (rev 37621)
@@ -26,3 +26,48 @@
DO debug("Target neutralized"),
Thread.currentThread().stop()
ENDRULE
+
+#########################################################################
+RULE Fail insertRecord
+CLASS com.arjuna.ats.arjuna.coordinator.BasicAction
+METHOD insertRecord
+AT ENTRY
+BIND NOTHING
+IF TRUE
+ DO debug("Target neutralized"),
+ Thread.currentThread().stop()
+ENDRULE
+
+#########################################################################
+RULE Fail topLevelPrepare
+CLASS com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord
+METHOD topLevelPrepare
+AT EXIT
+BIND NOTHING
+IF TRUE
+ DO debug("Target neutralized"),
+ Thread.currentThread().stop()
+ENDRULE
+
+#########################################################################
+RULE Fail topLevelPrepare
+CLASS com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord
+METHOD topLevelOnePhaseCommit
+AT EXIT
+BIND NOTHING
+IF TRUE
+ DO debug("Target neutralized"),
+ Thread.currentThread().stop()
+ENDRULE
+
+#########################################################################
+RULE Fail phase2Commit - die die die
+CLASS com.arjuna.ats.arjuna.coordinator.BasicAction
+METHOD phase2Commit
+AT ENTRY
+BIND NOTHING
+IF TRUE
+ DO debug("Assassinated"),
+ incrementCounter("phase2commit");
+ Thread.currentThread().stop()
+ENDRULE
\ No newline at end of file
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java 2011-10-19 20:18:14 UTC (rev 37620)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java 2011-10-19 21:25:20 UTC (rev 37621)
@@ -131,7 +131,7 @@
Xid currentXid = originalServer.getCurrentXid();
originalServer.storeRootTransaction();
transactionManager.suspend();
- performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid);
+ performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 1, false);
transactionManager.resume(originalTransaction);
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), 2000);
originalTransaction.enlistResource(proxyXAResource);
@@ -147,6 +147,12 @@
phase2CommitAborted.setPhase2CommitAborted(true);
phase2CommitAborted.notify();
}
+ } catch (LinkageError t) {
+ System.err.println("Should be a thread death but cest la vie");
+ synchronized (phase2CommitAborted) {
+ phase2CommitAborted.setPhase2CommitAborted(true);
+ phase2CommitAborted.notify();
+ }
} catch (Throwable t) {
t.printStackTrace();
}
@@ -180,6 +186,84 @@
}
@Test
+ @BMScript("leaveorphan")
+ public void testOnePhaseOrphan() throws Exception {
+ assertTrue(getLocalServer(3000).getCompletionCounter().getCommitCount() == 0);
+ assertTrue(getLocalServer(2000).getCompletionCounter().getCommitCount() == 0);
+ assertTrue(getLocalServer(1000).getCompletionCounter().getCommitCount() == 0);
+ final Phase2CommitAborted phase2CommitAborted = new Phase2CommitAborted();
+ Thread thread = new Thread(new Runnable() {
+ public void run() {
+ int startingTimeout = 0;
+ try {
+ int startingServer = 1000;
+ LocalServer originalServer = getLocalServer(startingServer);
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(originalServer.getClass().getClassLoader());
+ TransactionManager transactionManager = originalServer.getTransactionManager();
+ transactionManager.setTransactionTimeout(startingTimeout);
+ transactionManager.begin();
+ Transaction originalTransaction = transactionManager.getTransaction();
+ int remainingTimeout = (int) (originalServer.getTimeLeftBeforeTransactionTimeout() / 1000);
+ Xid currentXid = originalServer.getCurrentXid();
+ originalServer.storeRootTransaction();
+ transactionManager.suspend();
+ performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 2, false);
+ transactionManager.resume(originalTransaction);
+ XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), 2000);
+ originalTransaction.enlistResource(proxyXAResource);
+ originalServer.removeRootTransaction(currentXid);
+ transactionManager.commit();
+ Thread.currentThread().setContextClassLoader(classLoader);
+ } catch (ExecuteException e) {
+ System.err.println("Should be a thread death but cest la vie");
+ synchronized (phase2CommitAborted) {
+ phase2CommitAborted.setPhase2CommitAborted(true);
+ phase2CommitAborted.notify();
+ }
+ } catch (LinkageError t) {
+ System.err.println("Should be a thread death but cest la vie");
+ synchronized (phase2CommitAborted) {
+ phase2CommitAborted.setPhase2CommitAborted(true);
+ phase2CommitAborted.notify();
+ }
+ } catch (Throwable t) {
+ System.err.println("Should be a thread death but cest la vie");
+ synchronized (phase2CommitAborted) {
+ phase2CommitAborted.setPhase2CommitAborted(true);
+ phase2CommitAborted.notify();
+ }
+ }
+ }
+ }, "Orphan-creator");
+ thread.start();
+ synchronized (phase2CommitAborted) {
+ if (!phase2CommitAborted.isPhase2CommitAborted()) {
+ phase2CommitAborted.wait();
+ }
+ }
+ tearDown();
+ setup();
+ {
+
+ LocalServer server = getLocalServer(2000);
+ assertTrue(server.getCompletionCounter().getCommitCount() == 0);
+ assertTrue(server.getCompletionCounter().getRollbackCount() == 0);
+ server.doRecoveryManagerScan(true);
+ assertTrue(server.getCompletionCounter().getCommitCount() == 0);
+ assertTrue(server.getCompletionCounter().getRollbackCount() == 1);
+ }
+ {
+ LocalServer server = getLocalServer(1000);
+ assertTrue(server.getCompletionCounter().getCommitCount() == 0);
+ assertTrue(server.getCompletionCounter().getRollbackCount() == 0);
+ server.doRecoveryManagerScan(true);
+ assertTrue(server.getCompletionCounter().getCommitCount() == 0);
+ assertTrue(server.getCompletionCounter().getRollbackCount() == 0);
+ }
+ }
+
+ @Test
@BMScript("fail2pc")
public void testRecovery() throws Exception {
tearDown();
@@ -266,7 +350,7 @@
Xid currentXid = originalServer.getCurrentXid();
originalServer.storeRootTransaction();
transactionManager.suspend();
- performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid);
+ performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 1, false);
transactionManager.resume(originalTransaction);
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), 2000);
originalTransaction.enlistResource(proxyXAResource);
@@ -290,7 +374,7 @@
Xid currentXid = originalServer.getCurrentXid();
originalServer.storeRootTransaction();
transactionManager.suspend();
- performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid);
+ performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 1, false);
transactionManager.resume(originalTransaction);
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), 2000);
originalTransaction.enlistResource(proxyXAResource);
@@ -458,7 +542,7 @@
Xid currentXid = originalServer.getCurrentXid();
originalServer.storeRootTransaction();
transactionManager.suspend();
- performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
+ performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid, 1, true);
transactionManager.resume(originalTransaction);
originalServer.removeRootTransaction(currentXid);
if (commit) {
@@ -471,8 +555,9 @@
Thread.currentThread().setContextClassLoader(classLoader);
}
- private boolean performTransactionalWork(CompletionCounter counter, List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate)
- throws RollbackException, InvalidTransactionException, IllegalStateException, XAException, SystemException, NotSupportedException {
+ private boolean performTransactionalWork(CompletionCounter counter, List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate,
+ int numberOfResourcesToRegister, boolean addSynchronization) throws RollbackException, InvalidTransactionException, IllegalStateException,
+ XAException, SystemException, NotSupportedException {
Integer currentServerName = nodesToFlowTo.remove(0);
LocalServer currentServer = getLocalServer(currentServerName);
@@ -483,8 +568,12 @@
// Perform work on the migrated transaction
TransactionManager transactionManager = currentServer.getTransactionManager();
Transaction transaction = transactionManager.getTransaction();
- transaction.registerSynchronization(new TestSynchronization(currentServer.getNodeName()));
- transaction.enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
+ if (addSynchronization) {
+ transaction.registerSynchronization(new TestSynchronization(currentServer.getNodeName()));
+ }
+ for (int i = 0; i < numberOfResourcesToRegister; i++) {
+ transaction.enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
+ }
if (!nodesToFlowTo.isEmpty()) {
Integer nextServerNodeName = nodesToFlowTo.get(0);
@@ -495,7 +584,8 @@
// SUSPEND THE TRANSACTION
Xid currentXid = currentServer.getCurrentXid();
transactionManager.suspend();
- boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
+ boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid, numberOfResourcesToRegister,
+ addSynchronization);
transactionManager.resume(transaction);
// Create a proxy for the new server if necessary, this can orphan
More information about the jboss-svn-commits
mailing list