[jboss-cvs] JBoss Messaging SVN: r2953 - in trunk/tests: src/org/jboss/test/messaging/jms/clustering and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Aug 4 07:19:10 EDT 2007


Author: timfox
Date: 2007-08-04 07:19:10 -0400 (Sat, 04 Aug 2007)
New Revision: 2953

Modified:
   trunk/tests/build.xml
   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/NewClusteringTestBase.java
Log:
More work on speeding up clustering tests


Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml	2007-08-03 15:38:46 UTC (rev 2952)
+++ trunk/tests/build.xml	2007-08-04 11:19:10 UTC (rev 2953)
@@ -755,9 +755,9 @@
 <include name="**/jms/clustering/ChangeFailoverNodeTest.class"/>
 <include name="**/jms/clustering/ClusterConnectionManagerTest.class"/>
 <include name="**/jms/clustering/ClusteredConnectionFactoryTest.class"/>
-<!--
+<include name="**/jms/clustering/ClusteringAspectInternalTest.class"/>
 <include name="**/jms/clustering/ClusterViewUpdateTest.class"/>
--->
+<include name="**/jms/clustering/DisableLoadBalancingAndFailoverTest.class"/>
             </fileset>
          </batchtest>
       </junit>

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-03 15:38:46 UTC (rev 2952)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java	2007-08-04 11:19:10 UTC (rev 2953)
@@ -56,6 +56,14 @@
 
    // Public ---------------------------------------------------------------------------------------
 
+   protected void setUp() throws Exception
+   {
+   	nodeCount = 2;
+   	
+   	super.setUp();
+   }
+   
+   
    public void testUpdateConnectionFactoryOnKill() throws Exception
    {
       Connection conn = createConnectionOnServer(cf, 0);
@@ -65,21 +73,19 @@
       ClientClusteredConnectionFactoryDelegate cfDelegate =
          (ClientClusteredConnectionFactoryDelegate)jbcf.getDelegate();
 
-      assertEquals(4, cfDelegate.getDelegates().length);
+      assertEquals(2, cfDelegate.getDelegates().length);
 
       Connection conn1 = cf.createConnection();
 
       assertEquals(1, getServerId(conn1));
 
-      log.info("*** killing server");
       ServerManagement.kill(1);
-      log.info("killed server");
 
       log.info("sleeping 5 secs ...");
       Thread.sleep(5000);
 
       // first part of the test, verifies if the CF was updated
-      assertEquals(2, cfDelegate.getDelegates().length);
+      assertEquals(1, cfDelegate.getDelegates().length);
       conn.close();
 
       log.info("sleeping 5 secs ...");
@@ -88,7 +94,7 @@
       // Second part, verifies a possible race condition on failoverMap and handleFilover
 
       log.info("ServerId=" + getServerId(conn1));
-      assertTrue(1 != getServerId(conn1));
+      assertEquals(0, getServerId(conn1));
      
       conn1.close();
       
@@ -97,9 +103,9 @@
       
       Thread.sleep(5000);
       
-      assertEquals(3, cfDelegate.getDelegates().length);
+      assertEquals(2, cfDelegate.getDelegates().length);
       
-      log.info("Done!!");
+      ServerManagement.stop(1);
    }
    
    public void testUpdateConnectionFactoryOnStop() throws Exception
@@ -111,30 +117,26 @@
       ClientClusteredConnectionFactoryDelegate cfDelegate =
          (ClientClusteredConnectionFactoryDelegate)jbcf.getDelegate();
 
-      assertEquals(3, cfDelegate.getDelegates().length);
+      assertEquals(2, cfDelegate.getDelegates().length);
 
       Connection conn1 = cf.createConnection();
 
       assertEquals(1, getServerId(conn1));
 
-      log.info("*** killing server");
       ServerManagement.kill(1);
-      log.info("killed server");
 
       log.info("sleeping 5 secs ...");
       Thread.sleep(5000);
 
       // first part of the test, verifies if the CF was updated
-      assertEquals(2, cfDelegate.getDelegates().length);
+      assertEquals(1, cfDelegate.getDelegates().length);
       conn.close();
 
       log.info("sleeping 5 secs ...");
       Thread.sleep(5000);
 
       // Second part, verifies a possible race condition on failoverMap and handleFilover
