[jboss-cvs] JBoss Messaging SVN: r2560 - in branches/Branch_1_2_0_SP: tests and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 26 00:36:50 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-03-26 00:36:49 -0400 (Mon, 26 Mar 2007)
New Revision: 2560

Added:
   branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/
   branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/FailingClient.java
   branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/SimultaneousFailureTest.java
Modified:
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
   branches/Branch_1_2_0_SP/tests/build.xml
   branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-928

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-03-23 19:17:01 UTC (rev 2559)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-03-26 04:36:49 UTC (rev 2560)
@@ -306,10 +306,22 @@
 
             log.debug(this + " failed to handle callback", e);
 
+            /*
+
+            TODO: http://jira.jboss.org/jira/browse/JBMESSAGING-928
+                  We need to fix the lock condition caused by handleClientFailure (the promotion of the readLock to writeLock,
+                  cause a infinite wait on read locks that will need synchronized methods...
+                  We will relay on Lease until we can fix this.
+
+                  due to a time constraint to fix a production issue on an user, I have removed this condition until we can
+                  perform this condition without a risk while we will create a testcase for this condition.
+
+                  
+
             ServerConnectionEndpoint sce = sessionEndpoint.getConnectionEndpoint();
             ConnectionManager cm = sce.getServerPeer().getConnectionManager();
 
-            cm.handleClientFailure(sce.getRemotingClientSessionID(), false);
+            cm.handleClientFailure(sce.getRemotingClientSessionID(), false); */
 
             // we're practically cut, from connection down
 

Modified: branches/Branch_1_2_0_SP/tests/build.xml
===================================================================
--- branches/Branch_1_2_0_SP/tests/build.xml	2007-03-23 19:17:01 UTC (rev 2559)
+++ branches/Branch_1_2_0_SP/tests/build.xml	2007-03-26 04:36:49 UTC (rev 2560)
@@ -866,7 +866,8 @@
    </target>
 
 
-   <target name="tmp1" depends="tests-jar, prepare-testdirs, clear-test-logs">
+   <!-- Temporary crash debug -->
+   <target name="crash-tmp1" depends="tests-jar, prepare-testdirs, clear-test-logs">
       <java classname="org.jboss.test.messaging.tools.jmx.rmi.RMITestServer" fork="true">
          <sysproperty key="module.output" value="${tests.output}"/>
          <sysproperty key="test.logfile.suffix" value="tmp-server"/>
@@ -884,7 +885,8 @@
       </java>
    </target>
 
-   <target name="tmp2" depends="tests-jar, prepare-testdirs">
+   <!-- Temporary crash debug -->
+   <target name="crash-tmp2" depends="tests-jar, prepare-testdirs">
 
       <java classname="org.jboss.test.messaging.jms.crash.simultaneousfailure.FailingClient" >
          <sysproperty key="module.output" value="${tests.output}"/>
@@ -905,13 +907,15 @@
 
 
 
-   <target name="tmp3" depends="tests-jar, prepare-testdirs">
+   <!-- Temporary crash debug -->
+   <target name="crash-tmp3" depends="tests-jar, prepare-testdirs">
       <antcall target="crash-test">
          <param name="crash.test.name" value="org.jboss.test.messaging.jms.crash.simultaneousfailure.SimultaneousFailureTest"/>
       </antcall>
 
    </target>
 
+   <!-- This test is disabled until we can implement http://jira.jboss.org/jira/browse/JBMESSAGING-928 properly -->
    <target name="simultaneous-crash" depends="tests-jar, prepare-testdirs, clear-test-logs">
       <antcall target="stop-rmi-server"/>
 

Added: branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/FailingClient.java
===================================================================
--- branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/FailingClient.java	                        (rev 0)
+++ branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/FailingClient.java	2007-03-26 04:36:49 UTC (rev 2560)
@@ -0,0 +1,240 @@
+/*
+   * 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.crash.simultaneousfailure;
+
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.logging.Logger;
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *          <p/>
+ *          $Id$
+ */
+public class FailingClient
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   static InitialContext ic;
+
+   static Logger log = Logger.getLogger(FailingClient.class);
+
+   static ConnectionFactory cf;
+
+   static Topic destination;
+
+   static Object sem = new Object();
+
+   static boolean running = false;
+
+   // Static ---------------------------------------------------------------------------------------
+
+   public static void main(String arg[])
+   {
+      try
+      {
+         ServerManagement.create(0);
+         ServerManagement.deployTopic("Topic");
+         ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+         cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
+         destination = (Topic) ic.lookup("/topic/Topic");
+
+         ProducerThread producer = new ProducerThread("ProdThread" , cf, destination);
+         producer.start();
+
+         RunningThread threads[] = new RunningThread[20];
+         for (int i = 0; i < threads.length; i++)
+         {
+            threads[i] = new RunningThread("FailingThread" + i , cf, destination);
+         }
+
+         for (int i = 0; i < threads.length; i++)
+         {
+            threads[i].start();
+         }
+
+         Thread.sleep(1000);
+
+         synchronized (sem)
+         {
+            running = true;
+            sem.notifyAll();
+         }
+
+
+         threads[0].join();
+
+      }
+      catch (Exception e)
+      {
+         log.error(e.getMessage(), e);
+      }
+
+
+   }
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   // Public ---------------------------------------------------------------------------------------
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+   static class RunningThread extends Thread
+   {
+
+      ConnectionFactory cf;
+
+      Topic destination;
+
+      static Logger log = Logger.getLogger(RunningThread.class);
+
+      public RunningThread(String name, ConnectionFactory cf, Topic destination)
+      {
+         super(name);
+         this.cf = cf;
+         this.destination = destination;
+      }
+
+      public RunningThread(ConnectionFactory cf, Topic destination)
+      {
+         super();
+         this.cf = cf;
+         this.destination = destination;
+      }
+
+      public void run()
+      {
+         try
+         {
+            synchronized (sem)
+            {
+               if (!running)
+               {
+                  sem.wait();
+               }
+            }
+            log.info("Destination - " + destination);
+
+            while (true)
+            {
+               Connection conn = null;
+               conn = cf.createConnection();
+               conn.setClientID(Thread.currentThread().getName());
+               Session sess = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
+               TopicSubscriber subscriber = sess.createDurableSubscriber(destination,
+                  "subscription " + Thread.currentThread().getName());
+               conn.start();
+
+               log.info("Another iteration");
+               for (int i=0;i<10;i++)
+               {
+                  TextMessage tst = (TextMessage)subscriber.receive(10000);
+                  log.info(Thread.currentThread().getName() + " received " + tst.getText());
+               }
+               conn.close();
+
+            }
+         }
+         catch (Exception e)
+         {
+            log.error(e.getMessage(), e);
+         }
+      }
+   }
+
+   static class ProducerThread extends Thread
+   {
+
+      ConnectionFactory cf;
+
+      Topic destination;
+
+      static Logger log = Logger.getLogger(RunningThread.class);
+
+      public ProducerThread(String name, ConnectionFactory cf, Topic destination)
+      {
+         super(name);
+         this.cf = cf;
+         this.destination = destination;
+      }
+
+      public ProducerThread(ConnectionFactory cf, Topic destination)
+      {
+         super();
+         this.cf = cf;
+         this.destination = destination;
+      }
+
+      public void run()
+      {
+         try
+         {
+            synchronized (sem)
+            {
+               if (!running)
+               {
+                  sem.wait();
+               }
+            }
+            log.info("Destination - " + destination);
+
+            Connection conn = null;
+            conn = cf.createConnection();
+            conn.setClientID(Thread.currentThread().getName());
+            Session sess = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
+            MessageProducer prod = sess.createProducer(destination);
+            conn.start();
+
+            int i=0;
+
+            while (true)
+            {
+               prod.send(sess.createTextMessage("Test " + i++));
+            }
+         }
+         catch (Exception e)
+         {
+            log.error(e.getMessage(), e);
+         }
+      }
+   }
+}


Property changes on: branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/FailingClient.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

