[jboss-cvs] JBossAS SVN: r105412 - in branches/JBPAPP_5_1/testsuite: imports/config and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 31 08:54:08 EDT 2010
Author: istudens at redhat.com
Date: 2010-05-31 08:54:06 -0400 (Mon, 31 May 2010)
New Revision: 105412
Added:
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery02/
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery02/TestWithJMS.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashBMTBean.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashCMTBean.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashHelper.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashRem.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/TestASRecoveryWithJMS.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CommonCrashHelper.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CrashHelperRem.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/RecoveredXid.java
Removed:
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelperRem.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashLocalHome.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashRemHome.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/RecoveredXid.java
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/xa-mq-destinations-service.xml
Modified:
branches/JBPAPP_5_1/testsuite/
branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml
branches/JBPAPP_5_1/testsuite/imports/sections/jbossts.xml
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/WipeOutTxsInDoubt.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashBMTBean.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/TestASRecoveryWithJPA.java
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml
Log:
jbossts crash recovery tests with JMS, JBQA-3370
Property changes on: branches/JBPAPP_5_1/testsuite
___________________________________________________________________
Name: svn:ignore
- .settings
output
build.log
run.tstamp
junit*.properties
20070819
20070821
+ .settings
output
build.log
run.tstamp
junit*.properties
20070819
20070821
.project_my
.classpath_my
Modified: branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml 2010-05-31 12:54:06 UTC (rev 105412)
@@ -17,7 +17,7 @@
-->
<!--
- | JBQA-2176 - JBossTS crash recovery tests.
+ | JBQA-2176 - JBossTS crash recovery tests with EJB3.
|
| Usage for all tests:
| ./build.sh tests-ts-crash-recovery
@@ -31,7 +31,7 @@
| Usage for cluster tests:
| ./build.sh tests-ts-crash-recovery -Djbossts.db=oracle_rac -Djbossts.tstype=jts -Djbossts.target=crash-tests-single-db-tstype
|
- | Added new option for setting of datasource credentials:
+ | Added new option for settings of datasource credentials:
| -Djbossts.credentials=cr1 - the default one
| <xa-datasource-property name="User">crashrec</xa-datasource-property>
| <xa-datasource-property name="Password">crashrec</xa-datasource-property>
@@ -50,9 +50,42 @@
|
| Note: If you want to force the wiping out any txs in doubt from DB before the test you can use the property -DwipeOutTxsInDoubtBeforeTest=true.
-->
- <target name="tests-ts-crash-recovery"
- description="Runs JBossTS crash recovery tests">
-
+ <target name="tests-ts-crash-recovery" depends="tests-ts-crash-recovery-jpa"
+ description="Runs JBossTS crash recovery tests" />
+
+ <target name="tests-ts-crash-recovery-jpa" depends="tests-ts-init-jpa, tests-ts-crash-recovery-common" />
+
+ <!--
+ | JBQA-3370 - JBossTS crash recovery tests with HornetQ / JBoss Messaging.
+ |
+ | Usage for all tests:
+ | ./build.sh tests-ts-crash-recovery-jms
+ |
+ | or for particular test scenario:
+ | ./build.sh tests-ts-crash-recovery-jms -Djbossts.tstype=jts -Djbossts.tsdemarc=cmt -Djbossts.testcase=commit_halt.rev -Djbossts.target=crash-tests-jms-single
+ |
+ | Use '-Djbossts.hornetq=true" to test the HornetQ.
+ |
+ | Note: If you want to force the wiping out any txs in doubt from DB before the test you can use the property -DwipeOutTxsInDoubtBeforeTest=true.
+ -->
+ <target name="tests-ts-crash-recovery-jms" depends="tests-ts-init-jms, tests-ts-crash-recovery-common" />
+
+
+ <target name="tests-ts-init-jpa">
+ <property name="jbossts.target" value="crash-tests" />
+ <property name="jbossts.credentials" value="cr1" />
+ <property name="astest.jar.name" value="crashrecovery-astest.jar" />
+ <property name="want.jpa" value="true" />
+ </target>
+
+ <target name="tests-ts-init-jms">
+ <property name="jbossts.target" value="crash-tests-jms" />
+ <property name="astest.jar.name" value="crashrecovery-jms-astest.jar" />
+ <property name="want.jms" value="true" />
+ </target>
+
+ <target name="tests-ts-crash-recovery-common">
+
<available file="${jboss.dist}/server/crashrecovery-jta" property="have.crashrecovery.jta.profile" value="true"/>
<available file="${jboss.dist}/server/crashrecovery-jts" property="have.crashrecovery.jts.profile" value="true"/>
<condition property="have.crash.recovery.profiles">
@@ -64,19 +97,15 @@
<antcall target="prepare-crashrec-profiles" />
- <property name="jbossts.target" value="crash-tests" />
<property name="jbossts.max.time" value="420000" />
- <property name="jbossts.credentials" value="cr1" />
-
-
<run-as-test target="${jbossts.target}" />
</target>
- <!--
- | Macros and others
- -->
+ <!--
+ | Macros and others
+ -->
<macrodef name="run-as-test">
<attribute name="target"/>
@@ -84,7 +113,7 @@
<echo message="starting of ${build.resources}/${jbossts.crash.recovery.test.script.dir}/as-tests.xml"/>
<java classname="org.apache.tools.ant.launch.Launcher" fork="true" failonerror="true">
<classpath>
- <pathelement location="${build.lib}/crashrecovery-astest.jar"/>
+ <pathelement location="${build.lib}/${astest.jar.name}"/>
<pathelement location="${ant.library.dir}/ant-launcher.jar"/>
<path refid="org.apache.ant.classpath"/>
<path refid="junit.junit.classpath"/>
@@ -99,7 +128,7 @@
<sysproperty key="jboss.home" value="${jbosstest.dist}" />
<sysproperty key="jboss.dist" value="${jboss.dist}" />
<sysproperty key="astest.jar.dir" value="${build.lib}" />
- <sysproperty key="astest.jar.name" value="crashrecovery-astest.jar" />
+ <sysproperty key="astest.jar.name" value="${astest.jar.name}" />
<sysproperty key="astest.jar.deploy.dir" value="../../lib" />
<sysproperty key="build.reports" value="${build.reports}" />
<sysproperty key="sm.legacy.shutdown" value="true" />
@@ -149,42 +178,48 @@
<property name="target.server.dir" location="${jboss.dist}/server/crashrecovery-jts"/>
</ant>
- <setup-crash-recovery conf="crashrecovery-jta"/>
- <setup-crash-recovery conf="crashrecovery-jts"/>
- <setup-security-domains conf="crashrecovery-jta"/>
- <setup-security-domains conf="crashrecovery-jts"/>
+ <antcall target="setup-recovery"><param name="conf" value="crashrecovery-jta"/></antcall>
+ <antcall target="setup-recovery"><param name="conf" value="crashrecovery-jts"/></antcall>
</target>
-
-
- <macrodef name="setup-crash-recovery">
- <attribute name="conf"/>
- <sequential>
- <echo message="Setting up crash recovery for profile @{conf}.."/>
- <!-- enable crash recovery and point it to our datasource -->
- <replace file="${jboss.dist}/server/@{conf}/conf/jbossts-properties.xml">
- <replacetoken><![CDATA[</transaction-service>]]></replacetoken>
- <replacevalue><![CDATA[
+
+
+ <target name="setup-recovery" depends="setup-recovery-jpa, setup-recovery-jms" />
+
+ <target name="setup-recovery-jpa" if="want.jpa">
+ <antcall target="setup-recovery-jbossts-jpa" />
+ <antcall target="setup-security-domains" />
+ </target>
+
+ <target name="setup-recovery-jms" if="want.jms">
+ <antcall target="setup-jms-jboss-messaging" />
+ <antcall target="setup-jms-hornetq" />
+ </target>
+
+
+ <target name="setup-recovery-jbossts-jpa">
+ <echo message="Setting up crash recovery for profile ${conf}.."/>
+ <!-- enable crash recovery and point it to our datasource -->
+ <replace file="${jboss.dist}/server/${conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[</transaction-service>]]></replacetoken>
+ <replacevalue><![CDATA[
<properties depends="arjuna" name="jta">
<!-- xaRecoveryNode should match value in nodeIdentifier or be * -->
<property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>
</properties>
</transaction-service>]]></replacevalue>
- </replace>
- <!-- more verbose logging -->
- <replace file="${jboss.dist}/server/@{conf}/conf/jbossts-properties.xml">
- <replacetoken><![CDATA[type="System" value="0x00000000"]]></replacetoken>
- <replacevalue><![CDATA[type="System" value="0xffffffff"]]></replacevalue>
- </replace>
- </sequential>
- </macrodef>
+ </replace>
+ <!-- more verbose logging -->
+ <replace file="${jboss.dist}/server/${conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[type="System" value="0x00000000"]]></replacetoken>
+ <replacevalue><![CDATA[type="System" value="0xffffffff"]]></replacevalue>
+ </replace>
+ </target>
- <macrodef name="setup-security-domains">
- <attribute name="conf"/>
- <sequential>
- <echo message="Setting up security domains for profile @{conf}.."/>
- <replace file="${jboss.dist}/server/@{conf}/conf/login-config.xml">
- <replacetoken><![CDATA[</policy>]]></replacetoken>
- <replacevalue><![CDATA[
+ <target name="setup-security-domains">
+ <echo message="Setting up security domains for profile ${conf}.."/>
+ <replace file="${jboss.dist}/server/${conf}/conf/login-config.xml">
+ <replacetoken><![CDATA[</policy>]]></replacetoken>
+ <replacevalue><![CDATA[
<application-policy name="CrashRecoveryDomain">
<authentication>
<login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
@@ -205,8 +240,78 @@
</authentication>
</application-policy>
</policy>]]></replacevalue>
- </replace>
- </sequential>
- </macrodef>
+ </replace>
+ </target>
+
+ <target name="setup-jms-jboss-messaging" unless="jbossts.hornetq">
+ <echo message="Setting up JBoss Messaging (queues, ...) for profile ${conf}.."/>
+ <replace file="${jboss.dist}/server/${conf}/deploy/messaging/destinations-service.xml">
+ <replacetoken><![CDATA[</server>]]></replacetoken>
+ <replacevalue><![CDATA[
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.messaging.destination:service=Queue,name=crashRecoveryQueue"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ <attribute name="SecurityConfig">
+ <security>
+ <role name="guest" read="true" write="true" create="true"/>
+ </security>
+ </attribute>
+ </mbean>
+</server>]]></replacevalue>
+ </replace>
+
+ <echo message="Setting up JBoss Messaging recovery for profile ${conf}.."/>
+ <!-- enable crash recovery and point it to a JMS provider -->
+ <replace file="${jboss.dist}/server/${conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[</transaction-service>]]></replacetoken>
+ <replacevalue><![CDATA[
+ <properties depends="arjuna" name="jta">
+ <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBMESSAGING1"
+ value="org.jboss.jms.server.recovery.MessagingXAResourceRecovery;java:/DefaultJMSProvider"/>
+ <!-- xaRecoveryNode should match value in nodeIdentifier or be * -->
+ <property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>
+ </properties>
+</transaction-service>]]></replacevalue>
+ </replace>
+ <!-- more verbose logging -->
+ <replace file="${jboss.dist}/server/${conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[type="System" value="0x00000000"]]></replacetoken>
+ <replacevalue><![CDATA[type="System" value="0xffffffff"]]></replacevalue>
+ </replace>
+ </target>
+
+ <target name="setup-jms-hornetq" if="jbossts.hornetq">
+ <echo message="Setting up HornetQ (queues, ...) for profile ${conf}.."/>
+ <replace file="${jboss.dist}/server/${conf}/deploy/hornetq/hornetq-jms.xml">
+ <replacetoken><![CDATA[</configuration>]]></replacetoken>
+ <replacevalue><![CDATA[
+ <queue name="crashRecoveryQueue">
+ <entry name="/queue/crashRecoveryQueue"/>
+ </queue>
+</configuration>]]></replacevalue>
+ </replace>
+
+ <echo message="Setting up HornetQ recovery for profile ${conf}.."/>
+ <!-- enable crash recovery -->
+ <replace file="${jboss.dist}/server/${conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[</transaction-service>]]></replacetoken>
+ <replacevalue><![CDATA[
+ <properties depends="arjuna" name="jta">
+ <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.HORNETQ1"
+ value="org.hornetq.jms.server.recovery.HornetQXAResourceRecovery;org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"/>
+ <!-- xaRecoveryNode should match value in nodeIdentifier or be * -->
+ <property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>
+ </properties>
+</transaction-service>]]></replacevalue>
+ </replace>
+ <!-- more verbose logging -->
+ <replace file="${jboss.dist}/server/${conf}/conf/jbossts-properties.xml">
+ <replacetoken><![CDATA[type="System" value="0x00000000"]]></replacetoken>
+ <replacevalue><![CDATA[type="System" value="0xffffffff"]]></replacevalue>
+ </replace>
+ </target>
+
</project>
Modified: branches/JBPAPP_5_1/testsuite/imports/sections/jbossts.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/sections/jbossts.xml 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/imports/sections/jbossts.xml 2010-05-31 12:54:06 UTC (rev 105412)
@@ -1,6 +1,6 @@
<project name="tests-jbossts-jars">
<!-- JBossTS tests -->
- <target name="_jars-jbossts" depends="jbqa2176"/>
+ <target name="_jars-jbossts" depends="jbqa2176, jbqa3370"/>
<!-- JBossTS crash recovery tests -->
<target name="jbqa2176" depends="compile">
@@ -19,4 +19,18 @@
</fileset>
</jar>
</target>
+
+ <target name="jbqa3370" depends="compile">
+ <jar destfile="${build.lib}/crashrecovery-jms-astest.jar">
+ <fileset dir="${build.resources}/jbossts/resources">
+ <include name="java.policy"/>
+ </fileset>
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/jbossts/ASCrashRecovery02/*.class"/>
+ <include name="org/jboss/test/jbossts/jms/*.class"/>
+ <include name="org/jboss/test/jbossts/recovery/*.class"/>
+ <include name="org/jboss/test/jbossts/taskdefs/*.class"/>
+ </fileset>
+ </jar>
+ </target>
</project>
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/TestWithJPA.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -21,13 +21,13 @@
package org.jboss.test.jbossts.ASCrashRecovery01;
import org.jboss.test.jbossts.recovery.ASFailureSpec;
+import org.jboss.test.jbossts.recovery.CrashHelperRem;
+import org.jboss.test.jbossts.recovery.RecoveredXid;
import org.jboss.test.jbossts.taskdefs.JUnitClientTest;
import org.jboss.test.jbossts.taskdefs.TransactionLog;
import org.jboss.test.jbossts.taskdefs.Utils;
import org.jboss.test.jbossts.crash.CrashHelper;
-import org.jboss.test.jbossts.crash.CrashHelperRem;
import org.jboss.test.jbossts.crash.CrashRem;
-import org.jboss.test.jbossts.crash.RecoveredXid;
import org.jboss.test.jbossts.crash.TestEntity;
import org.jboss.test.jbossts.crash.TestEntityHelper;
import org.jboss.test.jbossts.crash.TestEntityHelperRem;
@@ -47,7 +47,7 @@
import javax.transaction.UserTransaction;
/**
- * Crash recovery tests with one crash XA resource and one JPA entity resource.
+ * Crash recovery tests with EJB3 entity.
*
* @author <a href="istudens at redhat.com">Ivo Studensky</a>
* @version $Revision: 1.1 $
@@ -55,7 +55,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 = 300000; // 5 minutes - allows two intervals of recovery which is 2 minutes by default
+ private static final int MAX_TEST_TIME = 5 * 60 * 1000; // 5 minutes - allows two intervals of recovery which is 2 minutes by default
private boolean isCMT = false;
private boolean clientTx = false;
@@ -68,7 +68,7 @@
private int maxTestTime = MAX_TEST_TIME;
private String storeDir = null;
- private String storeImple = "com.arjuna.ats.internal.arjuna.objectstore.HashedActionStore";
+ private String storeImple = "HashedActionStore";
private String storeType = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
private TransactionLog store;
private int existingUids;
@@ -163,7 +163,7 @@
wipeOutTxsInDoubt();
existingXidsInDoubt = lookupCrashHelper().checkXidsInDoubt();
- if (isDebug)
+ if (existingXidsInDoubt.size() > 0)
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
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/WipeOutTxsInDoubt.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/WipeOutTxsInDoubt.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery01/WipeOutTxsInDoubt.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -20,16 +20,15 @@
*/
package org.jboss.test.jbossts.ASCrashRecovery01;
+import org.jboss.test.jbossts.recovery.CrashHelperRem;
import org.jboss.test.jbossts.taskdefs.JUnitClientTest;
import org.jboss.test.jbossts.crash.CrashHelper;
-import org.jboss.test.jbossts.crash.CrashHelperRem;
import org.apache.tools.ant.BuildException;
import java.util.Map;
/**
- * Helper test just for wiping out of txs in doubt from DB.
- * It can be called via the as-tests.xml script.
+ * Helper test just for wiping out in-doubt txs from DB.
*
* @author <a href="istudens at redhat.com">Ivo Studensky</a>
* @version $Revision: 1.1 $
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery02/TestWithJMS.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery02/TestWithJMS.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/ASCrashRecovery02/TestWithJMS.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,520 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.jbossts.ASCrashRecovery02;
+
+import org.jboss.test.jbossts.recovery.ASFailureSpec;
+import org.jboss.test.jbossts.recovery.CrashHelperRem;
+import org.jboss.test.jbossts.recovery.RecoveredXid;
+import org.jboss.test.jbossts.taskdefs.JUnitClientTest;
+import org.jboss.test.jbossts.taskdefs.TransactionLog;
+import org.jboss.test.jbossts.taskdefs.Utils;
+import org.jboss.test.jbossts.jms.JMSCrashHelper;
+import org.jboss.test.jbossts.jms.JMSCrashRem;
+import org.jboss.remoting.CannotConnectException;
+import org.apache.tools.ant.BuildException;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.EJBTransactionRolledbackException;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+/**
+ * Crash recovery tests with JMS.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestWithJMS extends JUnitClientTest
+{
+ // the longest time to wait in millis before declaring a test a failed (overridable)
+ private static final int MAX_TEST_TIME = 5 * 60 * 1000; // 5 minutes - allows two intervals of recovery which is 2 minutes by default
+
+ private boolean isCMT = false;
+ private boolean clientTx = false;
+ private boolean expectFailure = false;
+ private boolean reverseOrder = false;
+ private boolean rollbackExpected = false;
+ private boolean wipeOutTxsInDoubt = false;
+ private boolean wipeOutTxsInDoubtBeforeTest = false;
+ private boolean wipeOutTxsInDoubtAfterTest = false;
+ private int maxTestTime = MAX_TEST_TIME;
+
+ private String storeDir = null;
+ private String storeImple = "HashedActionStore";
+ private String storeType = "StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
+ private TransactionLog store;
+ private int existingUids;
+ private Set<RecoveredXid> existingXidsInDoubt;
+
+ private String serverName = "default";
+
+
+ public void testAction()
+ {
+ if (config == null || params == null)
+ throw new UnsupportedOperationException("The test has not been initiated yet. Call the init() method first.");
+
+ StringBuilder sb = new StringBuilder();
+ ASFailureSpec[] fspecs = null;
+
+ for (Map.Entry<String, String> me : params.entrySet())
+ {
+ String key = me.getKey().trim();
+ String val = me.getValue().trim();
+
+ if ("name".equals(key))
+ setName(val);
+ else if ("cmt".equals(key))
+ isCMT = val.equalsIgnoreCase("true");
+ else if ("debug".equals(key))
+ isDebug = val.equalsIgnoreCase("true");
+ else if ("serverName".equals(key))
+ serverName = val;
+ else if ("storeType".equals(key))
+ storeType = val;
+ else if ("storeDir".equals(key))
+ storeDir = val;
+ else if ("clientTx".equals(key))
+ clientTx = val.equalsIgnoreCase("true");
+ else if ("storeImple".equals(key))
+ storeImple = val;
+ else if ("testTime".equals(key))
+ maxTestTime = Utils.parseInt(val, "parameter testTime should represent a number of miliseconds: ");
+ else if ("specs".equals(key))
+ fspecs = parseSpecs(val, sb);
+ else if ("wait".equals(key))
+ suspendFor(Integer.parseInt(val));
+ else if ("reverseOrder".equals(key))
+ reverseOrder = val.equalsIgnoreCase("true");
+ else if ("rollbackExpected".equals(key))
+ rollbackExpected = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubt".equals(key))
+ wipeOutTxsInDoubt = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubtBeforeTest".equals(key))
+ wipeOutTxsInDoubtBeforeTest = val.equalsIgnoreCase("true");
+ else if ("wipeOutTxsInDoubtAfterTest".equals(key))
+ wipeOutTxsInDoubtAfterTest = val.equalsIgnoreCase("true");
+ }
+
+ sb.insert(0, ":\n").insert(0, getName()).insert(0, "Executing test ");
+
+ System.out.println(sb);
+
+ try
+ {
+ String serverPath = config.getServerPath(serverName);
+
+ // get a handle to the transaction logs
+ if (storeDir == null)
+ storeDir = serverPath + "data/tx-object-store";
+ else
+ storeDir = serverPath + storeDir;
+ System.out.println("transaction log will be stored in " + storeDir + "(file=" + storeImple+")");
+ store = new TransactionLog(storeDir, storeImple);
+
+ if (expectFailure)
+ {
+ // this test may halt the VM so make sure the transaction log is empty
+ // before starting the test - then the pass/fail check is simply to
+ // test whether or not the log is empty (see recoverUids() below).
+ try
+ {
+ store.clearXids(storeType);
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ }
+
+ existingUids = getPendingUids();
+
+ if (wipeOutTxsInDoubtBeforeTest)
+ wipeOutTxsInDoubt();
+
+ existingXidsInDoubt = lookupCrashHelper().checkXidsInDoubt();
+ if (existingXidsInDoubt.size() > 0)
+ print(existingXidsInDoubt.size() + " txs in doubt before test run");
+
+ String message = getName();
+
+ // run the crash test
+ boolean result = crashTest(message, fspecs, reverseOrder);
+ print("crashTest result: " + result);
+
+ // checking the state of JMS after recovering
+ boolean jmsResult = true;
+ if (result)
+ {
+ jmsResult = checkJMS(message);
+ print("checkJMS result: " + jmsResult);
+ }
+
+ Set<RecoveredXid> xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
+ if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
+ wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
+
+ assertTrue("Crash recovery failed.", result);
+ assertTrue("Incorrect JMS state after crash recovery.", jmsResult);
+ assertEquals("There are still unrecovered txs in JMS after crash recovery.", existingXidsInDoubt.size(), xidsInDoubtAfterTest.size());
+ }
+ catch (Exception e)
+ {
+ if (isDebug)
+ e.printStackTrace();
+
+ throw new BuildException(e);
+ }
+ }
+
+ private boolean checkJMS(String sentMessage)
+ {
+ String receivedMessage = null;
+
+ try
+ {
+ receivedMessage = receiveMessage();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+
+ return (rollbackExpected) ? (receivedMessage == null) : sentMessage.equals(receivedMessage);
+ }
+
+ private String receiveMessage() throws Exception
+ {
+ Context context = null;
+ Connection connection = null;
+ try
+ {
+ context = config.getNamingContext(serverName);
+
+ ConnectionFactory cf = (ConnectionFactory) context.lookup("/ConnectionFactory");
+
+ Queue queue = (Queue) context.lookup("queue/crashRecoveryQueue");
+
+ connection = cf.createConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer = session.createConsumer(queue);
+
+ connection.start();
+
+ print("waiting to receive a message from queue/crashRecoveryQueue...");
+ TextMessage message = (TextMessage) consumer.receive(5 * 1000);
+
+ if (isDebug)
+ print("received message: " + ((message != null) ? message.getText() : message));
+
+ return (message != null) ? message.getText() : null;
+ }
+ catch (Exception e)
+ {
+ print("Error in receiving a message: " + e);
+ e.printStackTrace();
+ throw e;
+ }
+ finally
+ {
+ if (connection != null)
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ private boolean crashTest(String message, ASFailureSpec[] sa, boolean reverseOrder) throws Exception
+ {
+ UserTransaction tx = null;
+
+ try
+ {
+ JMSCrashRem cr = lookupCrashBean(isCMT ? JMSCrashRem.CMT_JNDI_NAME : JMSCrashRem.BMT_JNDI_NAME);
+
+ if (clientTx)
+ tx = startTx();
+
+ String res = cr.testXA(message, reverseOrder, sa);
+
+ return "Passed".equalsIgnoreCase(res);
+ }
+ catch (CannotConnectException e)
+ {
+ if (expectFailure)
+ {
+ print("Failure was expected: " + e.getMessage());
+
+ return recoverUids();
+ }
+ else
+ {
+ System.err.println("XACrashTest:crashTest: Caught[1] " + e);
+
+ e.printStackTrace();
+ }
+ }
+ catch (EJBTransactionRolledbackException re)
+ {
+ // try to recover, this failure was expected maybe?!
+ print("Failure was expected (maybe): " + re.getMessage());
+
+ return recoverUids();
+ }
+ catch (RuntimeException re)
+ {
+ if (re.getCause() instanceof HeuristicMixedException)
+ {
+ // try to recover, this failure was expected maybe?!
+ print("Failure was expected (maybe): " + re.getMessage());
+
+ return recoverUids();
+ }
+ else
+ {
+ System.err.println("XACrashTest:crashTest: Caught[2] " + re);
+ re.printStackTrace();
+ }
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ System.err.println("XACrashTest:crashTest: Caught[3] " + t);
+ }
+ finally {
+ if (clientTx)
+ try
+ {
+ tx.commit();
+ }
+ catch (Throwable e)
+ {
+ System.out.println("User tx commit failure: " + e.getMessage());
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Wait for any pending transactions to recover by restarting the AS.
+ * @return true if all pending branches have been recovered
+ * @throws IOException if the server cannot be started
+ */
+ private boolean recoverUids() throws IOException
+ {
+ 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 checking
+ suspendFor(2000); // short waiting is needed sometimes in order to be able to start the server again, 2 secs
+ config.startServer(serverName);
+
+ do
+ {
+ pendingUids = getPendingUids();
+ try
+ {
+ xidsInDoubtAfterTest = lookupCrashHelper().checkXidsInDoubt();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return false;
+ }
+ pendingXidsInDoubt = xidsInDoubtAfterTest.size();
+
+ if (pendingUids == -1)
+ {
+ print("recoverUids failed, object store error, pendingUids == -1");
+ return false; // object store error
+ }
+ if (pendingUids <= existingUids && pendingXidsInDoubt <= totalExistingXidsInDoubt)
+ {
+ print("recoverUids success");
+ return true; // all uids in AS recovered
+ }
+ pendingUids -= existingUids;
+ pendingXidsInDoubt -= totalExistingXidsInDoubt;
+
+ print("waiting for " + pendingUids + " branches");
+ print("waiting for " + pendingXidsInDoubt + " txs in doubt");
+
+ suspendFor(retryPeriod);
+ maxWait -= retryPeriod;
+
+ } while (maxWait > 0);
+
+ print("recoverUids failed, took too long to recover");
+
+ // the test failed to recover some uids - clear them out ready for the next test
+ if (pendingUids > 0)
+ {
+ try
+ {
+ store.clearXids(storeType);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ // the test failed to recover some xids in JMS - clear them out ready for the next test
+ if (pendingXidsInDoubt > 0)
+ {
+ print(pendingXidsInDoubt + " new txs in doubt after the test");
+
+ if (wipeOutTxsInDoubt || wipeOutTxsInDoubtAfterTest)
+ wipeOutTxsInDoubt(existingXidsInDoubt, xidsInDoubtAfterTest);
+ }
+
+ return false;
+ }
+
+ /**
+ * Wipes out all the txs in doubt.
+ *
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt()
+ {
+ // wipes out all txs in doubt
+ return wipeOutTxsInDoubt(null);
+ }
+
+ /**
+ * Wipes out only new txs in doubt after test run.
+ *
+ * @param xidsInDoubtBeforeTest txs in doubt before test run
+ * @param xidsInDoubtBeforeTest txs in doubt after test run
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsInDoubtBeforeTest, Set<RecoveredXid> xidsInDoubtAfterTest)
+ {
+ Set<RecoveredXid> xidsToRecover = new HashSet<RecoveredXid>(xidsInDoubtAfterTest);
+ xidsToRecover.removeAll(xidsInDoubtBeforeTest);
+
+ if (xidsToRecover.isEmpty())
+ return true;
+
+ return wipeOutTxsInDoubt(xidsToRecover);
+ }
+
+ /**
+ * Wipes out txs in doubt according to a xidsToRecover list.
+ *
+ * @param xidsToRecover list of xids to recover
+ * @return true in success, fail otherwise
+ */
+ private boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
+ {
+ print("wiping out txs in doubt");
+ try
+ {
+ lookupCrashHelper().wipeOutTxsInDoubt(xidsToRecover);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ private ASFailureSpec[] parseSpecs(String specArg, StringBuilder sb)
+ {
+ ASFailureSpec[] fspecs = config.parseSpecs(specArg);
+
+ for (ASFailureSpec spec : fspecs)
+ {
+ String name = (spec == null ? "INVALID" : spec.getName());
+
+ if (spec != null && spec.willTerminateVM())
+ expectFailure = true;
+
+ sb.append("\t").append(name).append('\n');
+ }
+
+ return fspecs;
+ }
+
+ // count how many pending transaction branches there are in the transaction log
+ private int getPendingUids()
+ {
+ try
+ {
+ return store.getIds(storeType).size();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+
+ return -1;
+ }
+ }
+
+ private JMSCrashRem lookupCrashBean(String name) throws Exception
+ {
+ return (JMSCrashRem) config.getNamingContext(serverName).lookup(name);
+ }
+
+ private CrashHelperRem lookupCrashHelper() throws Exception
+ {
+ return (CrashHelperRem) config.getNamingContext(serverName).lookup(JMSCrashHelper.REMOTE_JNDI_NAME);
+ }
+
+ private UserTransaction startTx() throws NamingException, SystemException, NotSupportedException
+ {
+ UserTransaction tx = (UserTransaction) config.getNamingContext(serverName).lookup("UserTransaction");
+
+ tx.begin();
+
+ return tx;
+ }
+
+}
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashBMTBean.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashBMTBean.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashBMTBean.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -28,8 +28,6 @@
import javax.annotation.Resource;
import javax.ejb.EJBContext;
import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.transaction.SystemException;
@@ -45,13 +43,11 @@
@Resource
private EJBContext context;
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public String testXA(String ... args)
{
return "Passed";
}
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public String testXA(ASFailureSpec... specs)
{
TestASRecovery xatest = new TestASRecovery();
@@ -68,17 +64,16 @@
return xatest.startTest() ? "Passed" : "Failed";
}
- @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public String testXA(String testEntityPK, boolean reverseOrder, ASFailureSpec... specs)
{
+ log.info("BMT testXA called with " + specs.length + " specs and testEntityPK=" + testEntityPK + " reverseOrder=" + reverseOrder);
+
TestASRecoveryWithJPA xatest = new TestASRecoveryWithJPA();
String txStatus = getStatus(context.getUserTransaction());
if (txStatus != null)
- log.info("BMT method called with tx status: " + txStatus);
+ log.info("BMT testXA called with tx status: " + txStatus);
- log.info("BMT testXA called with " + specs.length + " specs and testEntityPK=" + testEntityPK + " reverseOrder=" + reverseOrder);
-
xatest.setTestEntityPK(testEntityPK);
xatest.setReverseOrder(reverseOrder);
@@ -87,8 +82,8 @@
return xatest.startTest() ? "Passed" : "Failed";
}
-
- public String getStatus(UserTransaction tx)
+
+ protected String getStatus(UserTransaction tx)
{
if (tx == null)
return null;
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -22,18 +22,12 @@
package org.jboss.test.jbossts.crash;
import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.Set;
-import javax.ejb.EJBException;
import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import org.jboss.logging.Logger;
+import org.jboss.test.jbossts.recovery.CommonCrashHelper;
+import org.jboss.test.jbossts.recovery.CrashHelperRem;
/**
@@ -43,10 +37,9 @@
* @version $Revision: 1.1 $
*/
@Stateless
-public class CrashHelper implements CrashHelperRem
+public class CrashHelper extends CommonCrashHelper implements CrashHelperRem
{
- public static final String REMOTE_JNDI_NAME = CrashHelper.class.getSimpleName() + "/remote";
- private static Logger log = Logger.getLogger(CrashHelper.class);
+ public static final String REMOTE_JNDI_NAME = CrashHelper.class.getSimpleName() + "/remote";
/**
* JNDI name of crash recovery datasource.
@@ -57,15 +50,12 @@
/**
- * Wipes out xids in doubt from database ({@link #DS_JNDI_NAME}) according to
- * <code>xidToRecover</code> list. If xidToRecover is null, it wipes out all xids in doubt.
- *
- * @param xidToRecover list of Xids to recover
+ * Gets XAResource for a datasource with name ({@link #DS_JNDI_NAME}).
*/
- @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
- public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
+ @Override
+ protected XAResource getNewXAResource()
{
- log.info("wipe out txs in doubt");
+ XAResource xares = null;
try
{
AppServerJDBCXARecovery appServerRecovery = new AppServerJDBCXARecovery();
@@ -74,141 +64,22 @@
{
if (appServerRecovery.hasMoreResources())
{
- XAResource xares = appServerRecovery.getXAResource();
-
- Xid[] txInDoubt = null;
- try
- {
- txInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
- }
- catch (XAException e)
- {
- log.error("Cannot start recovering on xares", e);
-
- try
- {
- xares.recover(XAResource.TMENDRSCAN);
- }
- catch (Exception e1)
- {
- }
-
- return false;
- }
-
- if (txInDoubt == null || txInDoubt.length == 0)
- return true;
-
- log.info("There are " + txInDoubt.length + " xids in doubt");
-
- for (int k=0; k < txInDoubt.length; k++)
- {
- RecoveredXid xid = convertToRecoveredXid(txInDoubt[k]);
- if (xidsToRecover == null || xidsToRecover.contains(xid))
- {
- try
- {
- log.info("rollbacking of Xid " + xid);
- xares.rollback(txInDoubt[k]);
- }
- catch (Exception e)
- {
- log.error("Error in rollback of Xid " + txInDoubt[k], e);
- }
- }
- }
-
- try
- {
- if (xares != null)
- xares.recover(XAResource.TMENDRSCAN);
- }
- catch (XAException e)
- {
- log.error("Cannot finish recovering on xares", e);
- }
+ xares = appServerRecovery.getXAResource();
}
}
}
catch (SQLException e)
{
log.error("Cannot get any XAResource by AppServerJDBCXARecovery", e);
- return false;
}
-
- return true;
+
+ return xares;
}
- /**
- * Checks xids in doubt in datasource with {@link #DS_JNDI_NAME}.
- *
- * @return number of xids in doubt
- */
- @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
- public Set<RecoveredXid> checkXidsInDoubt()
+ @Override
+ protected void closeXAResource()
{
- Set<RecoveredXid> xids = new HashSet<RecoveredXid>();
- try
- {
- AppServerJDBCXARecovery appServerRecovery = new AppServerJDBCXARecovery();
-
- if (appServerRecovery.initialise("jndiname=" + DS_JNDI_NAME))
- {
- if (appServerRecovery.hasMoreResources())
- {
- XAResource xares = appServerRecovery.getXAResource();
-
- try
- {
- Xid[] xidsInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
-
- if (xidsInDoubt != null)
- {
- log.info("There are " + xidsInDoubt.length + " xids in doubt");
-
- for (int k=0; k < xidsInDoubt.length; k++)
- xids.add(convertToRecoveredXid(xidsInDoubt[k]));
- }
- }
- catch (XAException e)
- {
- log.error("Cannot start recover scan on xares", e);
- throw new EJBException("Cannot start recover scan on xares: " + e.getMessage());
- }
- finally
- {
- try
- {
- if (xares != null)
- xares.recover(XAResource.TMENDRSCAN);
- }
- catch (XAException e)
- {
- log.error("Cannot finish recover scan on xares", e);
- }
- }
- }
- }
- }
- catch (SQLException e)
- {
- log.error("Cannot get any XAResource by AppServerJDBCXARecovery", e);
- // cannot include the original exception into this thrown exception as it requires jdbc drivers also on the client side
- throw new EJBException("Cannot get any XAResource by AppServerJDBCXARecovery: " + e.getMessage());
- }
-
- return xids;
+ // Nothing to do here. Is it alright?
}
- private RecoveredXid convertToRecoveredXid(Xid xid)
- {
- RecoveredXid recoveredXid = new RecoveredXid();
-
- recoveredXid.setBranchQualifier(xid.getBranchQualifier());
- recoveredXid.setFormatId(xid.getFormatId());
- recoveredXid.setGlobalTransactionId(xid.getGlobalTransactionId());
-
- return recoveredXid;
- }
-
}
Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelperRem.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelperRem.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelperRem.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.jbossts.crash;
-
-import java.util.Set;
-
-import javax.ejb.Remote;
-
- at Remote
-public interface CrashHelperRem
-{
- public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover);
- public Set<RecoveredXid> checkXidsInDoubt();
-}
Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashLocalHome.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashLocalHome.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashLocalHome.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -1,28 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2008,
- * @author JBoss Inc.
- */
-package org.jboss.test.jbossts.crash;
-
-import javax.ejb.EJBLocalHome;
-import javax.ejb.CreateException;
-
-public interface CrashLocalHome extends EJBLocalHome {
- CrashLocal create() throws CreateException;
-}
Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashRemHome.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashRemHome.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashRemHome.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2008,
- * @author JBoss Inc.
- */
-package org.jboss.test.jbossts.crash;
-
-import javax.ejb.EJBHome;
-import javax.ejb.CreateException;
-import java.rmi.RemoteException;
-
-public interface CrashRemHome extends EJBHome {
- CrashRem create() throws CreateException, RemoteException;
-}
Deleted: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/RecoveredXid.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/RecoveredXid.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/RecoveredXid.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.jbossts.crash;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-public class RecoveredXid implements Serializable
-{
- private byte[] branchQualifier;
- private int formatId;
- private byte[] globalTransactionId;
-
- public RecoveredXid()
- {
- }
-
- public byte[] getBranchQualifier()
- {
- return branchQualifier;
- }
-
- public void setBranchQualifier(byte[] branchQualifier)
- {
- this.branchQualifier = branchQualifier;
- }
-
- public int getFormatId()
- {
- return formatId;
- }
-
- public void setFormatId(int formatId)
- {
- this.formatId = formatId;
- }
-
- public byte[] getGlobalTransactionId()
- {
- return globalTransactionId;
- }
-
- public void setGlobalTransactionId(byte[] globalTransactionId)
- {
- this.globalTransactionId = globalTransactionId;
- }
-
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + Arrays.hashCode(branchQualifier);
- result = prime * result + formatId;
- result = prime * result + Arrays.hashCode(globalTransactionId);
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- RecoveredXid other = (RecoveredXid) obj;
- if (!Arrays.equals(branchQualifier, other.branchQualifier))
- return false;
- if (formatId != other.formatId)
- return false;
- if (!Arrays.equals(globalTransactionId, other.globalTransactionId))
- return false;
- return true;
- }
-
- @Override
- /**
- * Only for debugging purposes.
- */
- public String toString()
- {
- return "RecoveredXid [branchQualifier=" + Arrays.toString(branchQualifier) + ", formatId=" + formatId
- + ", globalTransactionId=" + Arrays.toString(globalTransactionId) + "]";
- }
-
-}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashBMTBean.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashBMTBean.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashBMTBean.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.jbossts.jms;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.jbossts.recovery.ASFailureSpec;
+
+import javax.annotation.Resource;
+import javax.ejb.EJBContext;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
+
+ at Stateless
+ at TransactionManagement(TransactionManagementType.BEAN)
+public class JMSCrashBMTBean implements JMSCrashRem {
+ private static Logger log = Logger.getLogger(JMSCrashBMTBean.class);
+
+ @Resource
+ private EJBContext context;
+
+ public String testXA(String message, boolean reverseOrder, ASFailureSpec... specs)
+ {
+ log.info("BMT testXA called with " + specs.length + " specs and message=" + message + " and reverseOrder=" + reverseOrder);
+
+ TestASRecoveryWithJMS xatest = new TestASRecoveryWithJMS();
+ String txStatus = getStatus(context.getUserTransaction());
+
+ if (txStatus != null)
+ log.info("BMT testXA called with tx status: " + txStatus);
+
+ xatest.setReverseOrder(reverseOrder);
+ xatest.setMessage(message);
+
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ return xatest.startTest() ? "Passed" : "Failed";
+ }
+
+
+ protected String getStatus(UserTransaction tx)
+ {
+ if (tx == null)
+ return null;
+
+ try
+ {
+ return org.jboss.tm.TxUtils.getStatusAsString(tx.getStatus());
+ }
+ catch (SystemException e)
+ {
+ return "tx status error: " + e.getMessage();
+ }
+ }
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashCMTBean.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashCMTBean.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashCMTBean.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.jbossts.jms;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.jbossts.recovery.ASFailureSpec;
+
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.transaction.Transaction;
+
+ at Stateless
+public class JMSCrashCMTBean implements JMSCrashRem {
+ private static Logger log = Logger.getLogger(JMSCrashCMTBean.class);
+
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ public String testXA(String message, boolean reverseOrder, ASFailureSpec... specs)
+ {
+ log.info("CMT testXA called with " + specs.length + " specs and message=" + message + " and reverseOrder=" + reverseOrder);
+
+ TestASRecoveryWithJMS xatest = new TestASRecoveryWithJMS();
+ Transaction tx;
+
+ try
+ {
+ tx = com.arjuna.ats.jta.TransactionManager.transactionManager().getTransaction();
+ }
+ catch (javax.transaction.SystemException e)
+ {
+ tx = null;
+ }
+
+ if (tx == null)
+ {
+ log.error("CMT testXA called without a transaction");
+
+ return "Failed";
+ }
+ else
+ {
+ xatest.setReverseOrder(reverseOrder);
+ xatest.setMessage(message);
+
+ for (ASFailureSpec spec : specs)
+ xatest.addResource(spec);
+
+ return xatest.startTest(tx) ? "Passed" : "Failed";
+ }
+ }
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashHelper.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashHelper.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashHelper.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jbossts.jms;
+
+import javax.ejb.EJBException;
+import javax.ejb.Stateless;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.naming.InitialContext;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.test.jbossts.recovery.CommonCrashHelper;
+import org.jboss.test.jbossts.recovery.CrashHelperRem;
+
+
+/**
+ * Helper class for playing with in-doubt txs on JMS.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class JMSCrashHelper extends CommonCrashHelper implements CrashHelperRem
+{
+ public static final String REMOTE_JNDI_NAME = JMSCrashHelper.class.getSimpleName() + "/remote";
+
+ private XAConnection xaConnection = null;
+
+ @Override
+ protected XAResource getNewXAResource()
+ {
+ try
+ {
+ if (xaConnection == null)
+ {
+ InitialContext ic = new InitialContext();
+ XAConnectionFactory xacf = (XAConnectionFactory) ic.lookup("java:/XAConnectionFactory");
+
+ xaConnection = xacf.createXAConnection();
+ }
+
+ XASession session = xaConnection.createXASession();
+
+ return session.getXAResource();
+ }
+ catch (Exception e)
+ {
+ log.warn("Cannot create new XA resource", e);
+ throw new EJBException("Cannot create new XA resource: " + e.getMessage());
+ }
+ }
+
+ // Should not throw out any exception.
+ @Override
+ protected void closeXAResource()
+ {
+ if (xaConnection != null)
+ {
+ try
+ {
+ xaConnection.close();
+ }
+ catch (Exception e)
+ {
+ log.warn("Cannot close jms xa connection", e);
+ }
+ xaConnection = null;
+ }
+ }
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashRem.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashRem.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/JMSCrashRem.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package org.jboss.test.jbossts.jms;
+
+import org.jboss.test.jbossts.recovery.ASFailureSpec;
+
+import javax.ejb.Remote;
+
+ at Remote
+public interface JMSCrashRem {
+ // JNDI names of the fault injection beans
+ String BMT_JNDI_NAME = "JMSCrashBMTBean/remote";
+ String CMT_JNDI_NAME = "JMSCrashCMTBean/remote";
+
+ String testXA(String message, boolean reverseOrder, ASFailureSpec... specs);
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/TestASRecoveryWithJMS.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/TestASRecoveryWithJMS.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/jms/TestASRecoveryWithJMS.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jbossts.jms;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.transaction.Transaction;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.jbossts.recovery.TestASRecovery;
+
+
+/**
+ * Extends TestASRecovery class with adding JMS.
+ */
+public class TestASRecoveryWithJMS extends TestASRecovery
+{
+ private static Logger log = Logger.getLogger(TestASRecoveryWithJMS.class);
+
+ private String message = null;
+
+
+ /**
+ * Enlists JMS into the active transaction.
+ */
+ @Override
+ protected boolean addTxResources(Transaction tx)
+ {
+ if (super.addTxResources(tx))
+ {
+ return sendMessage(message);
+ }
+
+ return false;
+ }
+
+ public boolean sendMessage(String message)
+ {
+ log.info("sending a message...");
+
+ InitialContext ic = null;
+ Connection conn = null;
+ try
+ {
+ ic = new InitialContext();
+
+ ConnectionFactory connectionFactory = (ConnectionFactory) ic.lookup("java:/JmsXA");
+ Queue testQueue = (Queue) ic.lookup("queue/crashRecoveryQueue");
+
+ conn = connectionFactory.createConnection();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer(testQueue);
+
+ producer.send(session.createTextMessage(message));
+ log.info("message sent");
+
+ return true;
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ return false;
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (JMSException e)
+ {
+ log.warn(e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Sets a message content.
+ *
+ * @param message
+ */
+ public void setMessage(String message)
+ {
+ this.message = message;
+ }
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CommonCrashHelper.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CommonCrashHelper.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CommonCrashHelper.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,198 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jbossts.recovery;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ejb.EJBException;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.jbossts.recovery.RecoveredXid;
+
+
+/**
+ * Helper class for playing with in-doubt txs.
+ *
+ * @author <a href="istudens at redhat.com">Ivo Studensky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class CommonCrashHelper implements CrashHelperRem
+{
+ protected static Logger log = Logger.getLogger(CommonCrashHelper.class);
+
+
+ /**
+ * Wipes out in-doubt xids according to <code>xidToRecover</code> list.
+ * If xidToRecover is null, it wipes out all in-doubt xids.
+ * The in-doubt xids are taken from {@link #getNewXAResource()}.
+ *
+ * @param xidToRecover list of Xids to recover
+ */
+ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+ public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
+ {
+ log.info("wipe out in-doubt txs");
+
+ XAResource xares = null;
+ try
+ {
+ xares = getNewXAResource();
+
+ if (xares == null)
+ return false;
+
+ Xid[] txInDoubt = null;
+ try
+ {
+ txInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot start recovering on xares", e);
+
+ try
+ {
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (Exception e1)
+ {
+ }
+
+ return false;
+ }
+
+ if (txInDoubt == null || txInDoubt.length == 0)
+ return true;
+
+ log.info("There are " + txInDoubt.length + " xids in doubt");
+
+ for (int k=0; k < txInDoubt.length; k++)
+ {
+ RecoveredXid xid = convertToRecoveredXid(txInDoubt[k]);
+ if (xidsToRecover == null || xidsToRecover.contains(xid))
+ {
+ try
+ {
+ log.info("rollbacking of Xid " + xid);
+ xares.rollback(txInDoubt[k]);
+ }
+ catch (Exception e)
+ {
+ log.error("Error in rollback of Xid " + txInDoubt[k], e);
+ }
+ }
+ }
+
+ try
+ {
+ if (xares != null)
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot finish recovering on xares", e);
+ }
+ }
+ finally
+ {
+ closeXAResource();
+ }
+ return true;
+ }
+
+ /**
+ * Checks in-doubt xids by XAResource taken from {@link #getNewXAResource()}.
+ *
+ * @return in-doubt xids
+ */
+ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
+ public Set<RecoveredXid> checkXidsInDoubt()
+ {
+ Set<RecoveredXid> xids = new HashSet<RecoveredXid>();
+
+ XAResource xares = null;
+ try
+ {
+ xares = getNewXAResource();
+
+ try
+ {
+ Xid[] xidsInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
+
+ if (xidsInDoubt != null)
+ {
+ log.info("There are " + xidsInDoubt.length + " xids in doubt");
+
+ for (int k=0; k < xidsInDoubt.length; k++)
+ xids.add(convertToRecoveredXid(xidsInDoubt[k]));
+ }
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot start recover scan on xares", e);
+ throw new EJBException("Cannot start recover scan on xares: " + e.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if (xares != null)
+ xares.recover(XAResource.TMENDRSCAN);
+ }
+ catch (XAException e)
+ {
+ log.error("Cannot finish recover scan on xares", e);
+ }
+ }
+ }
+ finally
+ {
+ closeXAResource();
+ }
+
+ return xids;
+ }
+
+ private RecoveredXid convertToRecoveredXid(Xid xid)
+ {
+ RecoveredXid recoveredXid = new RecoveredXid();
+
+ recoveredXid.setBranchQualifier(xid.getBranchQualifier());
+ recoveredXid.setFormatId(xid.getFormatId());
+ recoveredXid.setGlobalTransactionId(xid.getGlobalTransactionId());
+
+ return recoveredXid;
+ }
+
+
+ protected abstract XAResource getNewXAResource();
+
+ // Should not throw out any exception.
+ protected abstract void closeXAResource();
+
+}
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CrashHelperRem.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CrashHelperRem.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/CrashHelperRem.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jbossts.recovery;
+
+import java.util.Set;
+
+import javax.ejb.Remote;
+
+import org.jboss.test.jbossts.recovery.RecoveredXid;
+
+ at Remote
+public interface CrashHelperRem
+{
+ public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover);
+ public Set<RecoveredXid> checkXidsInDoubt();
+}
Copied: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/RecoveredXid.java (from rev 104923, branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/RecoveredXid.java)
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/RecoveredXid.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/RecoveredXid.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jbossts.recovery;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class RecoveredXid implements Serializable
+{
+ private byte[] branchQualifier;
+ private int formatId;
+ private byte[] globalTransactionId;
+
+ public RecoveredXid()
+ {
+ }
+
+ public byte[] getBranchQualifier()
+ {
+ return branchQualifier;
+ }
+
+ public void setBranchQualifier(byte[] branchQualifier)
+ {
+ this.branchQualifier = branchQualifier;
+ }
+
+ public int getFormatId()
+ {
+ return formatId;
+ }
+
+ public void setFormatId(int formatId)
+ {
+ this.formatId = formatId;
+ }
+
+ public byte[] getGlobalTransactionId()
+ {
+ return globalTransactionId;
+ }
+
+ public void setGlobalTransactionId(byte[] globalTransactionId)
+ {
+ this.globalTransactionId = globalTransactionId;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(branchQualifier);
+ result = prime * result + formatId;
+ result = prime * result + Arrays.hashCode(globalTransactionId);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RecoveredXid other = (RecoveredXid) obj;
+ if (!Arrays.equals(branchQualifier, other.branchQualifier))
+ return false;
+ if (formatId != other.formatId)
+ return false;
+ if (!Arrays.equals(globalTransactionId, other.globalTransactionId))
+ return false;
+ return true;
+ }
+
+ @Override
+ /**
+ * Only for debugging purposes.
+ */
+ public String toString()
+ {
+ return "RecoveredXid [branchQualifier=" + Arrays.toString(branchQualifier) + ", formatId=" + formatId
+ + ", globalTransactionId=" + Arrays.toString(globalTransactionId) + "]";
+ }
+
+}
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/TestASRecoveryWithJPA.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/TestASRecoveryWithJPA.java 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/recovery/TestASRecoveryWithJPA.java 2010-05-31 12:54:06 UTC (rev 105412)
@@ -29,7 +29,7 @@
import org.jboss.test.jbossts.crash.TestEntityHelperLocal;
/**
- * Extends TestASRecovery class by adding JPA entity update.
+ * Extends TestASRecovery class by adding EJB3 entity update.
*/
public class TestASRecoveryWithJPA extends TestASRecovery
{
Deleted: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/xa-mq-destinations-service.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/xa-mq-destinations-service.xml 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/xa-mq-destinations-service.xml 2010-05-31 12:54:06 UTC (rev 105412)
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<server>
-
- <!-- RECOVERY destinations -->
-
- <mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.mq.destination:service=Queue,name=recovery">
- <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
- <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
- <attribute name="SecurityConf">
- <security>
- <role name="guest" read="true" write="true" create="true"/>
- </security>
- </attribute>
- </mbean>
-
- <mbean code="org.jboss.mq.server.jmx.Topic"
- name="jboss.mq.destination:service=Topic,name=recoveryTopic">
- <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
- <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
- <attribute name="SecurityConf">
- <security>
- <role name="guest" read="true" write="true" create="true"/>
- </security>
- </attribute>
- </mbean>
-
- <mbean code="org.jboss.mq.server.jmx.Topic"
- name="jboss.mq.destination:service=Topic,name=recoveryDurableTopic">
- <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
- <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
- <attribute name="SecurityConf">
- <security>
- <role name="guest" read="true" write="true" create="true"/>
- </security>
- </attribute>
- </mbean>
-
- <mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.mq.destination:service=Queue,name=recoveryQueue">
- <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
- <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
- <attribute name="SecurityConf">
- <security>
- <role name="guest" read="true" write="true" create="true"/>
- </security>
- </attribute>
- </mbean>
-
- <mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.mq.destination:service=Queue,name=rcvQ">
- <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
- <depends optional-attribute-name="SecurityManager">jboss.messaging:service=SecurityStore</depends>
- <attribute name="SecurityConf">
- <security>
- <role name="guest" read="true" write="true" create="true"/>
- </security>
- </attribute>
- </mbean>
-
- <mbean code="org.jboss.mq.server.jmx.Queue"
- name="jboss.mq.destination:service=Queue,name=sndQ">
- <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
-<!--
- <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
- <attribute name="SecurityConf">
- <security>
- <role name="guest" read="true" write="true" create="true"/>
- </security>
- </attribute>
--->
- </mbean>
-
-
-</server>
-
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml 2010-05-31 10:52:29 UTC (rev 105411)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml 2010-05-31 12:54:06 UTC (rev 105412)
@@ -25,23 +25,34 @@
<!--
Main targets intended for JBossAS Testsuite optional task
-->
+ <!-- Tests with JPA -->
<target name="crash-tests" depends="want-all-dbs, want-all-tstypes, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
-
<target name="crash-tests-single-db" depends="want-all-tstypes, want-all-tsdemarc, want-all-testcases, crash-tests-single" />
-
<target name="crash-tests-single-db-tstype" depends="want-all-tsdemarc, want-all-testcases, crash-tests-single" />
-
- <target name="crash-tests-single" depends="init, set-db, prepare-drivers, set-tstype, set-tsdemarc, set-testcase, crash-tests-tstype-jta, crash-tests-tstype-jts" />
+ <target name="crash-tests-single" depends="init-jpa, set-db, prepare-drivers, set-tstype, set-tsdemarc, set-testcase">
+ <antcall target="call-tests-for-all-dbs"><param name="call.target" value="crash-tests-for-tstype"/></antcall>
+ </target>
+
+ <!-- Tests with JMS -->
+ <target name="crash-tests-jms" depends="want-all-tstypes, want-all-tsdemarc, want-all-testcases, crash-tests-jms-single" />
+ <target name="crash-tests-jms-single" depends="init-jms, set-tstype, set-tsdemarc, set-testcase, crash-tests-for-tstype" />
<!--
Other targets...
-->
- <target name="init">
+ <target name="init-jpa">
<echo message="jboss.home=${jboss.home}"/>
<property name="wipeOutTxsInDoubt" value="true" />
+ <property name="want.jpa" value="true" />
</target>
+ <target name="init-jms">
+ <echo message="jboss.home=${jboss.home}"/>
+ <property name="wipeOutTxsInDoubt" value="true" />
+ <property name="want.jms" value="true" />
+ </target>
+
<target name="set-db">
<condition property="want.psql_8.2">
<equals arg1="${jbossts.db}" arg2="psql_8.2"/>
@@ -180,14 +191,6 @@
</target>
- <target name="crash-tests-tstype-jta" if="want.tstype.jta">
- <antcall target="call-tests-for-all-dbs"><param name="tstype" value="jta"/><param name="call.target" value="crash-tests-for-database"/></antcall>
- </target>
-
- <target name="crash-tests-tstype-jts" if="want.tstype.jts">
- <antcall target="call-tests-for-all-dbs"><param name="tstype" value="jts"/><param name="call.target" value="crash-tests-for-database"/></antcall>
- </target>
-
<target name="call-tests-for-all-dbs">
<antcall target="call-tests-for-psql_8.2"/>
<antcall target="call-tests-for-psql_8.3"/>
@@ -346,13 +349,24 @@
- <target name="crash-tests-for-database" depends="crash-tests-for-database-cmt, crash-tests-for-database-bmt" />
+ <target name="crash-tests-for-tstype" depends="crash-tests-for-tstype-jta, crash-tests-for-tstype-jts" />
+
+ <target name="crash-tests-for-tstype-jta" if="want.tstype.jta">
+ <antcall target="crash-tests-for-tsdemarc"><param name="tstype" value="jta" /></antcall>
+ </target>
+
+ <target name="crash-tests-for-tstype-jts" if="want.tstype.jts">
+ <antcall target="crash-tests-for-tsdemarc"><param name="tstype" value="jts" /></antcall>
+ </target>
- <target name="crash-tests-for-database-cmt" if="want.cmt">
+
+ <target name="crash-tests-for-tsdemarc" depends="crash-tests-for-tsdemarc-cmt, crash-tests-for-tsdemarc-bmt" />
+
+ <target name="crash-tests-for-tsdemarc-cmt" if="want.cmt">
<antcall target="crash-tests-all-testcases"><param name="cmt" value="true" /></antcall>
</target>
- <target name="crash-tests-for-database-bmt" if="want.bmt">
+ <target name="crash-tests-for-tsdemarc-bmt" if="want.bmt">
<antcall target="crash-tests-all-testcases"><param name="cmt" value="false" /></antcall>
</target>
@@ -415,22 +429,12 @@
</antcall>
</target>
- <target name="execute-crash-recovery-test" depends="hack-before-astest-run, crash-recovery-test, hack-after-astest-run" />
+ <target name="execute-crash-recovery-test" depends="hack-before-astest-run, crash-recovery-test-jpa, crash-recovery-test-jms, hack-after-astest-run" />
<!--
Note: If you want to wipe out txs in doubt before and after test you have to set property 'wipeOutTxsInDoubt' to true.
-->
- <target name="crash-recovery-test">
-<!-- <attribute name="specs"/>
- <attribute name="datasource"/>
- <attribute name="dbdriver"/>
- <attribute name="dbname"/>
- <attribute name="cmt"/>
- <attribute name="tstype"/>
- <attribute name="reverseOrder"/>
- <attribute name="rollbackExpected"/> -->
- <sequential>
-
+ <target name="crash-recovery-test-jpa" if="want.jpa">
<condition property="test.name.cmt" value="cmt" else="bmt">
<istrue value="${cmt}"/>
</condition>
@@ -452,7 +456,6 @@
<deploy-datasource-and-set-credentials from="${product.dir}/resources/${datasource}" to="${jboss.home}/server/crashrecovery-${tstype}/deploy/${datasource}" />
<astest:server method="start" serverName="crashrecovery-${tstype}" >
<deploy from="dbdrivers/${dbdriver}" to="lib/${dbdriver}" />
- <!--deploy from="resources/${datasource}" to="deploy/${datasource}" /-->
<deploy from="${astest.jar.deploy.dir}/${astest.app.jar.name}" to="deploy/${astest.app.jar.name}" />
</astest:server>
<astest:action abortOnFail="false" waitFor="10000" impl="org.jboss.test.jbossts.taskdefs.JUnitClientAction">
@@ -472,7 +475,6 @@
</astest:action>
<astest:server method="stop" serverName="crashrecovery-${tstype}" >
<undeploy from="deploy/${astest.app.jar.name}" />
- <!--undeploy from="deploy/${datasource}" /-->
<undeploy from="lib/${dbdriver}" />
</astest:server>
@@ -488,11 +490,64 @@
<delete file="${jboss.home}/server/crashrecovery-${tstype}/deploy/${datasource}"/>
<delete file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
<delete dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store"/>
+
<!-- delete work and tmp dirs otherwise tests failed due to permgen space - FIXME is this the right way how to ensure that? -->
<delete dir="${jboss.home}/server/crashrecovery-${tstype}/work"/>
<delete dir="${jboss.home}/server/crashrecovery-${tstype}/tmp"/>
+ </target>
- </sequential>
+ <target name="crash-recovery-test-jms" if="want.jms">
+ <condition property="test.name.cmt" value="cmt" else="bmt">
+ <istrue value="${cmt}"/>
+ </condition>
+ <condition property="test.name.reverseOrder" value="-reverse" else="">
+ <istrue value="${reverseOrder}"/>
+ </condition>
+ <property name="testname" value="${tstype}-${specs}-${test.name.cmt}${test.name.reverseOrder}"/>
+
+ <condition property="astest.app.jar.name" value="${astest.alternative.jar.name}">
+ <isset property="astest.alternative.jar.name"/>
+ </condition>
+ <property name="astest.app.jar.name" value="${astest.jar.name}" />
+
+ <condition property="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/ArjunaTransactionImple">
+ <equals arg1="${tstype}" arg2="jts" />
+ </condition>
+ <property name="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction" />
+
+ <astest:server method="start" serverName="crashrecovery-${tstype}" >
+ <deploy from="${astest.jar.deploy.dir}/${astest.app.jar.name}" to="deploy/${astest.app.jar.name}" />
+ </astest:server>
+ <astest:action abortOnFail="false" waitFor="10000" impl="org.jboss.test.jbossts.taskdefs.JUnitClientAction">
+ <param key="testClass" value="org.jboss.test.jbossts.ASCrashRecovery02.TestWithJMS" />
+ <param key="name" value="${testname}" />
+ <param key="serverName" value="crashrecovery-${tstype}" />
+ <param key="specs" value="${specs}" />
+ <param key="cmt" value="${cmt}" />
+ <param key="storeType" value="${storeType}" />
+ <param key="reverseOrder" value="${reverseOrder}" />
+ <param key="rollbackExpected" value="${rollbackExpected}" />
+ <param key="debug" value="true" />
+ <param key="reportFile" value="${build.reports}/TEST-org.jboss.test.jbossts.ASCrashRecovery02.TestWithJMS-${testname}.xml" />
+ <param key="testTime" value="${testTime}" />
+ </astest:action>
+ <astest:server method="stop" serverName="crashrecovery-${tstype}" >
+ <undeploy from="deploy/${astest.app.jar.name}" />
+ </astest:server>
+
+ <!-- archive artifacts -->
+ <zip destfile="${jboss.home}/server/crashrecovery-${tstype}/server-${testname}.artifacts.zip">
+ <fileset dir="${jboss.home}/server/crashrecovery-${tstype}">
+ <include name="log/server.log"/>
+ <include name="data/tx-object-store/**"/>
+ </fileset>
+ </zip>
+ <delete file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store"/>
+
+ <!-- delete work and tmp dirs otherwise tests failed due to permgen space - FIXME is this the right way how to ensure that? -->
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/work"/>
+ <delete dir="${jboss.home}/server/crashrecovery-${tstype}/tmp"/>
</target>
<macrodef name="deploy-datasource-and-set-credentials">
More information about the jboss-cvs-commits
mailing list