Commit 6297bc07 authored by Andre Freyssinet's avatar Andre Freyssinet
Browse files

Tests queue loading with a big number of waiting messages (Joram-358).

parent ff1d25c4
......@@ -6,3 +6,4 @@ org.ow2.joram.jdbc.transaction.dbname=MyJoramDB@@sid@@
org.ow2.joram.jdbc.transaction.user=user1
org.ow2.joram.jdbc.transaction.password=pass1
org.ow2.joram.jdbc.transaction.dbinit=CREATE TABLE MyTable (name VARCHAR(256), content BLOB(16M), PRIMARY KEY(name))
org.objectweb.joram.mom.messages.USELOADALL=true
\ No newline at end of file
......@@ -4741,7 +4741,7 @@
</antcall>
</target>
<target name="noreg.test57" depends="noreg.test57-1,noreg.test57-2,noreg.test57-3,noreg.test57-4,noreg.test57-3-jdbc,noreg.test57-4-jdbc"/>
<target name="noreg.test57" depends="noreg.test57-1,noreg.test57-2,noreg.test57-3,noreg.test57-4,noreg.test57-3-jdbc,noreg.test57-4-jdbc,noreg.test57b"/>
<target name="noreg.test57-1" depends="init.a3props,compile"
description=" --> Test server restart with a lot of big messages">
......@@ -4821,6 +4821,64 @@
</antcall>
</target>
<target name="noreg.test57b" depends="noreg.test57b-3,noreg.test57b-4,noreg.test57b-3-jdbc,noreg.test57b-4-jdbc"/>
<target name="noreg.test57b-3" depends="init.a3props,compile"
description=" --> Test server restart with a very big number of normal (1Kb) messages">
<!-- Use tuned NGTransaction configuration to avoid garbage -->
<antcall target="test.run" inheritAll="true">
<param name="className" value="joram.noreg.Test57b"/>
<param name="jndiconf" value="noreg/jndi.properties"/>
<param name="a3conf" value="noreg/a3servers2.xml"/>
<param name="testid" value="noreg.test57b-3"/>
<param name="jvmargs" value="-DswapAllowed=true -DDestination=org.objectweb.joram.client.jms.Queue -DMsgSize=1 -DNbMsg=100000"/>
</antcall>
</target>
<target name="noreg.test57b-4" depends="init.a3props,compile"
description=" --> Test server restart with a very big number of normal (1Kb) messages">
<!-- Use tuned NGTransaction configuration to avoid garbage, and fixedInMemory to force queue load at starting -->
<antcall target="test.run" inheritAll="true">
<param name="className" value="joram.noreg.Test57b"/>
<param name="jndiconf" value="noreg/jndi.properties"/>
<param name="a3conf" value="noreg/a3servers2.xml"/>
<param name="testid" value="noreg.test57b-4"/>
<param name="jvmargs" value="-DswapAllowed=true -DDestination=org.objectweb.joram.client.jms.Queue -DMsgSize=1 -DfixedInMemory=true -DNbMsg=100000"/>
</antcall>
</target>
<target name="noreg.test57b-3-jdbc" depends="init.a3props,compile"
description=" --> Test server restart with a very big number of normal (1Kb) messages">
<!-- Use JDBC Transaction configuration -->
<antcall target="test.run" inheritAll="true">
<param name="className" value="joram.noreg.Test57b"/>
<param name="jndiconf" value="noreg/jndi.properties"/>
<param name="a3conf" value="noreg/a3servers2_jdbc.xml"/>
<param name="transaction" value="fr.dyade.aaa.ext.JDBCTransaction"/>
<param name="a3props" value="a3jdbc.props"/>
<param name="testid" value="noreg.test57b-3-jdbc"/>
<param name="jvmargs" value="-DswapAllowed=true -DDestination=org.objectweb.joram.client.jms.Queue -DMsgSize=1 -DNbMsg=100000"/>
</antcall>
</target>
<target name="noreg.test57b-4-jdbc" depends="init.a3props,compile"
description=" --> Test server restart with a very big number of normal (1Kb) messages">
<!-- Use JDBC Transaction configuration, and fixedInMemory to force queue load at starting -->
<antcall target="test.run" inheritAll="true">
<param name="className" value="joram.noreg.Test57b"/>
<param name="jndiconf" value="noreg/jndi.properties"/>
<param name="a3conf" value="noreg/a3servers2_jdbc.xml"/>
<param name="transaction" value="fr.dyade.aaa.ext.JDBCTransaction"/>
<param name="a3props" value="a3jdbc.props"/>
<param name="testid" value="noreg.test57b-4-jdbc"/>
<param name="jvmargs" value="-DswapAllowed=true -DDestination=org.objectweb.joram.client.jms.Queue -DMsgSize=1 -DfixedInMemory=true -DNbMsg=100000"/>
</antcall>
</target>
<target name="noreg.test58" depends="init.a3props,compile"
description=" --> test creation of a consumer with a null topic id">
<antcall target="test.run" inheritAll="true">
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 - 2020 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package joram.noreg;
import java.util.Properties;
import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.objectweb.joram.client.jms.Destination;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.shared.DestinationConstants;
import framework.TestCase;
/**
* Test a server restart with lot of waiting (big) messages:
* - Sends a big number of messages.
* - Stops and restarts the server.
* - Sends anew a big number of messages to verify performance (JORAM-358).
* - Stops and restarts the server.
* - Consumes all messages.
* Verify that all messages are delivered in the right order.
*/
public class Test57b extends BaseTest {
static int MsgSize = 1*1024*1024;
static int NbMsg = 100;
static Destination dest = null;
static ConnectionFactory cf = null;
static String host = "localhost";
static int port = 16010;
public static void main(String[] args) throws Exception {
new Test57b().run(args);
}
public void run(String[] args) {
String[] jmwargs = null;
try {
try {
boolean swapAllowed = Boolean.getBoolean("swapAllowed");
MsgSize = Integer.getInteger("MsgSize", MsgSize/1024).intValue() *1024;
NbMsg = Integer.getInteger("NbMsg", NbMsg).intValue();
String destc = System.getProperty("Destination","org.objectweb.joram.client.jms.Queue");
boolean fixedInMemory = Boolean.getBoolean("fixedInMemory");
if (swapAllowed)
jmwargs = new String[]{"-Dorg.objectweb.joram.mom.messages.SWAPALLOWED=true"};
System.out.println("server start");
TestCase.startAgentServer((short) 0, jmwargs);
Thread.sleep(2000);
writeIntoFile("===================== start test 57 =====================");
writeIntoFile("----------------------------------------------------");
writeIntoFile("Destination: " + destc + " fixedInMemory: " + fixedInMemory);
writeIntoFile("MsgSize: " + MsgSize);
writeIntoFile("NbMsg: " + NbMsg);
writeIntoFile("----------------------------------------------------");
cf = TcpBaseTest.createConnectionFactory();
AdminModule.connect(cf);
if (fixedInMemory) {
Properties props = new Properties();
props.setProperty(DestinationConstants.FIXED_IN_MEMORY, "true");
dest = Queue.create(0, props);
} else {
dest = createDestination(destc);
}
User.create("anonymous", "anonymous", 0);
dest.setFreeReading();
dest.setFreeWriting();
org.objectweb.joram.client.jms.admin.AdminModule.disconnect();
} catch(Throwable exc){
exc.printStackTrace();
error(exc);
return;
}
// Phase1: Send a big number of messages.
String[] sentMsgId = new String[2*NbMsg];
try {
Connection cnx = cf.createConnection();
Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(dest);
cnx.start();
byte[] content = new byte[MsgSize];
for (int i = 0; i< MsgSize; i++)
content[i] = (byte) (i & 0xFF);
long start = System.currentTimeMillis();
long start2 = start;
for (int nb=0; nb<NbMsg; nb++) {
BytesMessage msg = sess.createBytesMessage();
msg.writeBytes(content);
prod.send(msg);
sentMsgId[nb] = msg.getJMSMessageID();
if ((nb %10000) == 9999) {
long end2 = System.currentTimeMillis();
System.out.println("message sent #" +nb + " -> " + (end2 - start2));
start2 = end2;
}
}
long end = System.currentTimeMillis();
System.out.println("All messages sent: " + ((end -start)/1000L));
prod.close();
sess.close();
cnx.close();
} catch (javax.jms.JMSException exc) {
exc.printStackTrace();
error(exc);
return;
}
// Phase2: Kill and restart server
try {
System.out.println("Server stop ");
TestCase.stopAgentServer((short) 0);
Thread.sleep(1000L);
System.out.println("server start");
TestCase.startAgentServer((short) 0);
Thread.sleep(1000L);
} catch (Exception exc) {
exc.printStackTrace();
error(exc);
return;
}
// Phase3: Send a big number of messages.
try {
Connection cnx = cf.createConnection();
Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess.createProducer(dest);
cnx.start();
byte[] content = new byte[MsgSize];
for (int i = 0; i< MsgSize; i++)
content[i] = (byte) (i & 0xFF);
long start = System.currentTimeMillis();
long start2 = start;
for (int nb=NbMsg; nb<(2*NbMsg); nb++) {
BytesMessage msg = sess.createBytesMessage();
msg.writeBytes(content);
prod.send(msg);
sentMsgId[nb] = msg.getJMSMessageID();
if ((nb %10000) == 9999) {
long end2 = System.currentTimeMillis();
System.out.println("message sent #" +nb + " -> " + (end2 - start2));
start2 = end2;
}
}
long end = System.currentTimeMillis();
System.out.println("All messages sent: " + ((end -start)/1000L));
prod.close();
sess.close();
cnx.close();
} catch (javax.jms.JMSException exc) {
exc.printStackTrace();
error(exc);
return;
}
// Phase4: Kill and restart server
try {
System.out.println("Server stop ");
TestCase.stopAgentServer((short) 0);
Thread.sleep(1000L);
System.out.println("server start");
TestCase.startAgentServer((short) 0);
Thread.sleep(1000L);
} catch (Exception exc) {
exc.printStackTrace();
error(exc);
return;
}
// Phase5: Consume all messages.
try {
long start = System.currentTimeMillis();
Connection cnx = cf.createConnection();
Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer cons = sess.createConsumer(dest);
cnx.start();
long end = System.currentTimeMillis();
System.out.println("Connection started: " + ((end -start)/1000L));
start = System.currentTimeMillis();
long start2 = start;
for (int nb=0; nb<(2*NbMsg); nb++) {
BytesMessage msg = (BytesMessage) cons.receive();
if (nb == 0) {
end = System.currentTimeMillis();
System.out.println("1st message received: " + ((end -start)/1000L));
}
boolean good = msg.getJMSMessageID().equals(sentMsgId[nb]);
BaseTest.assertTrue("Receive bad msg #" + nb, good);
if ((nb %10000) == 9999) {
long end2 = System.currentTimeMillis();
System.out.println("message received#" + nb + (good?" ok":" nok") + " -> " + (end2 - start2));
start2 = end2;
}
}
end = System.currentTimeMillis();
System.out.println("All messages received: " + ((end -start)/1000L));
cons.close();
sess.close();
cnx.close();
} catch(Throwable exc){
exc.printStackTrace();
error(exc);
return;
}
} finally{
TestCase.stopAgentServer((short)0);
endTest();
}
System.exit(0);
}
}
......@@ -13,6 +13,8 @@
<property name="org.ow2.joram.jdbc.transaction.password" value="pass1"/>
<property name="org.ow2.joram.jdbc.transaction.dbinit" value="CREATE TABLE MyTable (name VARCHAR(256), content BLOB(16M), PRIMARY KEY(name))"/>
<property name="org.objectweb.joram.mom.messages.USELOADALL" value="true"/>
<server id="0" name="S0" hostname="localhost">
<property name="fr.dyade.aaa.util.ReliableTcpConnection.windowSize"
value="100"/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment