From 1e3cc7ff9424e74e565640af8afd8563546252f4 Mon Sep 17 00:00:00 2001 From: Bhupendra Bhusman Bhardwaj Date: Wed, 24 Jan 2007 11:05:35 +0000 Subject: updated the test classes to be used with Topics as well as Queues git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@499356 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/ping/PingTestPerf.java | 32 ++++++++------- .../apache/qpid/requestreply/PingPongTestPerf.java | 45 ++++++++++++++-------- 2 files changed, 48 insertions(+), 29 deletions(-) (limited to 'java/perftests/src/test') diff --git a/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java b/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java index 402d72d6db..88a791ecb3 100644 --- a/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java +++ b/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java @@ -42,17 +42,17 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll /** * Holds the name of the property to get the test message size from. */ - protected static final String MESSAGE_SIZE_PROPNAME = "messageSize"; + private static final String MESSAGE_SIZE_PROPNAME = "messagesize"; /** * Holds the name of the property to get the ping queue name from. */ - protected static final String PING_QUEUE_NAME_PROPNAME = "pingQueue"; + private static final String PING_DESTINATION_NAME_PROPNAME = "destinationname"; /** * holds the queue count, if the test is being performed with multiple queues */ - protected static final String PING_QUEUE_COUNT_PROPNAME = "queues"; + private static final String PING_DESTINATION_COUNT_PROPNAME = "destinationscount"; /** * Holds the name of the property to get the test delivery mode from. @@ -84,6 +84,8 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll protected static final String VERBOSE_OUTPUT_PROPNAME = "verbose"; + /** Holds the true or false depending on wether it is P2P test or PubSub */ + private static final String IS_PUBSUB_PROPNAME = "pubsub"; /** * Holds the size of message body to attach to the ping messages. */ @@ -95,7 +97,7 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll /** * Holds the name of the queue to which pings are sent. */ - protected static final String PING_QUEUE_NAME_DEFAULT = "ping"; + private static final String PING_DESTINATION_NAME_DEFAULT = "ping"; /** * Holds the message delivery mode to use for the test. @@ -138,6 +140,8 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll */ ThreadLocal threadSetup = new ThreadLocal(); + Object _lock = new Object(); + // Set up a property reader to extract the test parameters from. Once ContextualProperties is available in // the project dependencies, use it to get property overrides for configurable tests and to notify the test runner // of the test parameters to log with the results. @@ -158,15 +162,16 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll setSystemPropertyIfNull(BATCH_SIZE, Integer.toString(BATCH_SIZE_DEFAULT)); setSystemPropertyIfNull(COMMIT_BATCH_SIZE, Integer.toString(COMMIT_BATCH_SIZE_DEFAULT)); setSystemPropertyIfNull(MESSAGE_SIZE_PROPNAME, Integer.toString(MESSAGE_SIZE_DEFAULT)); - setSystemPropertyIfNull(PING_QUEUE_NAME_PROPNAME, PING_QUEUE_NAME_DEFAULT); + setSystemPropertyIfNull(PING_DESTINATION_NAME_PROPNAME, PING_DESTINATION_NAME_DEFAULT); setSystemPropertyIfNull(PERSISTENT_MODE_PROPNAME, Boolean.toString(PERSISTENT_MODE_DEFAULT)); setSystemPropertyIfNull(TRANSACTED_PROPNAME, Boolean.toString(TRANSACTED_DEFAULT)); setSystemPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT); setSystemPropertyIfNull(VIRTUAL_PATH_PROPNAME, VIRTUAL_PATH_DEFAULT); setSystemPropertyIfNull(TIMEOUT_PROPNAME, Long.toString(TIMEOUT_DEFAULT)); - setSystemPropertyIfNull(PING_QUEUE_COUNT_PROPNAME, Integer.toString(1)); + setSystemPropertyIfNull(PING_DESTINATION_COUNT_PROPNAME, Integer.toString(1)); setSystemPropertyIfNull(VERBOSE_OUTPUT_PROPNAME, Boolean.toString(false)); setSystemPropertyIfNull(RATE_PROPNAME, Integer.toString(RATE_DEFAULT)); + setSystemPropertyIfNull(IS_PUBSUB_PROPNAME, Boolean.toString(false)); } /** @@ -244,14 +249,15 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll String username = "guest"; String password = "guest"; String virtualpath = testParameters.getProperty(VIRTUAL_PATH_PROPNAME); - int queueCount = Integer.parseInt(testParameters.getProperty(PING_QUEUE_COUNT_PROPNAME)); - String queueName = testParameters.getProperty(PING_QUEUE_NAME_PROPNAME); + int destinationscount = Integer.parseInt(testParameters.getProperty(PING_DESTINATION_COUNT_PROPNAME)); + String destinationname = testParameters.getProperty(PING_DESTINATION_NAME_PROPNAME); boolean persistent = Boolean.parseBoolean(testParameters.getProperty(PERSISTENT_MODE_PROPNAME)); boolean transacted = Boolean.parseBoolean(testParameters.getProperty(TRANSACTED_PROPNAME)); String selector = null; boolean verbose = Boolean.parseBoolean(testParameters.getProperty(VERBOSE_OUTPUT_PROPNAME)); int messageSize = Integer.parseInt(testParameters.getProperty(MESSAGE_SIZE_PROPNAME)); int rate = Integer.parseInt(testParameters.getProperty(RATE_PROPNAME)); + boolean pubsub = Boolean.parseBoolean(testParameters.getProperty(IS_PUBSUB_PROPNAME)); boolean afterCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_COMMIT)); boolean beforeCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_COMMIT)); @@ -263,14 +269,14 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll // This is synchronized because there is a race condition, which causes one connection to sleep if // all threads try to create connection concurrently - synchronized (this) + synchronized (_lock) { - // Establish a client to ping a Queue and listen the reply back from same Queue + // Establish a client to ping a Destination and listen the reply back from same Destination perThreadSetup._pingItselfClient = new TestPingItself(brokerDetails, username, password, virtualpath, - queueName, selector, transacted, persistent, + destinationname, selector, transacted, persistent, messageSize, verbose, afterCommit, beforeCommit, - afterSend, beforeSend, failOnce, batchSize, queueCount, - rate); + afterSend, beforeSend, failOnce, batchSize, destinationscount, + rate, pubsub); } // Start the client connection perThreadSetup._pingItselfClient.getConnection().start(); diff --git a/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java b/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java index 1252871d2c..fca133c425 100644 --- a/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java +++ b/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java @@ -1,6 +1,5 @@ package org.apache.qpid.requestreply; -import java.net.InetAddress; import java.util.Properties; import javax.jms.*; @@ -10,7 +9,6 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.apache.log4j.Logger; -import org.apache.log4j.NDC; import uk.co.thebadgerset.junit.extensions.AsymptoticTestCase; @@ -47,12 +45,12 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont /** * Holds the name of the property to get the test message size from. */ - private static final String MESSAGE_SIZE_PROPNAME = "messageSize"; + private static final String MESSAGE_SIZE_PROPNAME = "messagesize"; /** * Holds the name of the property to get the ping queue name from. */ - private static final String PING_QUEUE_NAME_PROPNAME = "pingQueue"; + private static final String PING_QUEUE_NAME_PROPNAME = "destinationname"; /** * Holds the name of the property to get the test delivery mode from. @@ -79,6 +77,8 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont */ private static final int MESSAGE_SIZE_DEFAULT = 0; + private static final int BATCH_SIZE_DEFAULT = 2; + /** * Holds the name of the queue to which pings are sent. */ @@ -112,6 +112,11 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont /** Holds the name of the property to get the message rate from. */ private static final String RATE_PROPNAME = "rate"; + private static final String VERBOSE_OUTPUT_PROPNAME = "verbose"; + + /** Holds the true or false depending on wether it is P2P test or PubSub */ + private static final String IS_PUBSUB_PROPNAME = "pubsub"; + /** Holds the default rate. A value of zero means infinity, only values of 1 or greater are meaningfull. */ private static final int RATE_DEFAULT = 0; @@ -126,6 +131,7 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont * Thread local to hold the per-thread test setup fields. */ ThreadLocal threadSetup = new ThreadLocal(); + Object _lock = new Object(); // Set up a property reader to extract the test parameters from. Once ContextualProperties is available in // the project dependencies, use it to get property overrides for configurable tests and to notify the test runner @@ -138,13 +144,16 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont super(name); // Sets up the test parameters with defaults. + setSystemPropertyIfNull(BATCH_SIZE, Integer.toString(BATCH_SIZE_DEFAULT)); setSystemPropertyIfNull(MESSAGE_SIZE_PROPNAME, Integer.toString(MESSAGE_SIZE_DEFAULT)); setSystemPropertyIfNull(PING_QUEUE_NAME_PROPNAME, PING_QUEUE_NAME_DEFAULT); setSystemPropertyIfNull(PERSISTENT_MODE_PROPNAME, Boolean.toString(PERSISTENT_MODE_DEFAULT)); setSystemPropertyIfNull(TRANSACTED_PROPNAME, Boolean.toString(TRANSACTED_DEFAULT)); setSystemPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT); setSystemPropertyIfNull(VIRTUAL_PATH_PROPNAME, VIRTUAL_PATH_DEFAULT); + setSystemPropertyIfNull(VERBOSE_OUTPUT_PROPNAME, Boolean.toString(false)); setSystemPropertyIfNull(RATE_PROPNAME, Integer.toString(RATE_DEFAULT)); + setSystemPropertyIfNull(IS_PUBSUB_PROPNAME, Boolean.toString(false)); } /** @@ -176,7 +185,7 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont // Generate a sample message. This message is already time stamped and has its reply-to destination set. ObjectMessage msg = - perThreadSetup._testPingProducer.getTestMessage(perThreadSetup._testPingProducer.getReplyQueue(), + perThreadSetup._testPingProducer.getTestMessage(perThreadSetup._testPingProducer.getReplyDestination(), Integer.parseInt(testParameters.getProperty( MESSAGE_SIZE_PROPNAME)), Boolean.parseBoolean(testParameters.getProperty( @@ -217,9 +226,10 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont boolean persistent = Boolean.parseBoolean(testParameters.getProperty(PERSISTENT_MODE_PROPNAME)); boolean transacted = Boolean.parseBoolean(testParameters.getProperty(TRANSACTED_PROPNAME)); String selector = null; - boolean verbose = false; + boolean verbose = Boolean.parseBoolean(testParameters.getProperty(VERBOSE_OUTPUT_PROPNAME)); int messageSize = Integer.parseInt(testParameters.getProperty(MESSAGE_SIZE_PROPNAME)); int rate = Integer.parseInt(testParameters.getProperty(RATE_PROPNAME)); + boolean pubsub = Boolean.parseBoolean(testParameters.getProperty(IS_PUBSUB_PROPNAME)); boolean afterCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_COMMIT)); boolean beforeCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_COMMIT)); @@ -228,20 +238,23 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont int batchSize = Integer.parseInt(testParameters.getProperty(BATCH_SIZE)); Boolean failOnce = Boolean.parseBoolean(testParameters.getProperty(FAIL_ONCE)); - // Establish a bounce back client on the ping queue to bounce back the pings. - perThreadSetup._testPingBouncer = new PingPongBouncer(brokerDetails, username, password, virtualpath, queueName, - persistent, transacted, selector, verbose); + synchronized(_lock) + { + // Establish a bounce back client on the ping queue to bounce back the pings. + perThreadSetup._testPingBouncer = new PingPongBouncer(brokerDetails, username, password, virtualpath, + queueName, persistent, transacted, selector, verbose, pubsub); - // Start the connections for client and producer running. - perThreadSetup._testPingBouncer.getConnection().start(); + // Start the connections for client and producer running. + perThreadSetup._testPingBouncer.getConnection().start(); - // Establish a ping-pong client on the ping queue to send the pings with. - perThreadSetup._testPingProducer = new PingPongProducer(brokerDetails, username, password, virtualpath, + // Establish a ping-pong client on the ping queue to send the pings with. + + perThreadSetup._testPingProducer = new PingPongProducer(brokerDetails, username, password, virtualpath, queueName, selector, transacted, persistent, messageSize, verbose, afterCommit, beforeCommit, afterSend, - beforeSend, failOnce, batchSize, 0, rate); - - perThreadSetup._testPingProducer.getConnection().start(); + beforeSend, failOnce, batchSize, 0, rate, pubsub); + perThreadSetup._testPingProducer.getConnection().start(); + } // Attach the per-thread set to the thread. threadSetup.set(perThreadSetup); -- cgit v1.2.1