-
-      log.info("ServerId=" + getServerId(conn1));
-      assertTrue(1 != getServerId(conn1));
+      assertEquals(0, getServerId(conn1));
      
       conn1.close();
       
@@ -143,9 +145,7 @@
       
       Thread.sleep(5000);
       
-      assertEquals(3, cfDelegate.getDelegates().length);
-      
-      log.info("Done!!");
+      assertEquals(2, cfDelegate.getDelegates().length);
    }
 
    public void testUpdateMixedConnectionFactory() throws Exception
@@ -156,7 +156,7 @@
       ClientClusteredConnectionFactoryDelegate cfDelegate =
          (ClientClusteredConnectionFactoryDelegate)jbcf.getDelegate();
 
-      assertEquals(3, cfDelegate.getDelegates().length);
+      assertEquals(2, cfDelegate.getDelegates().length);
 
       ConnectionFactory httpCF = (ConnectionFactory)ic[0].lookup("/HTTPConnectionFactory");
       JBossConnectionFactory jbhttpCF = (JBossConnectionFactory) httpCF;
@@ -166,9 +166,8 @@
       ClientClusteredConnectionFactoryDelegate httpcfDelegate =
          (ClientClusteredConnectionFactoryDelegate)jbhttpCF.getDelegate();
 
-      assertEquals(3, httpcfDelegate.getDelegates().length);
+      assertEquals(2, httpcfDelegate.getDelegates().length);
 
-
       validateCFs(cfDelegate, httpcfDelegate);
 
       Connection conn1 = cf.createConnection();
@@ -183,8 +182,8 @@
       Thread.sleep(5000);
 
       // first part of the test, verifies if the CF was updated
-      assertEquals(2, cfDelegate.getDelegates().length);
-      assertEquals(2, httpcfDelegate.getDelegates().length);
+      assertEquals(1, cfDelegate.getDelegates().length);
+      assertEquals(1, httpcfDelegate.getDelegates().length);
 
       validateCFs(cfDelegate, httpcfDelegate);
 
@@ -197,7 +196,8 @@
       // Second part, verifies a possible racing condition on failoverMap and handleFilover
 
       log.info("ServerId=" + getServerId(conn1));
-      assertTrue(1 != getServerId(conn1));
+      assertEquals(0, getServerId(conn1));
+      assertEquals(0, getServerId(httpConn1));
 
       conn1.close();
       httpConn.close();
@@ -214,7 +214,7 @@
       JBossConnectionFactory jbcf = (JBossConnectionFactory) cf;
       ClientClusteredConnectionFactoryDelegate cfDelegate =
          (ClientClusteredConnectionFactoryDelegate) jbcf.getDelegate();
-      assertEquals(3, cfDelegate.getDelegates().length);
+      assertEquals(2, cfDelegate.getDelegates().length);
 
       Connection conn1 = cf.createConnection();
 
@@ -222,7 +222,7 @@
 
       assertEquals(1, getServerId(conn1));
       
-      assertEquals(2, getServerId(conn2));
+      assertEquals(0, getServerId(conn2));
 
       ConnectionState state = this.getConnectionState(conn1);
 
@@ -237,10 +237,10 @@
       conn1.createSession(true, Session.SESSION_TRANSACTED);
 
       // first part of the test, verifies if the CF was updated
-      assertEquals(2, cfDelegate.getDelegates().length);
+      assertEquals(1, cfDelegate.getDelegates().length);
 
-      assertTrue(1 != getServerId(conn1));
-
+      assertEquals(0, getServerId(conn1));
+      
       conn.close();
       conn1.close();
       conn2.close();

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-03 15:38:46 UTC (rev 2952)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredConnectionFactoryTest.java	2007-08-04 11:19:10 UTC (rev 2953)
@@ -22,9 +22,6 @@
 
 package org.jboss.test.messaging.jms.clustering;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import javax.jms.Connection;
 
 import org.jboss.jms.client.JBossConnectionFactory;
