[jboss-cvs] JBoss Messaging SVN: r2988 - in trunk/tests/src/org/jboss/test/messaging/jms: stress/clustering and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 8 18:56:33 EDT 2007
Author: timfox
Date: 2007-08-08 18:56:33 -0400 (Wed, 08 Aug 2007)
New Revision: 2988
Added:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
Removed:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java
Modified:
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ChangeFailoverNodeTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveriesTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java
trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredTopicStressTest.java
trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/FailoverStressTest.java
Log:
Tests speedup
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ChangeFailoverNodeTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ChangeFailoverNodeTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ChangeFailoverNodeTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -45,7 +45,7 @@
* $Id: $
*
*/
-public class ChangeFailoverNodeTest extends NewClusteringTestBase
+public class ChangeFailoverNodeTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterConnectionManagerTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -45,7 +45,7 @@
* $Id: $
*
*/
-public class ClusterConnectionManagerTest extends NewClusteringTestBase
+public class ClusterConnectionManagerTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -52,7 +52,7 @@
* <p/>
* $Id$
*/
-public class ClusterLeakTest extends NewClusteringTestBase
+public class ClusterLeakTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -37,7 +37,7 @@
*
* $Id$
*/
-public class ClusterViewUpdateTest extends NewClusteringTestBase
+public class ClusterViewUpdateTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -34,7 +34,7 @@
* @version <tt>$Revision$</tt>
* $Id$
*/
-public class ClusteredConnectionFactoryTest extends NewClusteringTestBase
+public class ClusteredConnectionFactoryTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Copied: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java (from rev 2985, trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -0,0 +1,407 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.messaging.jms.clustering;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jms.Connection;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.naming.InitialContext;
+
+import org.jboss.jms.client.FailoverEvent;
+import org.jboss.jms.client.FailoverListener;
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.DelegateSupport;
+import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.tx.ResourceManagerFactory;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2928 $</tt>
+ * $Id: ClusteringTestBase.java 2928 2007-07-27 00:33:55Z timfox $
+ */
+public class ClusteringTestBase extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ protected String config = "all+http";
+
+ protected static InitialContext[] ic;
+ protected static Queue queue[];
+ protected static Topic topic[];
+
+ // No need to have multiple connection factories since a clustered connection factory will create
+ // connections in a round robin fashion on different servers.
+
+ protected static JBossConnectionFactory cf;
+
+ protected int nodeCount = 4;
+ protected ServiceAttributeOverrides overrides;
+
+ protected static ServiceAttributeOverrides currentOverrides;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ClusteringTestBase(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected int getFailoverNodeForNode(JBossConnectionFactory factory, int nodeID)
+ {
+ Integer l = (Integer)((ClientClusteredConnectionFactoryDelegate)(factory.getDelegate())).getFailoverMap().get(new Integer(nodeID));
+
+ return l.intValue();
+ }
+
+ protected int getNodeThatFailsOverOnto(JBossConnectionFactory factory, int nodeID)
+ {
+ Map map = ((ClientClusteredConnectionFactoryDelegate)(factory.getDelegate())).getFailoverMap();
+
+ Iterator iter = map.entrySet().iterator();
+
+ while (iter.hasNext())
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+
+ int val = ((Integer)entry.getValue()).intValue();
+ int key = ((Integer)entry.getKey()).intValue();
+
+ if (val == nodeID)
+ {
+ return key;
+ }
+ }
+
+ throw new IllegalStateException("Cannot find node that fails over onto " + nodeID);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ assertEquals(0, ResourceManagerFactory.instance.size());
+
+ log.info("node count is " + nodeCount);
+
+ if (ic != null && ic.length < nodeCount)
+ {
+ log.info("Node count has increased from " + ic.length + " to " + nodeCount);
+ //Node count has increased
+ InitialContext[] oldIc = ic;
+ ic = new InitialContext[nodeCount];
+ Queue[] oldQueue = queue;
+ queue = new Queue[nodeCount];
+ Topic[] oldTopic = topic;
+ topic = new Topic[nodeCount];
+ for (int i = 0; i < oldIc.length; i++)
+ {
+ ic[i] = oldIc[i];
+ queue[i] = oldQueue[i];
+ topic[i] = oldTopic[i];
+ }
+ }
+ else if (ic != null && ic.length > nodeCount)
+ {
+ log.info("Node count has decreased from " + ic.length + " to " + nodeCount);
+ //Node count has decreased
+ InitialContext[] oldIc = ic;
+ ic = new InitialContext[nodeCount];
+ Queue[] oldQueue = queue;
+ queue = new Queue[nodeCount];
+ Topic[] oldTopic = topic;
+ topic = new Topic[nodeCount];
+ for (int i = 0; i < nodeCount; i++)
+ {
+ ic[i] = oldIc[i];
+ queue[i] = oldQueue[i];
+ topic[i] = oldTopic[i];
+ }
+
+ for (int i = nodeCount; i < oldIc.length; i++)
+ {
+ log.info("*** killing server");
+ ServerManagement.kill(i);
+ }
+ }
+
+ if (overridesChanged(overrides, currentOverrides))
+ {
+ log.info("Overrides have changed so stopping and restarting all servers");
+ currentOverrides = overrides;
+
+ for (int i = 0; i < nodeCount; i++)
+ {
+ ServerManagement.stop(i);
+ }
+ }
+
+ for (int i = 0; i < nodeCount; i++)
+ {
+ if (!ServerManagement.isStarted(i))
+ {
+ log.info("Server " + i + " is not started - starting it");
+
+ ServerManagement.start(i, config, currentOverrides, ic == null);
+
+ if (ic == null)
+ {
+ ic = new InitialContext[nodeCount];
+ queue = new Queue[nodeCount];
+ topic = new Topic[nodeCount];
+ }
+
+ log.info("deploying queue on node " + i);
+ ServerManagement.deployQueue("testDistributedQueue", i);
+ ServerManagement.deployTopic("testDistributedTopic", i);
+
+ ic[i] = new InitialContext(ServerManagement.getJNDIEnvironment(i));
+
+ queue[i] = (Queue)ic[i].lookup("queue/testDistributedQueue");
+ topic[i] = (Topic)ic[i].lookup("topic/testDistributedTopic");
+
+ }
+
+ checkEmpty(queue[i], i);
+
+ // Check no subscriptions left lying around
+
+ checkNoSubscriptions(topic[i], i);
+
+ ServerManagement.getServer(i).resetAllSuckers();
+ }
+
+ if (ic != null)
+ {
+ cf = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
+ }
+ }
+
+ private boolean overridesChanged(ServiceAttributeOverrides sao1, ServiceAttributeOverrides sao2)
+ {
+ Map map1 = sao1 == null ? null : sao1.getMap();
+
+ Map map2 = sao2 == null ? null : sao2.getMap();
+
+ if (map1 == null && map2 == null)
+ {
+ return false;
+ }
+ if ((map1 == null && map2 != null) || (map2 == null && map1 != null))
+ {
+ return true;
+ }
+
+ if (map1.size() != map2.size())
+ {
+ return true;
+ }
+
+ Iterator iter = map1.entrySet().iterator();
+ while (iter.hasNext())
+ {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Object otherVal = map2.get(entry.getKey());
+ if (otherVal == null)
+ {
+ return true;
+ }
+ if (!otherVal.equals(entry.getValue()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ // This will tell us if any connections have been left open
+ assertEquals(0, ResourceManagerFactory.instance.size());
+ }
+
+ protected String getLocatorURL(Connection conn)
+ {
+ return getConnectionState(conn).getRemotingConnection().
+ getRemotingClient().getInvoker().getLocator().getLocatorURI();
+ }
+
+ protected String getObjectId(Connection conn)
+ {
+ return ((DelegateSupport) ((JBossConnection) conn).
+ getDelegate()).getID();
+ }
+
+ protected ConnectionState getConnectionState(Connection conn)
+ {
+ return (ConnectionState) (((DelegateSupport) ((JBossConnection) conn).
+ getDelegate()).getState());
+ }
+
+ protected void waitForFailoverComplete(int serverID, Connection conn1)
+ throws Exception
+ {
+
+ assertEquals(serverID, ((JBossConnection)conn1).getServerID());
+
+ // register a failover listener
+ SimpleFailoverListener failoverListener = new SimpleFailoverListener();
+ ((JBossConnection)conn1).registerFailoverListener(failoverListener);
+
+ log.debug("killing node " + serverID + " ....");
+
+ ServerManagement.kill(serverID);
+
+ log.info("########");
+ log.info("######## KILLED NODE " + serverID);
+ log.info("########");
+
+ // wait for the client-side failover to complete
+
+ while (true)
+ {
+ FailoverEvent event = failoverListener.getEvent(30000);
+ if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
+ {
+ break;
+ }
+ if (event == null)
+ {
+ fail("Did not get expected FAILOVER_COMPLETED event");
+ }
+ }
+
+ // failover complete
+ log.info("failover completed");
+ }
+
+
+
+ /**
+ * Lookup for the connection with the right serverID. I'm using this method to find the proper
+ * serverId so I won't relay on loadBalancing policies on testcases.
+ */
+ protected Connection getConnection(Connection[] conn, int serverId) throws Exception
+ {
+ for(int i = 0; i < conn.length; i++)
+ {
+ ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
+ getDelegate()).getState());
+
+ if (state.getServerID() == serverId)
+ {
+ return conn[i];
+ }
+ }
+
+ return null;
+ }
+
+ protected void checkConnectionsDifferentServers(Connection[] conn) throws Exception
+ {
+ int[] serverID = new int[conn.length];
+ for(int i = 0; i < conn.length; i++)
+ {
+ ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
+ getDelegate()).getState());
+ serverID[i] = state.getServerID();
+ }
+
+ for(int i = 0; i < nodeCount; i++)
+ {
+ for(int j = 0; j < nodeCount; j++)
+ {
+ if (i == j)
+ {
+ continue;
+ }
+
+ if (serverID[i] == serverID[j])
+ {
+ fail("Connections " + i + " and " + j +
+ " are pointing to the same physical node (" + serverID[i] + ")");
+ }
+ }
+ }
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+ protected class SimpleFailoverListener implements FailoverListener
+ {
+ private LinkedQueue buffer;
+
+ public SimpleFailoverListener()
+ {
+ buffer = new LinkedQueue();
+ }
+
+ public void failoverEventOccured(FailoverEvent event)
+ {
+ try
+ {
+ buffer.put(event);
+ }
+ catch(InterruptedException e)
+ {
+ throw new RuntimeException("Putting thread interrupted while trying to add event " +
+ "to buffer", e);
+ }
+ }
+
+ /**
+ * Blocks until a FailoverEvent is available or timeout occurs, in which case returns null.
+ */
+ public FailoverEvent getEvent(long timeout) throws InterruptedException
+ {
+ return (FailoverEvent)buffer.poll(timeout);
+ }
+ }
+
+}
+
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -28,7 +28,7 @@
*
* $Id: FailoverTest.java 2685 2007-05-15 07:56:12Z timfox $
*/
-public class DisableLoadBalancingAndFailoverTest extends NewClusteringTestBase
+public class DisableLoadBalancingAndFailoverTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTestBase.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTestBase.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -46,7 +46,7 @@
* $Id: DistributedDestinationsTest.java 2796 2007-06-25 22:24:41Z timfox $
*
*/
-public abstract class DistributedQueueTestBase extends NewClusteringTestBase
+public abstract class DistributedQueueTestBase extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedRequestResponseTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -40,7 +40,7 @@
*
* $Id: TemporaryDestinationTest.java 2701 2007-05-17 16:01:05Z timfox $
*/
-public class DistributedRequestResponseTest extends NewClusteringTestBase
+public class DistributedRequestResponseTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedTopicTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -44,7 +44,7 @@
* $Id$
*
*/
-public class DistributedTopicTest extends NewClusteringTestBase
+public class DistributedTopicTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/FailoverTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -32,7 +32,7 @@
*
* $Id$
*/
-public class FailoverTest extends NewClusteringTestBase
+public class FailoverTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/HATest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -55,7 +55,7 @@
* $Id$
*
*/
-public class HATest extends NewClusteringTestBase
+public class HATest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -17,6 +17,7 @@
import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.jms.tx.ResourceManagerFactory;
import org.jboss.test.messaging.tools.ServerManagement;
import EDU.oswego.cs.dl.util.concurrent.Slot;
@@ -27,7 +28,7 @@
*
* $Id$
*/
-public class LargeClusterTest extends NewClusteringTestBase
+public class LargeClusterTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
@@ -112,9 +113,7 @@
{
// By this time, after running setUp(), we should have an already formed cluster of seven
// nodes
-
-
-
+
Set view = ServerManagement.getServer(0).getNodeIDView();
assertEquals(7, view.size());
@@ -430,6 +429,8 @@
protected void tearDown() throws Exception
{
super.tearDown();
+
+ assertEquals(0, ResourceManagerFactory.instance.size());
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -16,6 +16,7 @@
import org.jboss.jms.client.delegate.DelegateSupport;
import org.jboss.jms.client.plugin.RoundRobinLoadBalancingPolicy;
import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.tx.ResourceManagerFactory;
import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -27,7 +28,7 @@
*
* $Id$
*/
-public class LoadBalancingTest extends NewClusteringTestBase
+public class LoadBalancingTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
@@ -152,8 +153,18 @@
protected void setUp() throws Exception
{
nodeCount = 2;
+
super.setUp();
+
+ assertEquals(0, ResourceManagerFactory.instance.size());
}
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ assertEquals(0, ResourceManagerFactory.instance.size());
+ }
// Private --------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MergeQueueTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -25,7 +25,7 @@
*
* $Id$
*/
-public class MergeQueueTest extends NewClusteringTestBase
+public class MergeQueueTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -46,7 +46,7 @@
*
* $Id$
*/
-public class MultiThreadFailoverTest extends NewClusteringTestBase
+public class MultiThreadFailoverTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultipleFailoverTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -46,7 +46,7 @@
*
* $Id$
*/
-public class MultipleFailoverTest extends NewClusteringTestBase
+public class MultipleFailoverTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Deleted: trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -1,405 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.messaging.jms.clustering;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.Queue;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-
-import org.jboss.jms.client.FailoverEvent;
-import org.jboss.jms.client.FailoverListener;
-import org.jboss.jms.client.JBossConnection;
-import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
-import org.jboss.jms.client.delegate.DelegateSupport;
-import org.jboss.jms.client.state.ConnectionState;
-import org.jboss.jms.tx.ResourceManagerFactory;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
-
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2928 $</tt>
- * $Id: ClusteringTestBase.java 2928 2007-07-27 00:33:55Z timfox $
- */
-public class NewClusteringTestBase extends MessagingTestCase
-{
- // Constants ------------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- protected String config = "all+http";
-
- protected static InitialContext[] ic;
- protected static Queue queue[];
- protected static Topic topic[];
-
- // No need to have multiple connection factories since a clustered connection factory will create
- // connections in a round robin fashion on different servers.
-
- protected static JBossConnectionFactory cf;
-
- protected int nodeCount = 4;
- protected ServiceAttributeOverrides overrides;
-
- protected static ServiceAttributeOverrides currentOverrides;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public NewClusteringTestBase(String name)
- {
- super(name);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected int getFailoverNodeForNode(JBossConnectionFactory factory, int nodeID)
- {
- Integer l = (Integer)((ClientClusteredConnectionFactoryDelegate)(factory.getDelegate())).getFailoverMap().get(new Integer(nodeID));
-
- return l.intValue();
- }
-
- protected int getNodeThatFailsOverOnto(JBossConnectionFactory factory, int nodeID)
- {
- Map map = ((ClientClusteredConnectionFactoryDelegate)(factory.getDelegate())).getFailoverMap();
-
- Iterator iter = map.entrySet().iterator();
-
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
-
- int val = ((Integer)entry.getValue()).intValue();
- int key = ((Integer)entry.getKey()).intValue();
-
- if (val == nodeID)
- {
- return key;
- }
- }
-
- throw new IllegalStateException("Cannot find node that fails over onto " + nodeID);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- log.info("node count is " + nodeCount);
-
- if (ic != null && ic.length < nodeCount)
- {
- log.info("Node count has increased from " + ic.length + " to " + nodeCount);
- //Node count has increased
- InitialContext[] oldIc = ic;
- ic = new InitialContext[nodeCount];
- Queue[] oldQueue = queue;
- queue = new Queue[nodeCount];
- Topic[] oldTopic = topic;
- topic = new Topic[nodeCount];
- for (int i = 0; i < oldIc.length; i++)
- {
- ic[i] = oldIc[i];
- queue[i] = oldQueue[i];
- topic[i] = oldTopic[i];
- }
- }
- else if (ic != null && ic.length > nodeCount)
- {
- log.info("Node count has decreased from " + ic.length + " to " + nodeCount);
- //Node count has decreased
- InitialContext[] oldIc = ic;
- ic = new InitialContext[nodeCount];
- Queue[] oldQueue = queue;
- queue = new Queue[nodeCount];
- Topic[] oldTopic = topic;
- topic = new Topic[nodeCount];
- for (int i = 0; i < nodeCount; i++)
- {
- ic[i] = oldIc[i];
- queue[i] = oldQueue[i];
- topic[i] = oldTopic[i];
- }
-
- for (int i = nodeCount; i < oldIc.length; i++)
- {
- log.info("*** killing server");
- ServerManagement.kill(i);
- }
- }
-
- if (overridesChanged(overrides, currentOverrides))
- {
- log.info("Overrides have changed so stopping and restarting all servers");
- currentOverrides = overrides;
-
- for (int i = 0; i < nodeCount; i++)
- {
- ServerManagement.stop(i);
- }
- }
-
- for (int i = 0; i < nodeCount; i++)
- {
- if (!ServerManagement.isStarted(i))
- {
- log.info("Server " + i + " is not started - starting it");
-
- ServerManagement.start(i, config, currentOverrides, ic == null);
-
- if (ic == null)
- {
- ic = new InitialContext[nodeCount];
- queue = new Queue[nodeCount];
- topic = new Topic[nodeCount];
- }
-
- log.info("deploying queue on node " + i);
- ServerManagement.deployQueue("testDistributedQueue", i);
- ServerManagement.deployTopic("testDistributedTopic", i);
-
- ic[i] = new InitialContext(ServerManagement.getJNDIEnvironment(i));
-
- queue[i] = (Queue)ic[i].lookup("queue/testDistributedQueue");
- topic[i] = (Topic)ic[i].lookup("topic/testDistributedTopic");
-
- }
-
- checkEmpty(queue[i], i);
-
- // Check no subscriptions left lying around
-
- checkNoSubscriptions(topic[i], i);
-
- ServerManagement.getServer(i).resetAllSuckers();
- }
-
- if (ic != null)
- {
- cf = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
- }
- }
-
- private boolean overridesChanged(ServiceAttributeOverrides sao1, ServiceAttributeOverrides sao2)
- {
- Map map1 = sao1 == null ? null : sao1.getMap();
-
- Map map2 = sao2 == null ? null : sao2.getMap();
-
- if (map1 == null && map2 == null)
- {
- return false;
- }
- if ((map1 == null && map2 != null) || (map2 == null && map1 != null))
- {
- return true;
- }
-
- if (map1.size() != map2.size())
- {
- return true;
- }
-
- Iterator iter = map1.entrySet().iterator();
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
- Object otherVal = map2.get(entry.getKey());
- if (otherVal == null)
- {
- return true;
- }
- if (!otherVal.equals(entry.getValue()))
- {
- return true;
- }
- }
- return false;
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- // This will tell us if any connections have been left open
- assertEquals(0, ResourceManagerFactory.instance.size());
- }
-
- protected String getLocatorURL(Connection conn)
- {
- return getConnectionState(conn).getRemotingConnection().
- getRemotingClient().getInvoker().getLocator().getLocatorURI();
- }
-
- protected String getObjectId(Connection conn)
- {
- return ((DelegateSupport) ((JBossConnection) conn).
- getDelegate()).getID();
- }
-
- protected ConnectionState getConnectionState(Connection conn)
- {
- return (ConnectionState) (((DelegateSupport) ((JBossConnection) conn).
- getDelegate()).getState());
- }
-
- protected void waitForFailoverComplete(int serverID, Connection conn1)
- throws Exception
- {
-
- assertEquals(serverID, ((JBossConnection)conn1).getServerID());
-
- // register a failover listener
- SimpleFailoverListener failoverListener = new SimpleFailoverListener();
- ((JBossConnection)conn1).registerFailoverListener(failoverListener);
-
- log.debug("killing node " + serverID + " ....");
-
- ServerManagement.kill(serverID);
-
- log.info("########");
- log.info("######## KILLED NODE " + serverID);
- log.info("########");
-
- // wait for the client-side failover to complete
-
- while (true)
- {
- FailoverEvent event = failoverListener.getEvent(30000);
- if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
- {
- break;
- }
- if (event == null)
- {
- fail("Did not get expected FAILOVER_COMPLETED event");
- }
- }
-
- // failover complete
- log.info("failover completed");
- }
-
-
-
- /**
- * Lookup for the connection with the right serverID. I'm using this method to find the proper
- * serverId so I won't relay on loadBalancing policies on testcases.
- */
- protected Connection getConnection(Connection[] conn, int serverId) throws Exception
- {
- for(int i = 0; i < conn.length; i++)
- {
- ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
- getDelegate()).getState());
-
- if (state.getServerID() == serverId)
- {
- return conn[i];
- }
- }
-
- return null;
- }
-
- protected void checkConnectionsDifferentServers(Connection[] conn) throws Exception
- {
- int[] serverID = new int[conn.length];
- for(int i = 0; i < conn.length; i++)
- {
- ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
- getDelegate()).getState());
- serverID[i] = state.getServerID();
- }
-
- for(int i = 0; i < nodeCount; i++)
- {
- for(int j = 0; j < nodeCount; j++)
- {
- if (i == j)
- {
- continue;
- }
-
- if (serverID[i] == serverID[j])
- {
- fail("Connections " + i + " and " + j +
- " are pointing to the same physical node (" + serverID[i] + ")");
- }
- }
- }
- }
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
- protected class SimpleFailoverListener implements FailoverListener
- {
- private LinkedQueue buffer;
-
- public SimpleFailoverListener()
- {
- buffer = new LinkedQueue();
- }
-
- public void failoverEventOccured(FailoverEvent event)
- {
- try
- {
- buffer.put(event);
- }
- catch(InterruptedException e)
- {
- throw new RuntimeException("Putting thread interrupted while trying to add event " +
- "to buffer", e);
- }
- }
-
- /**
- * Blocks until a FailoverEvent is available or timeout occurs, in which case returns null.
- */
- public FailoverEvent getEvent(long timeout) throws InterruptedException
- {
- return (FailoverEvent)buffer.poll(timeout);
- }
- }
-
-}
-
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -46,7 +46,7 @@
* @version <tt>$Revision$</tt>
* $Id$
*/
-public class NoFailoverTest extends NewClusteringTestBase
+public class NoFailoverTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -40,7 +40,7 @@
* $Id: $
*
*/
-public class PreserveOrderingTest extends NewClusteringTestBase
+public class PreserveOrderingTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveriesTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveriesTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/RecoverDeliveriesTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -50,7 +50,7 @@
* $Id: $
*
*/
-public class RecoverDeliveriesTest extends NewClusteringTestBase
+public class RecoverDeliveriesTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/TemporaryDestinationTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -40,7 +40,7 @@
*
* $Id$
*/
-public class TemporaryDestinationTest extends NewClusteringTestBase
+public class TemporaryDestinationTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -38,7 +38,7 @@
* $Id$
*
*/
-public class XAFailoverTest extends NewClusteringTestBase
+public class XAFailoverTest extends ClusteringTestBase
{
// Constants ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -35,11 +35,11 @@
import javax.jms.Session;
import org.jboss.logging.Logger;
-import org.jboss.test.messaging.jms.clustering.NewClusteringTestBase;
+import org.jboss.test.messaging.jms.clustering.ClusteringTestBase;
import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
-public class ClusteredQueueStressTest extends NewClusteringTestBase
+public class ClusteredQueueStressTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredTopicStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredTopicStressTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredTopicStressTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -19,10 +19,10 @@
import javax.jms.TextMessage;
import org.jboss.logging.Logger;
-import org.jboss.test.messaging.jms.clustering.NewClusteringTestBase;
+import org.jboss.test.messaging.jms.clustering.ClusteringTestBase;
-public class ClusteredTopicStressTest extends NewClusteringTestBase
+public class ClusteredTopicStressTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/FailoverStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/FailoverStressTest.java 2007-08-08 21:56:36 UTC (rev 2987)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/FailoverStressTest.java 2007-08-08 22:56:33 UTC (rev 2988)
@@ -32,7 +32,7 @@
import org.jboss.jms.client.FailoverEvent;
import org.jboss.jms.client.FailoverListener;
import org.jboss.jms.client.JBossConnection;
-import org.jboss.test.messaging.jms.clustering.NewClusteringTestBase;
+import org.jboss.test.messaging.jms.clustering.ClusteringTestBase;
import org.jboss.test.messaging.tools.ServerManagement;
import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
@@ -43,7 +43,7 @@
*
* $Id$
*/
-public class FailoverStressTest extends NewClusteringTestBase
+public class FailoverStressTest extends ClusteringTestBase
{
// Constants -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list