summaryrefslogtreecommitdiff
path: root/java/perftests/src/test
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2007-01-23 09:39:56 +0000
committerMartin Ritchie <ritchiem@apache.org>2007-01-23 09:39:56 +0000
commit2d02ef0b32ef823e33317271adb430db7aa5edb4 (patch)
tree81714605e5d93959990de593b15513be23b8cd95 /java/perftests/src/test
parent19d23d9e5882d8a487fa03d561b80513c5c0b71d (diff)
downloadqpid-python-2d02ef0b32ef823e33317271adb430db7aa5edb4.tar.gz
Added ability to cause failover before/after commit/sends
Added batch size ability. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@498965 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/perftests/src/test')
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java158
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java117
2 files changed, 196 insertions, 79 deletions
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 ef34b92265..e416d31031 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
@@ -13,23 +13,22 @@ import org.apache.log4j.Logger;
import uk.co.thebadgerset.junit.extensions.AsymptoticTestCase;
/**
- *
* PingTestPerf is a ping test, that has been written with the intention of being scaled up to run many times
* simultaneously to simluate many clients/producers/connections.
- *
+ * <p/>
* <p/>A single run of the test using the default JUnit test runner will result in the sending and timing of a single
* full round trip ping. This test may be scaled up using a suitable JUnit test runner.
- *
+ * <p/>
* <p/>The setup/teardown cycle establishes a connection to a broker and sets up a queue to send ping messages to and a
* temporary queue for replies. This setup is only established once for all the test repeats/threads that may be run,
* except if the connection is lost in which case an attempt to re-establish the setup is made.
- *
+ * <p/>
* <p/>The test cycle is: Connects to a queue, creates a temporary queue, creates messages containing a property that
* is the name of the temporary queue, fires off a message on the original queue and waits for a response on the
* temporary queue.
- *
+ * <p/>
* <p/>Configurable test properties: message size, transacted or not, persistent or not. Broker connection details.
- *
+ * <p/>
* <p><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
* </table>
@@ -40,65 +39,95 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll
{
private static Logger _logger = Logger.getLogger(PingTestPerf.class);
- /** Holds the name of the property to get the test message size from. */
+ /**
+ * Holds the name of the property to get the test message size from.
+ */
private static final String MESSAGE_SIZE_PROPNAME = "messageSize";
- /** Holds the name of the property to get the ping queue name from. */
+ /**
+ * Holds the name of the property to get the ping queue name from.
+ */
private static final String PING_QUEUE_NAME_PROPNAME = "pingQueue";
- /** holds the queue count, if the test is being performed with multiple queues */
+ /**
+ * holds the queue count, if the test is being performed with multiple queues
+ */
private static final String PING_QUEUE_COUNT_PROPNAME = "queues";
- /** Holds the name of the property to get the test delivery mode from. */
+ /**
+ * Holds the name of the property to get the test delivery mode from.
+ */
private static final String PERSISTENT_MODE_PROPNAME = "persistent";
- /** Holds the name of the property to get the test transactional mode from. */
+ /**
+ * Holds the name of the property to get the test transactional mode from.
+ */
private static final String TRANSACTED_PROPNAME = "transacted";
- /** Holds the name of the property to get the test broker url from. */
+ /**
+ * Holds the name of the property to get the test broker url from.
+ */
private static final String BROKER_PROPNAME = "broker";
- /** Holds the name of the property to get the test broker virtual path. */
+ /**
+ * Holds the name of the property to get the test broker virtual path.
+ */
private static final String VIRTUAL_PATH_PROPNAME = "virtualPath";
- /** Holds the waiting timeout for response messages */
+ /**
+ * Holds the waiting timeout for response messages
+ */
private static final String TIMEOUT_PROPNAME = "timeout";
- /** Holds the size of message body to attach to the ping messages. */
+ /**
+ * Holds the size of message body to attach to the ping messages.
+ */
private static final int MESSAGE_SIZE_DEFAULT = 0;
- /** Holds the name of the queue to which pings are sent. */
+ private static final int BATCH_SIZE_DEFAULT = 2;
+
+ /**
+ * Holds the name of the queue to which pings are sent.
+ */
private static final String PING_QUEUE_NAME_DEFAULT = "ping";
- /** Holds the message delivery mode to use for the test. */
+ /**
+ * Holds the message delivery mode to use for the test.
+ */
private static final boolean PERSISTENT_MODE_DEFAULT = false;
- /** Holds the transactional mode to use for the test. */
+ /**
+ * Holds the transactional mode to use for the test.
+ */
private static final boolean TRANSACTED_DEFAULT = false;
- /** Holds the default broker url for the test. */
+ /**
+ * Holds the default broker url for the test.
+ */
private static final String BROKER_DEFAULT = "tcp://localhost:5672";
- /** Holds the default virtual path for the test. */
+ /**
+ * Holds the default virtual path for the test.
+ */
private static final String VIRTUAL_PATH_DEFAULT = "/test";
- /** Sets a default ping timeout. */
+ /**
+ * Sets a default ping timeout.
+ */
private static final long TIMEOUT_DEFAULT = 3000;
- // Sets up the test parameters with defaults.
- static
- {
- 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(TIMEOUT_PROPNAME, Long.toString(TIMEOUT_DEFAULT));
- setSystemPropertyIfNull(PING_QUEUE_COUNT_PROPNAME, Integer.toString(1));
- }
- /** Thread local to hold the per-thread test setup fields. */
+ private static final String FAIL_AFTER_COMMIT = "FailAfterCommit";
+ private static final String FAIL_BEFORE_COMMIT = "FailBeforeCommit";
+ private static final String FAIL_AFTER_SEND = "FailAfterSend";
+ private static final String FAIL_BEFORE_SEND = "FailBeforeSend";
+ private static final String BATCH_SIZE = "BatchSize";
+
+
+
+ /**
+ * Thread local to hold the per-thread test setup fields.
+ */
ThreadLocal<PerThreadSetup> threadSetup = new ThreadLocal<PerThreadSetup>();
// Set up a property reader to extract the test parameters from. Once ContextualProperties is available in
@@ -107,9 +136,27 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll
private Properties testParameters = System.getProperties();
//private Properties testParameters = new ContextualProperties(System.getProperties());
+
public PingTestPerf(String name)
{
super(name);
+ // Sets up the test parameters with defaults.
+
+
+ setSystemPropertyIfNull(FAIL_AFTER_COMMIT, "false");
+ setSystemPropertyIfNull(FAIL_BEFORE_COMMIT, "false");
+ setSystemPropertyIfNull(FAIL_AFTER_SEND, "false");
+ setSystemPropertyIfNull(FAIL_BEFORE_SEND, "false");
+
+ 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(TIMEOUT_PROPNAME, Long.toString(TIMEOUT_DEFAULT));
+ setSystemPropertyIfNull(PING_QUEUE_COUNT_PROPNAME, Integer.toString(1));
}
/**
@@ -124,7 +171,7 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll
suite.addTest(new PingTestPerf("testPingOk"));
return suite;
- //return new junit.framework.TestSuite(PingTestPerf.class);
+ //return new junit.framework.TestSuite(PingTestPerf.class);
}
private static void setSystemPropertyIfNull(String propName, String propValue)
@@ -135,18 +182,28 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll
}
}
+ public void testPing(int jim) throws Exception
+ {
+ testPingOk(1);
+ }
+
public void testPingOk(int numPings) throws Exception
{
// Get the per thread test setup to run the test through.
PerThreadSetup perThreadSetup = threadSetup.get();
+ if (numPings == 0)
+ {
+ _logger.error("Number of pings requested was zero.");
+ }
+
// Generate a sample message. This message is already time stamped and has its reply-to destination set.
ObjectMessage msg =
- perThreadSetup._pingItselfClient.getTestMessage(null,
- Integer.parseInt(testParameters.getProperty(
- MESSAGE_SIZE_PROPNAME)),
- Boolean.parseBoolean(testParameters.getProperty(
- PERSISTENT_MODE_PROPNAME)));
+ perThreadSetup._pingItselfClient.getTestMessage(null,
+ Integer.parseInt(testParameters.getProperty(
+ MESSAGE_SIZE_PROPNAME)),
+ Boolean.parseBoolean(testParameters.getProperty(
+ PERSISTENT_MODE_PROPNAME)));
// start the test
long timeout = Long.parseLong(testParameters.getProperty(TIMEOUT_PROPNAME));
@@ -185,20 +242,31 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll
boolean verbose = false;
int messageSize = Integer.parseInt(testParameters.getProperty(MESSAGE_SIZE_PROPNAME));
+ boolean afterCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_COMMIT));
+ boolean beforeCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_COMMIT));
+ boolean afterSend = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_SEND));
+ boolean beforeSend = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_SEND));
+
+ int batchSize = Integer.parseInt(testParameters.getProperty(BATCH_SIZE));
+
// Establish a client to ping a Queue and listen the reply back from same Queue
if (queueCount > 1)
{
// test client with multiple queues
perThreadSetup._pingItselfClient = new TestPingItself(brokerDetails, username, password, virtualpath,
- queueCount, selector, transacted, persistent,
- messageSize, verbose);
+ selector, transacted, persistent,
+ messageSize, verbose,
+ afterCommit, beforeCommit, afterSend, beforeSend,
+ batchSize, queueCount);
}
else
{
// Establish a client to ping a Queue and listen the reply back from same Queue
perThreadSetup._pingItselfClient = new TestPingItself(brokerDetails, username, password, virtualpath,
queueName, selector, transacted, persistent,
- messageSize, verbose);
+ messageSize, verbose,
+ afterCommit, beforeCommit, afterSend, beforeSend,
+ batchSize);
}
// Start the client connection
@@ -228,7 +296,9 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll
private static class PerThreadSetup
{
- /** Holds the test ping client. */
+ /**
+ * Holds the test ping client.
+ */
private TestPingItself _pingItselfClient;
}
}
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 f553faf302..3e1035ce05 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
@@ -18,22 +18,22 @@ import uk.co.thebadgerset.junit.extensions.AsymptoticTestCase;
* PingPongTestPerf is a full round trip ping test, that has been written with the intention of being scaled up to run
* many times simultaneously to simluate many clients/producer/connections. A full round trip ping sends a message from
* a producer to a conumer, then the consumer replies to the message on a temporary queue.
- *
+ * <p/>
* <p/>A single run of the test using the default JUnit test runner will result in the sending and timing of the number
* of pings specified by the test size and time how long it takes for all of these to complete. This test may be scaled
* up using a suitable JUnit test runner. See {@link TKTestRunner} or {@link PPTestRunner} for more information on how
* to do this.
- *
+ * <p/>
* <p/>The setup/teardown cycle establishes a connection to a broker and sets up a queue to send ping messages to and a
* temporary queue for replies. This setup is only established once for all the test repeats, but each test threads
* gets its own connection/producer/consumer, this is only re-established if the connection is lost.
- *
+ * <p/>
* <p/>The test cycle is: Connects to a queue, creates a temporary queue, creates messages containing a property that
* is the name of the temporary queue, fires off many messages on the original queue and waits for them all to come
* back on the temporary queue.
- *
+ * <p/>
* <p/>Configurable test properties: message size, transacted or not, persistent or not. Broker connection details.
- *
+ * <p/>
* <p><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
* </table>
@@ -44,43 +44,69 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont
{
private static Logger _logger = Logger.getLogger(PingPongTestPerf.class);
- /** Holds the name of the property to get the test message size from. */
+ /**
+ * Holds the name of the property to get the test message size from.
+ */
private static final String MESSAGE_SIZE_PROPNAME = "messageSize";
- /** Holds the name of the property to get the ping queue name from. */
+ /**
+ * Holds the name of the property to get the ping queue name from.
+ */
private static final String PING_QUEUE_NAME_PROPNAME = "pingQueue";
- /** Holds the name of the property to get the test delivery mode from. */
+ /**
+ * Holds the name of the property to get the test delivery mode from.
+ */
private static final String PERSISTENT_MODE_PROPNAME = "persistent";
- /** Holds the name of the property to get the test transactional mode from. */
+ /**
+ * Holds the name of the property to get the test transactional mode from.
+ */
private static final String TRANSACTED_PROPNAME = "transacted";
- /** Holds the name of the property to get the test broker url from. */
+ /**
+ * Holds the name of the property to get the test broker url from.
+ */
private static final String BROKER_PROPNAME = "broker";
- /** Holds the name of the property to get the test broker virtual path. */
+ /**
+ * Holds the name of the property to get the test broker virtual path.
+ */
private static final String VIRTUAL_PATH_PROPNAME = "virtualPath";
- /** Holds the size of message body to attach to the ping messages. */
+ /**
+ * Holds the size of message body to attach to the ping messages.
+ */
private static final int MESSAGE_SIZE_DEFAULT = 0;
- /** Holds the name of the queue to which pings are sent. */
+ /**
+ * Holds the name of the queue to which pings are sent.
+ */
private static final String PING_QUEUE_NAME_DEFAULT = "ping";
- /** Holds the message delivery mode to use for the test. */
+ /**
+ * Holds the message delivery mode to use for the test.
+ */
private static final boolean PERSISTENT_MODE_DEFAULT = false;
- /** Holds the transactional mode to use for the test. */
+ /**
+ * Holds the transactional mode to use for the test.
+ */
private static final boolean TRANSACTED_DEFAULT = false;
- /** Holds the default broker url for the test. */
+ /**
+ * Holds the default broker url for the test.
+ */
private static final String BROKER_DEFAULT = "tcp://localhost:5672";
- /** Holds the default virtual path for the test. */
+ /**
+ * Holds the default virtual path for the test.
+ */
private static final String VIRTUAL_PATH_DEFAULT = "/test";
- /** Sets a default ping timeout. */
+ /**
+ * Sets a default ping timeout.
+ */
private static final long TIMEOUT = 15000;
// Sets up the test parameters with defaults.
@@ -94,7 +120,9 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont
setSystemPropertyIfNull(VIRTUAL_PATH_PROPNAME, VIRTUAL_PATH_DEFAULT);
}
- /** Thread local to hold the per-thread test setup fields. */
+ /**
+ * Thread local to hold the per-thread test setup fields.
+ */
ThreadLocal<PerThreadSetup> threadSetup = new ThreadLocal<PerThreadSetup>();
// Set up a property reader to extract the test parameters from. Once ContextualProperties is available in
@@ -103,6 +131,13 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont
private Properties testParameters = System.getProperties();
//private Properties testParameters = new ContextualProperties(System.getProperties());
+ private static final String FAIL_AFTER_COMMIT = "FailAfterCommit";
+ private static final String FAIL_BEFORE_COMMIT = "FailBeforeCommit";
+ private static final String FAIL_AFTER_SEND = "FailAfterSend";
+ private static final String FAIL_BEFORE_SEND = "FailBeforeSend";
+ private static final String BATCH_SIZE = "BatchSize";
+
+
public PingPongTestPerf(String name)
{
super(name);
@@ -137,11 +172,11 @@ 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(),
- Integer.parseInt(testParameters.getProperty(
- MESSAGE_SIZE_PROPNAME)),
- Boolean.parseBoolean(testParameters.getProperty(
- PERSISTENT_MODE_PROPNAME)));
+ perThreadSetup._testPingProducer.getTestMessage(perThreadSetup._testPingProducer.getReplyQueue(),
+ Integer.parseInt(testParameters.getProperty(
+ MESSAGE_SIZE_PROPNAME)),
+ Boolean.parseBoolean(testParameters.getProperty(
+ PERSISTENT_MODE_PROPNAME)));
// Use the test timing controller to reset the test timer now and obtain the current time.
// This can be used to remove the message creation time from the test.
@@ -181,6 +216,12 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont
boolean verbose = false;
int messageSize = Integer.parseInt(testParameters.getProperty(MESSAGE_SIZE_PROPNAME));
+ boolean afterCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_COMMIT));
+ boolean beforeCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_COMMIT));
+ boolean afterSend = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_SEND));
+ boolean beforeSend = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_SEND));
+ int batchSize = Integer.parseInt(testParameters.getProperty(BATCH_SIZE));
+
// 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);
@@ -191,7 +232,9 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont
// 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);
+ verbose,
+ afterCommit, beforeCommit, afterSend, beforeSend,
+ batchSize, 0);
perThreadSetup._testPingProducer.getConnection().start();
@@ -205,14 +248,14 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont
try
{
/**if ((_testPingBouncer != null) && (_testPingBouncer.getConnection() != null))
- {
- _testPingBouncer.getConnection().close();
- }
-
- if ((_testPingProducer != null) && (_testPingProducer.getConnection() != null))
- {
- _testPingProducer.getConnection().close();
- }*/
+ {
+ _testPingBouncer.getConnection().close();
+ }
+
+ if ((_testPingProducer != null) && (_testPingProducer.getConnection() != null))
+ {
+ _testPingProducer.getConnection().close();
+ }*/
}
finally
{
@@ -222,10 +265,14 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont
private static class PerThreadSetup
{
- /** Holds the test ping-pong producer. */
+ /**
+ * Holds the test ping-pong producer.
+ */
private PingPongProducer _testPingProducer;
- /** Holds the test ping client. */
+ /**
+ * Holds the test ping client.
+ */
private PingPongBouncer _testPingBouncer;
}
}