mirror of
https://github.com/apache/activemq-artemis.git
synced 2025-03-08 18:29:20 +00:00
Fixing test failure
This test started to fail after performance improvements from ACTIVEMQ6-78 After some investigation it turned out that this test was racing with the client crashing even before the queue was created or sending a non persistent message asynchronously while the client crashed before the server received the message. I've also decreased some of the times on pings so the test could run a bit faster
This commit is contained in:
parent
f7c4d56cc7
commit
60179cfc98
@ -44,9 +44,11 @@ import org.apache.activemq.tests.util.SpawnedVMSupport;
|
||||
*/
|
||||
public class ClientCrashTest extends ClientTestBase
|
||||
{
|
||||
static final int PING_PERIOD = 2000;
|
||||
// using short values so this test can run fast
|
||||
static final int PING_PERIOD = 100;
|
||||
|
||||
static final int CONNECTION_TTL = 6000;
|
||||
// using short values so this test can run fast
|
||||
static final int CONNECTION_TTL = 1000;
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
@ -76,18 +78,22 @@ public class ClientCrashTest extends ClientTestBase
|
||||
{
|
||||
assertActiveConnections(1);
|
||||
|
||||
// spawn a JVM that creates a Core client, which sends a message
|
||||
Process p = SpawnedVMSupport.spawnVM(CrashClient.class.getName());
|
||||
|
||||
ClientSession session = sf.createSession(false, true, true);
|
||||
session.createQueue(ClientCrashTest.QUEUE, ClientCrashTest.QUEUE, null, false);
|
||||
|
||||
// spawn a JVM that creates a Core client, which sends a message
|
||||
// It has to be spawned after the queue was created.
|
||||
// if the client is too fast you race the send before the queue was created, missing a message
|
||||
Process p = SpawnedVMSupport.spawnVM(CrashClient.class.getName());
|
||||
|
||||
ClientConsumer consumer = session.createConsumer(ClientCrashTest.QUEUE);
|
||||
ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE);
|
||||
|
||||
|
||||
session.start();
|
||||
|
||||
// receive a message from the queue
|
||||
Message messageFromClient = consumer.receive(500000);
|
||||
Message messageFromClient = consumer.receive(5000);
|
||||
Assert.assertNotNull("no message received", messageFromClient);
|
||||
Assert.assertEquals(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBodyBuffer().readString());
|
||||
|
||||
@ -155,7 +161,7 @@ public class ClientCrashTest extends ClientTestBase
|
||||
session.start();
|
||||
|
||||
// receive a message from the queue
|
||||
ClientMessage messageFromClient = consumer.receive(10000);
|
||||
ClientMessage messageFromClient = consumer.receive(timeout);
|
||||
Assert.assertNotNull("no message received", messageFromClient);
|
||||
Assert.assertEquals(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBodyBuffer().readString());
|
||||
|
||||
|
@ -59,8 +59,9 @@ public class CrashClient
|
||||
ClientSession session = sf.createSession(false, true, true);
|
||||
ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE);
|
||||
|
||||
// it has to be durable otherwise it may race dying before the client is killed
|
||||
ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE,
|
||||
false,
|
||||
true,
|
||||
0,
|
||||
System.currentTimeMillis(),
|
||||
(byte)1);
|
||||
|
@ -59,7 +59,7 @@ public class CrashClient2
|
||||
ClientSession session = sf.createSession(true, true, 1000000);
|
||||
ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE2);
|
||||
|
||||
ClientMessage message = session.createMessage(false);
|
||||
ClientMessage message = session.createMessage(true);
|
||||
message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
|
||||
|
||||
producer.send(message);
|
||||
|
Loading…
x
Reference in New Issue
Block a user