You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2009/11/11 01:13:14 UTC
svn commit: r834721 - in /qpid/trunk/qpid/java/testkit: bin/
src/main/java/org/apache/qpid/testkit/perf/
src/main/java/org/apache/qpid/testkit/soak/
Author: rajith
Date: Wed Nov 11 00:13:13 2009
New Revision: 834721
URL: http://svn.apache.org/viewvc?rev=834721&view=rev
Log:
Removed the following files as they will be replaced by a generic Sender and Receiver.
The bin files and the files under o/a/qpid/teskit/perf are moved under tools.
Removed:
qpid/trunk/qpid/java/testkit/bin/perf_report.sh
qpid/trunk/qpid/java/testkit/bin/run_pub.sh
qpid/trunk/qpid/java/testkit/bin/run_sub.sh
qpid/trunk/qpid/java/testkit/bin/setenv.sh
qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/perf/
qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/BaseTest.java
qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/MultiThreadedConsumer.java
qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/MultiThreadedProducer.java
qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/SimpleConsumer.java
qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/SimpleProducer.java
Modified:
qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/ResourceLeakTest.java
Modified: qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/ResourceLeakTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/ResourceLeakTest.java?rev=834721&r1=834720&r2=834721&view=diff
==============================================================================
--- qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/ResourceLeakTest.java (original)
+++ qpid/trunk/qpid/java/testkit/src/main/java/org/apache/qpid/testkit/soak/ResourceLeakTest.java Wed Nov 11 00:13:13 2009
@@ -21,6 +21,8 @@
package org.apache.qpid.testkit.soak;
+import java.util.Random;
+
import javax.jms.BytesMessage;
import javax.jms.Destination;
import javax.jms.MessageConsumer;
@@ -29,7 +31,11 @@
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.BasicMessageConsumer;
+import org.apache.qpid.client.BasicMessageProducer;
import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.testkit.TestLauncher;
import org.apache.qpid.thread.Threading;
/**
@@ -37,8 +43,9 @@
* ================
* This test will open x number of connections where each
* connection will create a session and a producer/consumer pair,
- * and then send configurable no of messages.
- * It will them sleep for configurable time interval and
+ * and then a randomly selected set of connections (about 1/4th)
+ * will send a configurable no of messages and try to receive them.
+ * It will then sleep for configurable time interval and
* tear down the connections/sessions/consumers.
* It will then repeat the process again until the test is stopped.
*
@@ -47,16 +54,14 @@
* To find if the broker has leaks when cleaning resources.
* To find if the client has leaks with resources.
*/
-public class ResourceLeakTest extends BaseTest
+public class ResourceLeakTest extends TestLauncher
{
- protected int connection_count = 10;
- protected long connection_idle_time = 5000;
-
+ /* protected long connection_idle_time = 5000;
+ protected Random rand = new Random();
+
public ResourceLeakTest()
{
- super();
- connection_count = Integer.getInteger("con_count",10);
- connection_idle_time = Long.getLong("con_idle_time", 5000);
+ super();
}
public void test()
@@ -68,13 +73,7 @@
Session[] sessions = new Session[connection_count];
MessageConsumer[] msgCons = new MessageConsumer[connection_count];
MessageProducer [] msgProds = new MessageProducer[connection_count];
- Destination dest = new AMQQueue(new AMQShortString(exchange_name),
- new AMQShortString(routing_key),
- new AMQShortString(queue_name),
- true, //exclusive
- true // auto delete
- );
-
+
while (true)
{
for (int i = 0; i < connection_count; i++)
@@ -84,23 +83,36 @@
cons[i] = con;
Session ssn = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
sessions[i] = ssn;
+ Destination dest = new AMQQueue(new AMQShortString(exchange_name),
+ new AMQShortString(routing_key + i),
+ new AMQShortString(queue_name + i),
+ true, //exclusive
+ true // auto delete
+ );
MessageConsumer msgCon = ssn.createConsumer(dest);
msgCons[i] = msgCon;
MessageProducer msgProd = ssn.createProducer(dest);
msgProds[i] = msgProd;
-
- BytesMessage msg = ssn.createBytesMessage();
+ }
+
+ // Select some connections randomly and send/recv messages
+ // Exercise around quarter of the connections
+ for (int i=0; i < connection_count/4; i++)
+ {
+ int k = rand.nextInt(connection_count);
+
+ BytesMessage msg = sessions[k].createBytesMessage();
msg.writeBytes("Test Msg".getBytes());
for (int j = 0; j < msg_count;j++)
{
- msgProd.send(msg);
+ msgProds[k].send(msg);
}
int j = 0;
while (j < msg_count)
{
- msgCon.receive();
+ msgCons[k].receive();
j++;
}
}
@@ -111,10 +123,24 @@
{
for (int i = 0; i < connection_count; i++)
{
- msgCons[i].close();
- msgProds[i].close();
- sessions[i].close();
- cons[i].close();
+ if (!((BasicMessageConsumer)msgCons[i]).isClosed())
+ {
+ msgCons[i].close();
+ }
+
+ if (!((BasicMessageProducer)msgProds[i]).isClosed())
+ {
+ msgProds[i].close();
+ }
+
+ if (!((AMQSession)sessions[i]).isClosed())
+ {
+ sessions[i].close();
+ }
+ if (!((AMQConnection)cons[i]).isClosed())
+ {
+ cons[i].close();
+ }
}
}
catch (Exception e)
@@ -149,6 +175,6 @@
{
throw new Error("Error creating test thread",e);
}
- }
+ }*/
}
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org