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
This commit is contained in:
Gary Tully 2013-08-08 15:54:59 +00:00
parent 0ba311f14b
commit c7aad77a16
3 changed files with 11 additions and 9 deletions

View File

@ -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();
}

View File

@ -51,10 +51,10 @@ public class DbRestartJDBCQueueMasterSlaveLeaseTest extends DbRestartJDBCQueueMa
}
private long getLockKeepAlivePeriod() {
return 500;
return 1000;
}
private long getLockAcquireSleepInterval() {
return 2000;
return 8000;
}
}

View File

@ -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);