You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2007/12/16 21:17:00 UTC

svn commit: r604691 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/

Author: rajdavies
Date: Sun Dec 16 12:16:59 2007
New Revision: 604691

URL: http://svn.apache.org/viewvc?rev=604691&view=rev
Log:
update performance tests

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java   (with props)
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java   (with props)
Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaDurableTopicTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaQueueTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaDurableTopicTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaQueueTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java Sun Dec 16 12:16:59 2007
@@ -25,12 +25,22 @@
  */
 public class AMQStoreDurableTopicTest extends SimpleDurableTopicTest {
 
-    protected void configureBroker(BrokerService answer) throws Exception {
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
         File dataFileDir = new File("target/test-amq-data/perfTest/amqdb");
+        dataFileDir.mkdirs();
         answer.setDeleteAllMessagesOnStartup(true);
         AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter();
-        adaptor.setDirectory(dataFileDir);
+        adaptor.setArchiveDataLogs(true);
+        adaptor.setMaxFileLength(1024 * 64);
+        answer.setDataDirectoryFile(dataFileDir);
         answer.setPersistenceAdapter(adaptor);
-        answer.addConnector(bindAddress);
+        answer.addConnector(uri);
+    }
+    
+    protected void setUp() throws Exception {
+        numberofProducers=6;
+        numberOfConsumers=6;
+        this.consumerSleepDuration=0;
+        super.setUp();
     }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java Sun Dec 16 12:16:59 2007
@@ -26,7 +26,7 @@
  */
 public class AMQStoreQueueTest extends SimpleQueueTest {
 
-    protected void configureBroker(BrokerService answer) throws Exception {
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
 
         File dataFileDir = new File("target/test-amq-data/perfTest/amq");
 
@@ -34,7 +34,7 @@
         adaptor.setDirectory(dataFileDir);
 
         answer.setPersistenceAdapter(adaptor);
-        answer.addConnector(bindAddress);
+        answer.addConnector(uri);
         answer.setDeleteAllMessagesOnStartup(true);
 
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaDurableTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaDurableTopicTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaDurableTopicTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaDurableTopicTest.java Sun Dec 16 12:16:59 2007
@@ -27,7 +27,7 @@
  */
 public class JournalKahaDurableTopicTest extends SimpleDurableTopicTest {
 
-    protected void configureBroker(BrokerService answer) throws Exception {
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
 
         File dataFileDir = new File("target/test-amq-data/perfTest");
         File journalDir = new File(dataFileDir, "journal").getCanonicalFile();
@@ -38,7 +38,7 @@
         journalAdaptor.setMaxCheckpointWorkers(1);
 
         answer.setPersistenceAdapter(journalAdaptor);
-        answer.addConnector(bindAddress);
+        answer.addConnector(uri);
         answer.setDeleteAllMessagesOnStartup(true);
 
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaQueueTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaQueueTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/JournalKahaQueueTest.java Sun Dec 16 12:16:59 2007
@@ -28,7 +28,7 @@
  */
 public class JournalKahaQueueTest extends SimpleQueueTest {
 
-    protected void configureBroker(BrokerService answer) throws Exception {
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
 
         File dataFileDir = new File("target/test-amq-data/perfTest");
         File journalDir = new File(dataFileDir, "journal").getCanonicalFile();
@@ -39,7 +39,7 @@
         journalAdaptor.setMaxCheckpointWorkers(1);
 
         answer.setPersistenceAdapter(journalAdaptor);
-        answer.addConnector(bindAddress);
+        answer.addConnector(uri);
         answer.setDeleteAllMessagesOnStartup(true);
 
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaDurableTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaDurableTopicTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaDurableTopicTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaDurableTopicTest.java Sun Dec 16 12:16:59 2007
@@ -32,10 +32,10 @@
      * result=factory.getBroker(); result.start(); return result; }
      */
 
-    protected void configureBroker(BrokerService answer) throws Exception {
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
         KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter();
         answer.setPersistenceAdapter(adaptor);
-        answer.addConnector(bindAddress);
+        answer.addConnector(uri);
         answer.setDeleteAllMessagesOnStartup(true);
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaQueueTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaQueueTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/KahaQueueTest.java Sun Dec 16 12:16:59 2007
@@ -24,10 +24,10 @@
  */
 public class KahaQueueTest extends SimpleQueueTest {
 
-    protected void configureBroker(BrokerService answer) throws Exception {
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
         KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter();
         answer.setPersistenceAdapter(adaptor);
-        answer.addConnector(bindAddress);
+        answer.addConnector(uri);
         answer.setDeleteAllMessagesOnStartup(true);
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/QueueConnectionMemoryTest.java Sun Dec 16 12:16:59 2007
@@ -47,18 +47,18 @@
         // just cancel super class test
     }
 
-    protected void configureBroker(BrokerService answer) throws Exception {
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
         KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter();
         answer.setPersistenceAdapter(adaptor);
-        answer.addConnector(bindAddress);
+        answer.addConnector(uri);
         answer.setDeleteAllMessagesOnStartup(true);
     }
 
     public void testMemory() throws Exception {
         if (broker == null) {
-            broker = createBroker();
+            broker = createBroker(bindAddress);
         }
-        factory = createConnectionFactory();
+        factory = createConnectionFactory(bindAddress);
         Connection con = factory.createConnection();
         Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
         destination = createDestination(session, destinationName);

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java?rev=604691&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java Sun Dec 16 12:16:59 2007
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.perf;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.network.NetworkConnector;
+
+
+public class SimpleDurableTopicNetworkTest extends SimpleNetworkTest {
+    
+    protected void setUp() throws Exception {
+        numberofProducers=6;
+        numberOfConsumers=6;
+        samepleCount=100;
+        playloadSize = 1;
+        super.setUp();
+    }
+    
+    
+    protected PerfProducer createProducer(ConnectionFactory fac, Destination dest, int number, byte payload[]) throws JMSException {
+        PerfProducer pp = new PerfProducer(fac, dest, payload);
+        pp.setDeliveryMode(DeliveryMode.PERSISTENT);
+        return pp;
+    }
+
+    protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number) throws JMSException {
+        return new PerfConsumer(fac, dest, "subs:" + number);
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleDurableTopicNetworkTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java?rev=604691&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java Sun Dec 16 12:16:59 2007
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.perf;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.network.NetworkConnector;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import junit.framework.TestCase;
+
+
+public class SimpleNetworkTest extends SimpleTopicTest {
+
+    private static final Log LOG = LogFactory.getLog(SimpleNetworkTest.class);
+    protected String consumerBindAddress = "tcp://localhost:61616";
+    protected String producerBindAddress = "tcp://localhost:61617";
+    protected static final String CONSUMER_BROKER_NAME = "Consumer";
+    protected static final String PRODUCER_BROKER_NAME = "Producer";
+    protected BrokerService consumerBroker;
+    protected BrokerService producerBroker;
+    protected ConnectionFactory consumerFactory;
+    protected ConnectionFactory producerFactory;
+    
+    protected void setUp() throws Exception {
+        if (consumerBroker == null) {
+            consumerBroker = createConsumerBroker(consumerBindAddress);
+        }
+        if (producerBroker == null) {
+            producerBroker = createProducerBroker(producerBindAddress);
+        }
+        consumerFactory = createConnectionFactory("vm://"+CONSUMER_BROKER_NAME);
+        producerFactory = createConnectionFactory("vm://"+ PRODUCER_BROKER_NAME);
+        //consumerFactory = createConnectionFactory(consumerBindAddress);
+        //producerFactory = createConnectionFactory(producerBindAddress);
+        Connection con = consumerFactory.createConnection();
+        Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        destination = createDestination(session, destinationName);
+        LOG.info("Testing against destination: " + destination);
+        LOG.info("Running " + numberofProducers + " producer(s) and " + numberOfConsumers + " consumer(s)");
+        con.close();
+        producers = new PerfProducer[numberofProducers];
+        consumers = new PerfConsumer[numberOfConsumers];
+        for (int i = 0; i < numberOfConsumers; i++) {
+            consumers[i] = createConsumer(consumerFactory, destination, i);
+            consumers[i].setSleepDuration(consumerSleepDuration);
+        }
+        for (int i = 0; i < numberofProducers; i++) {
+            array = new byte[playloadSize];
+            for (int j = i; j < array.length; j++) {
+                array[j] = (byte)j;
+            }
+            producers[i] = createProducer(producerFactory, destination, i, array);
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        for (int i = 0; i < numberOfConsumers; i++) {
+            consumers[i].shutDown();
+        }
+        for (int i = 0; i < numberofProducers; i++) {
+            producers[i].shutDown();
+        }
+        
+        if (producerBroker != null) {
+            producerBroker.stop();
+            producerBroker = null;
+        }
+        if (consumerBroker != null) {
+            consumerBroker.stop();
+            consumerBroker = null;
+        }
+    }
+    
+    protected BrokerService createConsumerBroker(String uri) throws Exception {
+        BrokerService answer = new BrokerService();
+        configureConsumerBroker(answer,uri);
+        answer.start();
+        return answer;
+    }
+    
+    protected void configureConsumerBroker(BrokerService answer,String uri) throws Exception {
+        answer.setPersistent(false);
+        answer.setBrokerName(CONSUMER_BROKER_NAME);
+        answer.setDeleteAllMessagesOnStartup(true);
+        answer.addConnector(uri);
+        answer.setUseShutdownHook(false);
+    }
+    
+    protected BrokerService createProducerBroker(String uri) throws Exception {
+        BrokerService answer = new BrokerService();
+        configureProducerBroker(answer,uri);
+        answer.start();
+        return answer;
+    }
+    
+    protected void configureProducerBroker(BrokerService answer,String uri) throws Exception {
+        answer.setBrokerName(PRODUCER_BROKER_NAME);
+        answer.setDeleteAllMessagesOnStartup(true);
+        NetworkConnector connector = answer.addNetworkConnector("static://"+consumerBindAddress);
+        connector.setDuplex(true);
+        answer.addConnector(uri);
+        answer.setUseShutdownHook(false);
+    }
+
+
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleNetworkTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleQueueTest.java Sun Dec 16 12:16:59 2007
@@ -28,5 +28,10 @@
     protected Destination createDestination(Session s, String destinationName) throws JMSException {
         return s.createQueue(destinationName);
     }
+    
+    protected void setUp() throws Exception {
+        this.consumerSleepDuration=2000;
+        super.setUp();
+    }
 
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SimpleTopicTest.java Sun Dec 16 12:16:59 2007
@@ -61,9 +61,9 @@
      */
     protected void setUp() throws Exception {
         if (broker == null) {
-            broker = createBroker();
+            broker = createBroker(bindAddress);
         }
-        factory = createConnectionFactory();
+        factory = createConnectionFactory(bindAddress);
         Connection con = factory.createConnection();
         Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
         destination = createDestination(session, destinationName);
@@ -109,9 +109,9 @@
      * 
      * @throws Exception
      */
-    protected BrokerService createBroker() throws Exception {
+    protected BrokerService createBroker(String uri) throws Exception {
         BrokerService answer = new BrokerService();
-        configureBroker(answer);
+        configureBroker(answer,uri);
         answer.start();
         return answer;
     }
@@ -123,15 +123,16 @@
     protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number) throws JMSException {
         return new PerfConsumer(fac, dest);
     }
-
-    protected void configureBroker(BrokerService answer) throws Exception {
-        answer.addConnector(bindAddress);
+    
+    
+    protected void configureBroker(BrokerService answer,String uri) throws Exception {
         answer.setDeleteAllMessagesOnStartup(true);
+        answer.addConnector(uri);
         answer.setUseShutdownHook(false);
     }
 
-    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-        return new ActiveMQConnectionFactory(bindAddress);
+    protected ActiveMQConnectionFactory createConnectionFactory(String uri) throws Exception {
+        return new ActiveMQConnectionFactory(uri);
     }
 
     public void testPerformance() throws JMSException, InterruptedException {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java?rev=604691&r1=604690&r2=604691&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/perf/SlowConsumerTopicTest.java Sun Dec 16 12:16:59 2007
@@ -66,7 +66,7 @@
     }
 
     protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
-        ActiveMQConnectionFactory result = super.createConnectionFactory();
+        ActiveMQConnectionFactory result = super.createConnectionFactory(bindAddress);
         ActiveMQPrefetchPolicy policy = new ActiveMQPrefetchPolicy();
         policy.setTopicPrefetch(1000);
         result.setPrefetchPolicy(policy);