diff options
| author | Robert Greig <rgreig@apache.org> | 2007-01-23 17:08:03 +0000 |
|---|---|---|
| committer | Robert Greig <rgreig@apache.org> | 2007-01-23 17:08:03 +0000 |
| commit | bc4c9900650e2d306432493751f3e84f7b09e8e3 (patch) | |
| tree | 114a978eb66ea97df9de3192539d0f247ee46d84 /java/perftests/src/test | |
| parent | b076114507d5c838ecf3d10f1f2dbea78a35f139 (diff) | |
| download | qpid-python-bc4c9900650e2d306432493751f3e84f7b09e8e3.tar.gz | |
(Patch submitted by Rupert Smith) Added the ability to limit the rate at which messages are sent by the ping tests.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@499083 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.java | 35 | ||||
| -rw-r--r-- | java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java | 57 |
2 files changed, 50 insertions, 42 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 d476080720..c9896ce063 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 @@ -75,10 +75,13 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll private static final String VIRTUAL_PATH_PROPNAME = "virtualPath";
/**
- * Holds the waiting timeout for response messages
+ * Holds the name of the property to get the waiting timeout for response messages.
*/
private static final String TIMEOUT_PROPNAME = "timeout";
+ /** 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";
/**
@@ -118,6 +121,8 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll */
private static final long TIMEOUT_DEFAULT = 3000;
+ /** 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;
private static final String FAIL_AFTER_COMMIT = "FailAfterCommit";
private static final String FAIL_BEFORE_COMMIT = "FailBeforeCommit";
@@ -126,7 +131,6 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll private static final String BATCH_SIZE = "BatchSize";
private static final String FAIL_ONCE = "FailOnce";
-
/**
* Thread local to hold the per-thread test setup fields.
*/
@@ -138,13 +142,11 @@ 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");
@@ -161,6 +163,7 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll setSystemPropertyIfNull(TIMEOUT_PROPNAME, Long.toString(TIMEOUT_DEFAULT));
setSystemPropertyIfNull(PING_QUEUE_COUNT_PROPNAME, Integer.toString(1));
setSystemPropertyIfNull(VERBOSE_OUTPUT_PROPNAME, Boolean.toString(false));
+ setSystemPropertyIfNull(RATE_PROPNAME, Integer.toString(RATE_DEFAULT));
}
/**
@@ -175,7 +178,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)
@@ -202,11 +205,11 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll // 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));
@@ -215,7 +218,8 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll // Fail the test if the timeout was exceeded.
if (numReplies != numPings)
{
- Assert.fail("The ping timed out after "+ timeout + " ms. Messages Sent = " + numPings + ", MessagesReceived = " + numReplies);
+ Assert.fail("The ping timed out after " + timeout + " ms. Messages Sent = " + numPings + ", MessagesReceived = "
+ + numReplies);
}
}
@@ -243,6 +247,7 @@ public class PingTestPerf extends AsymptoticTestCase //implements TimingControll 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 afterCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_COMMIT));
boolean beforeCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_COMMIT));
@@ -254,14 +259,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 (this)
{
// 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,
- afterCommit, beforeCommit, afterSend, beforeSend, failOnce,
- batchSize, queueCount);
+ messageSize, verbose, afterCommit, beforeCommit,
+ afterSend, beforeSend, failOnce, batchSize, queueCount,
+ rate);
}
// 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 df0508c881..1252871d2c 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 @@ -109,16 +109,18 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont */
private static final long TIMEOUT = 15000;
- // 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);
- }
+ /** Holds the name of the property to get the message rate from. */
+ private static final String RATE_PROPNAME = "rate";
+
+ /** 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;
+
+ 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";
+ private static final String FAIL_ONCE = "FailOnce";
/**
* Thread local to hold the per-thread test setup fields.
@@ -131,17 +133,18 @@ 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";
- private static final String FAIL_ONCE = "FailOnce";
-
-
public PingPongTestPerf(String name)
{
super(name);
+
+ // Sets up the test parameters with defaults.
+ 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(RATE_PROPNAME, Integer.toString(RATE_DEFAULT));
}
/**
@@ -173,11 +176,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.
@@ -216,6 +219,7 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont String selector = null;
boolean verbose = false;
int messageSize = Integer.parseInt(testParameters.getProperty(MESSAGE_SIZE_PROPNAME));
+ int rate = Integer.parseInt(testParameters.getProperty(RATE_PROPNAME));
boolean afterCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_COMMIT));
boolean beforeCommit = Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_COMMIT));
@@ -234,9 +238,8 @@ 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,
- afterCommit, beforeCommit, afterSend, beforeSend, failOnce,
- batchSize, 0);
+ verbose, afterCommit, beforeCommit, afterSend,
+ beforeSend, failOnce, batchSize, 0, rate);
perThreadSetup._testPingProducer.getConnection().start();
@@ -253,7 +256,7 @@ public class PingPongTestPerf extends AsymptoticTestCase //implements TimingCont {
_testPingBouncer.getConnection().close();
}
-
+
if ((_testPingProducer != null) && (_testPingProducer.getConnection() != null))
{
_testPingProducer.getConnection().close();
|
