From c7aad77a166e4555d07a4a9c62e22352429b8ee7 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Thu, 8 Aug 2013 15:54:59 +0000 Subject: [PATCH] extend the lease period in the test to make more deterministic wrt timing git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1511842 13f79535-47bb-0310-9956-ffa450edef68 --- .../ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java | 8 ++++---- .../broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java | 4 ++-- .../broker/ft/DbRestartJDBCQueueMasterSlaveTest.java | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java index 9b662355d7..5f3f7fb7d6 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.java @@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory; public class DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest extends DbRestartJDBCQueueMasterSlaveLeaseTest { private static final transient Logger LOG = LoggerFactory.getLogger(DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest.class); - private long restartDelay = 500; + private long restartDelay = 2000; @Override protected void configureBroker(BrokerService brokerService) { @@ -37,7 +37,7 @@ public class DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest extends DbRestartJDBC @Override protected void delayTillRestartRequired() { - if (restartDelay > 500) { + if (restartDelay > 2000) { LOG.info("delay for more than lease quantum. While Db is offline, master should stay alive but could loose lease"); } else { LOG.info("delay for less than lease quantum. While Db is offline, master should stay alive"); @@ -61,12 +61,12 @@ public class DbRestartJDBCQueueMasterSlaveLeaseQuiesceTest extends DbRestartJDBC @Override public void setUp() throws Exception { - restartDelay = 500; + restartDelay = 2000; super.setUp(); } public void testSendReceiveWithLeaseExpiry() throws Exception { - restartDelay = 3000; + restartDelay = 10000; testSendReceive(); } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java index 84fcaa91e0..9f51ab79cd 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveLeaseTest.java @@ -51,10 +51,10 @@ public class DbRestartJDBCQueueMasterSlaveLeaseTest extends DbRestartJDBCQueueMa } private long getLockKeepAlivePeriod() { - return 500; + return 1000; } private long getLockAcquireSleepInterval() { - return 2000; + return 8000; } } diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.java index f4f11bb149..ce1022255c 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/ft/DbRestartJDBCQueueMasterSlaveTest.java @@ -30,6 +30,7 @@ import javax.jms.TransactionRolledBackException; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.MessageId; import org.apache.activemq.store.jdbc.JDBCPersistenceAdapter; import org.apache.derby.jdbc.EmbeddedDataSource; import org.slf4j.Logger; @@ -114,15 +115,16 @@ public class DbRestartJDBCQueueMasterSlaveTest extends JDBCQueueMasterSlaveTest java.sql.Connection dbConnection = null; try { ActiveMQMessage mqMessage = (ActiveMQMessage) message; + MessageId id = mqMessage.getMessageId(); dbConnection = sharedDs.getConnection(); PreparedStatement s = dbConnection.prepareStatement(((JDBCPersistenceAdapter) connectedToBroker().getPersistenceAdapter()).getStatements().getFindMessageStatement()); - s.setString(1, mqMessage.getMessageId().getProducerId().toString()); - s.setLong(2, mqMessage.getMessageId().getProducerSequenceId()); + s.setString(1, id.getProducerId().toString()); + s.setLong(2, id.getProducerSequenceId()); ResultSet rs = s.executeQuery(); if (!rs.next()) { // message is gone, so lets count it as consumed - LOG.info("On TransactionRolledBackException we know that the ack/commit got there b/c message is gone so we count it: " + mqMessage); + LOG.info("On TransactionRolledBackException we know that the ack/commit got there b/c message is gone so we count it: " + mqMessage); super.consumeMessage(message, messageList); } else { LOG.info("On TransactionRolledBackException we know that the ack/commit was lost so we expect a replay of: " + mqMessage);