[jboss-cvs] JBossAS SVN: r77746 - in trunk/testsuite/src/main/org/jboss/test/cluster: invokerha and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Sep 1 06:04:48 EDT 2008
Author: galder.zamarreno at jboss.com
Date: 2008-09-01 06:04:48 -0400 (Mon, 01 Sep 2008)
New Revision: 77746
Modified:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaTransactionStickyUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaTransactionStickyUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java
trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java
trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java
trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java
Log:
[JBAS-5850] Added tests that check behaivour when nodes are shutdown while in the middle of a transaction sticky invocation.
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaTransactionStickyUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaTransactionStickyUnitTestCase.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaTransactionStickyUnitTestCase.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -21,6 +21,9 @@
*/
package org.jboss.test.cluster.defaultcfg.test;
+import java.util.List;
+
+import org.jboss.invocation.InvokerHA;
import org.jboss.test.cluster.defaultcfg.test.JRMPInvokerHaUnitTestCase.JRMPInvokerHaFactory;
import org.jboss.test.cluster.invokerha.AbstractInvokerHaTransactionSticky;
@@ -43,6 +46,14 @@
super.tearDown();
}
+ @Override
+ protected List<Object> undeployChosenTargetNode(Object chosenTarget)
+ {
+ List<? extends InvokerHA> replicants = infrastructure.getReplicants();
+ replicants.remove(chosenTarget);
+ return (List<Object>) replicants;
+ }
+
public static class JRMPInvokerHaTransactionStickyFactory extends JRMPInvokerHaFactory
{
@Override
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaTransactionStickyUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaTransactionStickyUnitTestCase.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaTransactionStickyUnitTestCase.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -21,7 +21,11 @@
*/
package org.jboss.test.cluster.defaultcfg.test;
+import java.util.List;
+
+import org.jboss.remoting.InvokerLocator;
import org.jboss.test.cluster.defaultcfg.test.UnifiedInvokerHaUnitTestCase.UnifiedInvokerHaFactory;
+import org.jboss.test.cluster.defaultcfg.test.UnifiedInvokerHaUnitTestCase.UnifiedInvokerHaInfrastructure;
import org.jboss.test.cluster.invokerha.AbstractInvokerHaTransactionSticky;
/**
@@ -41,8 +45,16 @@
protected void tearDown() throws Exception
{
super.tearDown();
- }
+ }
+ @Override
+ protected List<Object> undeployChosenTargetNode(Object chosenTarget)
+ {
+ List<? extends InvokerLocator> locators = ((UnifiedInvokerHaInfrastructure)infrastructure).getLocators();
+ locators.remove(chosenTarget);
+ return (List<Object>) locators;
+ }
+
public static class UnifiedInvokerHaTransactionStickyFactory extends UnifiedInvokerHaFactory
{
@Override
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -115,6 +115,8 @@
*/
public static class UnifiedInvokerHaInfrastructure extends InvokerHaInfrastructure
{
+ private List<InvokerLocator> locators;
+
public UnifiedInvokerHaInfrastructure(int serverCount, InvokerHaFactory invokerHaFactory)
{
super(serverCount, invokerHaFactory);
@@ -125,7 +127,7 @@
throws Exception
{
/* convert replicant list into an InvokerLocator list */
- List<InvokerLocator> locators = new ArrayList<InvokerLocator>(replicants.size());
+ locators = new ArrayList<InvokerLocator>(replicants.size());
for (InvokerHA replicant : replicants)
{
locators.add(((MockUnifiedInvokerHA)replicant).getLocator());
@@ -140,5 +142,10 @@
replicant.registerBean(targetName, target);
}
}
+
+ public List<InvokerLocator> getLocators()
+ {
+ return locators;
+ }
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -55,7 +55,7 @@
{
private static final Logger log = Logger.getLogger(AbstractInvokerHa.class);
- InvokerHaInfrastructure infrastructure;
+ protected InvokerHaInfrastructure infrastructure;
InvokerHaTransactionalMockUtils transactionalMockUtils;
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -21,18 +21,23 @@
*/
package org.jboss.test.cluster.invokerha;
+import java.rmi.ServerException;
import java.rmi.server.UID;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.transaction.Transaction;
+import org.jboss.ha.framework.interfaces.GenericClusteringException;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
import org.jboss.ha.framework.interfaces.TransactionStickyFirstAvailable;
import org.jboss.ha.framework.interfaces.TransactionStickyFirstAvailableIdenticalAllProxies;
import org.jboss.ha.framework.interfaces.TransactionStickyRandomRobin;
import org.jboss.ha.framework.interfaces.TransactionStickyRoundRobin;
import org.jboss.invocation.Invocation;
+import org.jboss.invocation.InvokerProxyHA;
import org.jboss.logging.Logger;
import org.jboss.test.cluster.invokerha.InvokerHaTransactionalMockUtils.MockTransaction;
@@ -41,7 +46,7 @@
*
* @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
*/
-public class AbstractInvokerHaTransactionSticky extends AbstractInvokerHa
+public abstract class AbstractInvokerHaTransactionSticky extends AbstractInvokerHa
{
private static final Logger log = Logger.getLogger(AbstractInvokerHaTransactionSticky.class);
@@ -83,6 +88,11 @@
transactionalSuccessfulCalls(TransactionStickyRandomRobin.class, true);
}
+ public void testTransactionalCallsWithNodeShutdown() throws Exception
+ {
+ transactionalCallsWithNodeShutdown(TransactionStickyRandomRobin.class);
+ }
+
public void testSuccessfulCallsRoundRobin() throws Exception
{
/* test transaction sticky round robin lbp without transactions, should
@@ -189,6 +199,26 @@
}
+ protected void transactionalCallsWithNodeShutdown(Class<? extends LoadBalancePolicy> policyClass)
+ {
+ log.debug("transactional calls with node shutdown [policy=" + policyClass + "]");
+
+ try
+ {
+ UID uid = new UID();
+ createNewProxies(0, policyClass, true);
+ transactionalMockUtils.getTpcf().setUid(uid);
+ performTransactionalCallsWithNodeShutdown(null, policyClass);
+ }
+ catch(Exception e)
+ {
+ /* catching to log the error properly (JUnit in eclipse does not show
+ * correctly exceptions from invokers) and fail */
+ log.error("Error", e);
+ fail();
+ }
+ }
+
protected void successfulCalls(Class<? extends LoadBalancePolicy> policyClass)
{
log.debug("successfull calls [policy=" + policyClass);
@@ -252,6 +282,42 @@
return chosenTargets;
}
+ protected void performTransactionalCallsWithNodeShutdown(Transaction tx,
+ Class<? extends LoadBalancePolicy> policyClass) throws Exception
+ {
+ Invocation inv;
+
+ Set<Object> chosenTargetsDateTimeTeller = new HashSet<Object>(1);
+
+ /* create invocation to date time teller */
+ inv = infrastructure.createDateTimeTellerInvocation(tx, null);
+ /* invoke on proxy passing the invocation */
+ log.debug(timeTellerProxy.invoke(inv));
+ /* assert post conditions after invocation */
+ chosenTargetsDateTimeTeller = assertSuccessfulPostConditions(inv, chosenTargetsDateTimeTeller);
+
+ List<Object> newReplicants = undeployChosenTargetNode(chosenTargetsDateTimeTeller.toArray()[0]);
+ ((InvokerProxyHA)timeTellerProxy).updateClusterInfo((ArrayList<Object>)newReplicants, 3);
+
+ inv = infrastructure.createDateTimeTellerInvocation(tx, null);
+ try
+ {
+ log.debug(timeTellerProxy.invoke(inv));
+ fail("Should have thrown an exception because sticky target is no longer available");
+ }
+ catch(Exception e)
+ {
+ log.debug("Expected exception", e);
+ assertTrue(e instanceof GenericClusteringException || e.getCause() instanceof GenericClusteringException);
+ }
+ }
+
+ /**
+ * Undeploy chosen target from the cluster and return the list of remaining
+ * targets in cluster.
+ */
+ protected abstract List<Object> undeployChosenTargetNode(Object chosenTarget);
+
protected void assertChosenTargetsInBetweenTx(Class<? extends LoadBalancePolicy> policyClass, Set<?> chosenTargetsTx1, Set<?> chosenTargetsTx2, boolean newProxiesInBetweenTransactions)
{
if (policyClass.equals(TransactionStickyRoundRobin.class))
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -285,6 +285,11 @@
}
}
+ public List<? extends InvokerHA> getReplicants()
+ {
+ return replicants;
+ }
+
/**
* Simulate the deployment of an mbean in a list of invoker endpoints.
*
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/JRMPInvokerHaMockUtils.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
+import org.jboss.ha.framework.interfaces.GenericClusteringException;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
import org.jboss.invocation.Invocation;
import org.jboss.invocation.Invoker;
@@ -125,7 +126,7 @@
}
@Override
- protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc)
+ protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws GenericClusteringException
{
InvokerHaFailureType failureType = (InvokerHaFailureType)invocation.getValue("FAILURE_TYPE");
if (failureType != null)
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java 2008-09-01 10:02:54 UTC (rev 77745)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java 2008-09-01 10:04:48 UTC (rev 77746)
@@ -29,6 +29,7 @@
import javax.management.MBeanServer;
import javax.net.SocketFactory;
+import org.jboss.ha.framework.interfaces.GenericClusteringException;
import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
import org.jboss.invocation.Invocation;
import org.jboss.invocation.Invoker;
@@ -130,7 +131,7 @@
}
@Override
- protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc)
+ protected void putIfExistsTransactionTarget(Invocation invocation, Object tpc) throws GenericClusteringException
{
InvokerHaFailureType failureType = (InvokerHaFailureType)invocation.getValue("FAILURE_TYPE");
if (failureType != null)
More information about the jboss-cvs-commits
mailing list