Added: branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/SimultaneousFailureTest.java
===================================================================
--- branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/SimultaneousFailureTest.java	                        (rev 0)
+++ branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/SimultaneousFailureTest.java	2007-03-26 04:36:49 UTC (rev 2560)
@@ -0,0 +1,214 @@
+/*
+   * 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.crash.simultaneousfailure;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.logging.Logger;
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.Message;
+import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
+import javax.jms.TextMessage;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *          $Id$
+ */
+public class SimultaneousFailureTest extends MessagingTestCase
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+
+   InitialContext ic;
+
+   static Logger log = Logger.getLogger(SimultaneousFailureTest.class);
+
+   ConnectionFactory cf;
+
+   Topic destination;
+
+   static Object sem = new Object();
+
+   static boolean running = false;
+
+   static boolean shouldStop = false;
+
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public SimultaneousFailureTest(String name)
+   {
+      super(name);
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+
+   public void testMultipleConnections() throws Exception
+   {
+
+      RunningThread threads[] = new RunningThread[20];
+      for (int i = 0; i < 20; i++)
+      {
+         threads[i] = new RunningThread("JunitConsumer(" + i + ")", cf, destination);
+      }
+
+      for (int i = 0; i < 20; i++)
+      {
+         threads[i].start();
+      }
+
+      Thread.sleep(1000);
+
+      synchronized (sem)
+      {
+         running = true;
+         sem.notifyAll();
+      }
+
+
+      Thread.sleep(300000);
+      synchronized (sem)
+      {
+         shouldStop=true;
+      }
+
+
+      for (int i = 0; i < 20; i++)
+      {
+         threads[i].join();
+      }
+   }
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      ServerManagement.create(0);
+      //ServerManagement.deployQueue("Queue");
+      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+      cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
+      destination = (Topic) ic.lookup("/topic/Topic");
+      running = false;
+   }
+
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+   }
+
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+
+   static class RunningThread extends Thread
+   {
+
+      ConnectionFactory cf;
+
+      Topic destination;
+
+      static Logger log = Logger.getLogger(RunningThread.class);
+
+      public RunningThread(String name, ConnectionFactory cf, Topic destination)
+      {
+         super(name);
+         this.cf = cf;
+         this.destination = destination;
+      }
+
+      public RunningThread(ConnectionFactory cf, Topic destination)
+      {
+         super();
+         this.cf = cf;
+         this.destination = destination;
+      }
+
+      public void run()
+      {
+         try
+         {
+            synchronized (sem)
+            {
+               if (!running)
+               {
+                  sem.wait();
+               }
+            }
+            log.info("Destination - " + destination);
+
+            while (true)
+            {
+               synchronized (sem)
+               {
+                  if (shouldStop)
+                  {
+                     break;
+                  }
+               }
+               Connection conn = null;
+               conn = cf.createConnection();
+               conn.setClientID(Thread.currentThread().getName());
+               Session sess = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);
+               TopicSubscriber subscriber = sess.createDurableSubscriber(destination,
+                  "subscription " + Thread.currentThread().getName());
+               conn.start();
+
+               log.info("Another iteration");
+               for (int i=0;i<10;i++)
+               {
+                  TextMessage tst = (TextMessage)subscriber.receive(10000);
+                  log.info(Thread.currentThread().getName() + " received " + tst.getText());
+               }
+               conn.close();
+
+            }
+         }
+         catch (Exception e)
+         {
+            log.error(e.getMessage(), e);
+         }
+      }
+   }
+
+
+}


Property changes on: branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/jms/crash/simultaneousfailure/SimultaneousFailureTest.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision

Modified: branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
===================================================================
--- branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2007-03-23 19:17:01 UTC (rev 2559)
+++ branches/Branch_1_2_0_SP/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java	2007-03-26 04:36:49 UTC (rev 2560)
@@ -117,6 +117,23 @@
       }
 
       log.info("RMI server " + serverIndex + " bound");
+
+      // there is one crash test that needs to start the server, as an external VM...
+      // as one client will crash while another will be alive
+      boolean startAll=false;
+
+      for (int i=0;i<args.length;i++)
+      {
+         if (args[i].equals("-startAll"))
+         {
+            startAll=true;
+         }
+      }
+
+      if (startAll)
+      {
+         testServer.start("all", true);
+      }
    }
 
    // Attributes ----------------------------------------------------




More information about the jboss-cvs-commits mailing list