@@ -55,9 +52,16 @@
 
    // Public ---------------------------------------------------------------------------------------
 
+   
+   protected void setUp() throws Exception
+   {
+   	nodeCount = 2;
+   	
+   	super.setUp();
+   }
+   
    public void testGetAOPBroken() throws Exception
    {      
-      ServerManagement.kill(2);
       ServerManagement.kill(1);
       ServerManagement.kill(0);
 
@@ -78,7 +82,6 @@
 
       try
       {
-      	ServerManagement.kill(2);
          ServerManagement.kill(1);
          
          assertNotNull(((JBossConnectionFactory)cf).getDelegate().getClientAOPStack());
@@ -115,18 +118,15 @@
          
          conn = cf.createConnection();
          
-         Set ids = new HashSet();
+         assertEquals(0, getServerId(conn));
          
-         ids.add(new Integer(getServerId(conn)));
-         
          conn.close();
          
          conn = cf.createConnection();
-
-         ids.add(new Integer(getServerId(conn)));
          
-         assertTrue(ids.contains(new Integer(0)));
-         assertTrue(ids.contains(new Integer(2)));
+         assertEquals(0, getServerId(conn));
+         
+         conn.close();
       }
       finally
       {
@@ -151,49 +151,16 @@
 
          // this should break on server1
          conn = cf.createConnection();
-
-         Set ids = new HashSet();
          
-         ids.add(new Integer(getServerId(conn)));
+         assertEquals(0, getServerId(conn));
          
          conn.close();
          
          conn = cf.createConnection();
-
-         ids.add(new Integer(getServerId(conn)));
          
-         assertTrue(ids.contains(new Integer(0)));
-         assertTrue(ids.contains(new Integer(2)));
-      }
-      finally
-      {
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-
-   public void testCreateConnectionTwoServersBroken() throws Exception
-   {
-      Connection conn = null;
-
-      try
-      {
-         conn = createConnectionOnServer(cf, 0);
-         conn.close();
-
-         ServerManagement.kill(1);
-         ServerManagement.kill(2);
-         conn = cf.createConnection();
-
          assertEquals(0, getServerId(conn));
          
          conn.close();
-         
-         conn = cf.createConnection();
-
-         assertEquals(0, getServerId(conn));
       }
       finally
       {
@@ -204,7 +171,6 @@
       }
    }
 
-
    // Package protected ----------------------------------------------------------------------------
 
    // Protected ------------------------------------------------------------------------------------

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-03 15:38:46 UTC (rev 2952)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DisableLoadBalancingAndFailoverTest.java	2007-08-04 11:19:10 UTC (rev 2953)
@@ -28,7 +28,7 @@
  *
  * $Id: FailoverTest.java 2685 2007-05-15 07:56:12Z timfox $
  */
-public class DisableLoadBalancingAndFailoverTest extends ClusteringTestBase
+public class DisableLoadBalancingAndFailoverTest extends NewClusteringTestBase
 {
    // 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-03 15:38:46 UTC (rev 2952)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueTestBase.java	2007-08-04 11:19:10 UTC (rev 2953)
@@ -47,7 +47,7 @@
  * $Id: DistributedDestinationsTest.java 2796 2007-06-25 22:24:41Z timfox $
  *
  */
-public abstract class DistributedQueueTestBase extends ClusteringTestBase
+public abstract class DistributedQueueTestBase extends NewClusteringTestBase
 {
 
    // Constants -----------------------------------------------------

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java	2007-08-03 15:38:46 UTC (rev 2952)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/NewClusteringTestBase.java	2007-08-04 11:19:10 UTC (rev 2953)
@@ -72,7 +72,7 @@
 
    protected static JBossConnectionFactory cf;
    
-   protected static int nodeCount = 4;
+   protected int nodeCount = 4;
 
    // Constructors ---------------------------------------------------------------------------------
 
@@ -120,6 +120,48 @@
    {
       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 < ic.length; i++)
+      	{
+      		ServerManagement.kill(i);
+      	}
+      }
+      
       for (int i = 0; i < nodeCount; i++)
       {
 	      if (!ServerManagement.isStarted(i))




More information about the jboss-cvs-commits mailing list