[jboss-cvs] JBossAS SVN: r67784 - 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 Dec 3 12:39:23 EST 2007
Author: galder.zamarreno at jboss.com
Date: 2007-12-03 12:39:22 -0500 (Mon, 03 Dec 2007)
New Revision: 67784
Modified:
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaTransactionStickyUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.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/UnifiedInvokerHaMockUtils.java
Log:
[JBAS-4455] Added tests where new transaction sticky lbps work as the default ones when not running within a transaction.
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 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaTransactionStickyUnitTestCase.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -45,6 +45,10 @@
public static class JRMPInvokerHaTransactionStickyFactory extends JRMPInvokerHaFactory
{
+ @Override
+ public String getChosenTargetKey()
+ {
+ return "TX_STICKY_TARGET";
+ }
}
-
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.java 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JRMPInvokerHaUnitTestCase.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -72,5 +72,10 @@
{
return new MockJRMPInvokerHA(getInvokerTypeName() + "-" + serverName + "-" + serverNumber);
}
+
+ public String getChosenTargetKey()
+ {
+ return "TEST_CHOSEN_TARGET";
+ }
}
}
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 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaTransactionStickyUnitTestCase.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -45,5 +45,10 @@
public static class UnifiedInvokerHaTransactionStickyFactory extends UnifiedInvokerHaFactory
{
+ @Override
+ public String getChosenTargetKey()
+ {
+ return "TX_STICKY_TARGET";
+ }
}
}
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 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/UnifiedInvokerHaUnitTestCase.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -91,6 +91,11 @@
return invoker;
}
+
+ public String getChosenTargetKey()
+ {
+ return "TEST_CHOSEN_TARGET";
+ }
}
/**
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHa.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -129,7 +129,7 @@
protected void transactionalSuccessfulCalls(Class<? extends LoadBalancePolicy> policyClass, boolean newProxiesInBetweenTransactions)
{
- log.debug("successfull calls [policy=" + policyClass + ",newProxiesInBetweenTransactions=" + newProxiesInBetweenTransactions + "]");
+ log.debug("transactional successfull calls [policy=" + policyClass + ",newProxiesInBetweenTransactions=" + newProxiesInBetweenTransactions + "]");
try
{
@@ -140,7 +140,7 @@
/* Simulate client user transaction */
uid = new UID();
transactionalMockUtils.getTpcf().setUid(uid);
- performCalls(3, null, policyClass, newProxiesInBetweenTransactions);
+ performCalls(3, null, policyClass);
if (newProxiesInBetweenTransactions)
{
@@ -152,7 +152,7 @@
Transaction tx = new MockTransaction();
transactionalMockUtils.getTpcf().setUid(uid);
transactionalMockUtils.getTpci().setTransaction(tx);
- performCalls(3, tx, policyClass, newProxiesInBetweenTransactions);
+ performCalls(3, tx, policyClass);
}
catch(Exception e)
{
@@ -164,8 +164,7 @@
}
protected void performCalls(int numberPairCalls,
- Transaction tx, Class<? extends LoadBalancePolicy> policyClass,
- boolean newProxiesInBetweenTransactions) throws Exception
+ Transaction tx, Class<? extends LoadBalancePolicy> policyClass) throws Exception
{
Invocation inv;
@@ -190,12 +189,15 @@
protected Object assertSuccessfulPostConditions(Invocation inv, Object prevChosenTarget, Transaction tx, Class<? extends LoadBalancePolicy> policyClass)
{
assertEquals(0, inv.getAsIsValue("FAILOVER_COUNTER"));
- Object chosenTarget = inv.getTransientValue("TEST_CHOSEN_TARGET");
+ Object chosenTarget = inv.getTransientValue(invokerHaFactory.getChosenTargetKey());
assertNotNull(chosenTarget);
/* if tx was null, invocation's tx should be null after invocation. */
assertEquals(tx, inv.getTransaction());
- /* check tx failover authorisations */
- assertTrue("transaction should have reached the server", invokerHaFactory.getTxFailoverAuthorizationsMap().containsKey(transactionalMockUtils.getTpcf().getUid()));
+ if (transactionalMockUtils.getTpcf().getUid() != null)
+ {
+ /* check tx failover authorisations */
+ assertTrue("transaction should have reached the server", invokerHaFactory.getTxFailoverAuthorizationsMap().containsKey(transactionalMockUtils.getTpcf().getUid()));
+ }
/* check chosen target with previously chosen target, if there's any */
return assertChosenTarget(policyClass, chosenTarget, prevChosenTarget);
}
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/AbstractInvokerHaTransactionSticky.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -83,9 +83,35 @@
transactionalSuccessfulCalls(TransactionStickyRandomRobin.class, true);
}
- /* TODO -> bunch of tests that test the new transaction sticky lbps under
- * when no transactions run. They should behave exactly as the normal lbps */
+ public void testSuccessfulCallsRoundRobin() throws Exception
+ {
+ /* test transaction sticky round robin lbp without transactions, should
+ * behave like standard round robin */
+ successfulCalls(TransactionStickyRoundRobin.class);
+ }
+ public void testSuccessfulCallsFirstAvailable() throws Exception
+ {
+ /* test transaction sticky first available lbp without transactions, should
+ * behave like standard first available */
+ successfulCalls(TransactionStickyFirstAvailable.class);
+ }
+
+ public void testSuccessfulCallsFirstAvailableIndenticalAllProxies() throws Exception
+ {
+ /* test transaction sticky first available identical all proxies lbp
+ * without transactions, should behave like standard identical all
+ * proxies */
+ successfulCalls(TransactionStickyFirstAvailableIdenticalAllProxies.class);
+ }
+
+ public void testSuccessfulCallsRandomRobin() throws Exception
+ {
+ /* test transaction sticky random robin lbp without transactions, should
+ * behave like standard random robin */
+ successfulCalls(TransactionStickyRandomRobin.class);
+ }
+
public void testFailBeforeServer() throws Exception
{
/* if failure happens before reaching the server, regardless of whether
@@ -122,7 +148,7 @@
protected void transactionalSuccessfulCalls(Class<? extends LoadBalancePolicy> policyClass,
boolean newProxiesInBetweenTransactions)
{
- log.debug("successfull calls [policy=" + policyClass + ",newProxiesInBetweenTransactions=" + newProxiesInBetweenTransactions + "]");
+ log.debug("transactional successfull calls [policy=" + policyClass + ",newProxiesInBetweenTransactions=" + newProxiesInBetweenTransactions + "]");
try
{
@@ -162,6 +188,24 @@
}
}
+
+ protected void successfulCalls(Class<? extends LoadBalancePolicy> policyClass)
+ {
+ log.debug("successfull calls [policy=" + policyClass);
+
+ try
+ {
+ createNewProxies(0, policyClass, true);
+ performCalls(3, 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 performTransactionalStickyCalls(int numberPairCalls, Transaction tx,
Class<? extends LoadBalancePolicy> policyClass, boolean newProxiesInBetweenTransactions) throws Exception
@@ -197,7 +241,7 @@
protected Set<Object> assertSuccessfulPostConditions(Invocation inv, Set<Object> chosenTargets, Transaction tx)
{
assertEquals(0, inv.getAsIsValue("FAILOVER_COUNTER"));
- Object chosenTarget = inv.getTransientValue("TX_STICKY_TARGET");
+ Object chosenTarget = inv.getTransientValue(invokerHaFactory.getChosenTargetKey());
assertNotNull(chosenTarget);
/* if tx was null, invocation's tx should be null after invocation. */
assertEquals(tx, inv.getTransaction());
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/InvokerHaInfrastructure.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -200,6 +200,7 @@
public Invoker createDateTimeTellerProxy(int serverIndex, Class<? extends LoadBalancePolicy> policyClass) throws Exception
{
InvokerHA server = replicants.get(serverIndex);
+ log.debug("replicants: " + replicants);
return server.createProxy(dateTimeTellerON, policyClass.newInstance(), "UnitTestPartition/DateTimeTellerMBean");
}
@@ -382,6 +383,13 @@
* @return
*/
InvokerHA createInvokerHaServer(String serverName, int serverNumber);
+
+ /**
+ * Returns transient payload key to retrieve chosen target.
+ *
+ * @return String representation of the key
+ */
+ String getChosenTargetKey();
}
/**
Modified: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java 2007-12-03 17:37:16 UTC (rev 67783)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/UnifiedInvokerHaMockUtils.java 2007-12-03 17:39:22 UTC (rev 67784)
@@ -69,7 +69,7 @@
@Override
public String toString()
{
- return name;
+ return name + "," + super.toString();
}
public void setLocator(InvokerLocator locator)
@@ -107,6 +107,8 @@
failureType.injectFailureIfExistsAfterServer((Integer)invocation.getAsIsValue("FAILOVER_COUNTER"));
}
+ log.debug("invoking on " + invocation.getObjectName());
+
return super.invoke(invocationReq);
}
}
@@ -157,6 +159,20 @@
{
return client;
}
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + ",[client=" + client + "]";
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ /* reimplemented equals to avoid lingering static family cluster info
+ * references being valid in latter tests */
+ return super.equals(obj) && client.equals(((MockInvokerLocator)obj).getClient());
+ }
}
public static class MockClient extends Client
@@ -207,6 +223,12 @@
TransactionPropagationContextFactory tpcFactory = TransactionPropagationContextUtil.getTPCFactoryClientSide();
return (tpcFactory == null) ? null : tpcFactory.getTransactionPropagationContext();
}
+
+ @Override
+ public String toString()
+ {
+ return invoker.toString();
+ }
}
public static class MockClientInvoker implements ClientInvoker
More information about the jboss-cvs-commits
mailing list