org.apache.qpid.test.unit.ack
Class AcknowledgeAfterFailoverOnMessageTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.qpid.test.utils.QpidTestCase
              extended by org.apache.qpid.test.utils.QpidBrokerTestCase
                  extended by org.apache.qpid.test.utils.FailoverBaseCase
                      extended by org.apache.qpid.test.unit.ack.AcknowledgeTest
                          extended by org.apache.qpid.test.unit.ack.AcknowledgeOnMessageTest
                              extended by org.apache.qpid.test.unit.ack.AcknowledgeAfterFailoverOnMessageTest
All Implemented Interfaces:
MessageListener, junit.framework.Test, org.apache.qpid.jms.ConnectionListener

public class AcknowledgeAfterFailoverOnMessageTest
extends AcknowledgeOnMessageTest
implements org.apache.qpid.jms.ConnectionListener

The AcknowlegeAfterFailoverOnMessageTests Extends the OnMessage AcknowledgeTests to validate that after the client has failed over that the client can still receive and ack messages. All the AcknowledgeTest ack modes are exercised here though some are disabled due to know issues (e.g. DupsOk, AutoAck : QPID-143 and the clientAck and dirtyClientAck due to QPID-1816) This class has two main test structures, overrides of AcknowledgeOnMessageTest to perform the clean acking based on session ack mode and a series of dirty ack tests that test what happends if you receive a message then try and ack AFTER you have failed over.


Nested Class Summary
(package private)  class AcknowledgeAfterFailoverOnMessageTest.DirtyAckingHandler
           
 
Nested classes/interfaces inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
QpidBrokerTestCase.MessageType
 
Field Summary
(package private)  boolean _cleaned
           
protected  CountDownLatch _failoverCompleted
           
(package private)  int _msgCount
           
 
Fields inherited from class org.apache.qpid.test.unit.ack.AcknowledgeOnMessageTest
_causeOfFailure, _receivedAll
 
Fields inherited from class org.apache.qpid.test.unit.ack.AcknowledgeTest
_connection, _consumer, _consumerSession, _producer, _queue, NUM_MESSAGES
 
Fields inherited from class org.apache.qpid.test.utils.FailoverBaseCase
_logger, DEFAULT_FAILOVER_TIME, FAILING_PORT, FAILING_VM_PORT, failingPort
 
Fields inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
_broker, _brokerLanguage, _brokerLogPrefix, _brokerOutputStream, _brokerPersistent, _brokers, _configFile, _connectionFactory, _connections, _initialContext, _interleaveBrokerLog, _output, _outputFile, _testName, BROKER_READY, CONTENT, CPP, DEFAULT_MANAGEMENT_PORT, DEFAULT_MESSAGE_SIZE, DEFAULT_PORT, DEFAULT_SSL_PORT, DEFAULT_VM_PORT, EXTERNAL, INDEX, JAVA, LOGMONITOR_TIMEOUT, QPID_HOME, QpidHome, QUEUE, RECEIVE_TIMEOUT, TOPIC, VM
 
Fields inherited from class org.apache.qpid.test.utils.QpidTestCase
MEMORY_STORE_CLASS_NAME, MS_CLASS_NAME_KEY
 
Constructor Summary
AcknowledgeAfterFailoverOnMessageTest()
           
 
Method Summary
 void bytesReceived(long count)
           
 void bytesSent(long count)
           
 void doAcknowlegement(Message msg)
          Perform the acknowledgement of messages if additionally required.
 void failBroker(int port)
          Override so we can block until failover has completd
 void failoverComplete()
           
 void init(boolean transacted, int mode)
          Override default init to add connectionListener so we can verify that failover took place
 boolean preFailover(boolean redirect)
           
protected  void prepBroker(int index)
          Prepare the broker for the next round.
 boolean preResubscribe()
           
 void setUp()
           
protected  void testDirtyAcking(boolean transacted, int mode)
          Test that Acking/Committing a message received before failover causes an exception at commit/ack time.
 void testDirtyAckingTransacted()
           
 void testDirtyClientAck()
           
 
Methods inherited from class org.apache.qpid.test.unit.ack.AcknowledgeOnMessageTest
fail, onMessage, testAcking
 
Methods inherited from class org.apache.qpid.test.unit.ack.AcknowledgeTest
testAutoAck, testClientAck, testDupsOk, testNoAck, testPreAck, testTransacted
 
Methods inherited from class org.apache.qpid.test.utils.FailoverBaseCase
getConnectionFactory, getFailingPort, tearDown
 
Methods inherited from class org.apache.qpid.test.utils.QpidBrokerTestCase
cleanBroker, createMessage, createNextMessage, drainQueue, getBroker, getBrokerCommand, getClientConnection, getConfigurationStringProperty, getConnection, getConnection, getConnection, getConnectionFactory, getConnectionURL, getInitialContext, getLogger, getManagementPort, getMessageSize, getPort, getPort, getTestConfigFile, getTestQueue, getTestQueueName, getTestVirtualhostsFile, isBroker010, isBroker08, isBrokerStorePersistent, isCppBroker, isExternalBroker, isJavaBroker, makeVirtualHostPersistent, reloadBrokerSecurityConfig, restartBroker, restartBroker, revertLoggingLevels, revertSystemProperties, runBare, saveTestConfiguration, saveTestVirtualhosts, sendMessage, sendMessage, sendMessage, setBrokerEnvironment, setBrokerOnlySystemProperty, setConfigurationProperty, setLoggerLevel, setMessageSize, setSystemProperty, setSystemProperty, setTestClientSystemProperty, startBroker, startBroker, stopBroker, stopBroker
 
Methods inherited from class org.apache.qpid.test.utils.QpidTestCase
getTestProfileMessageStoreClassName, run
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_failoverCompleted

protected CountDownLatch _failoverCompleted

_msgCount

int _msgCount

_cleaned

boolean _cleaned
Constructor Detail

AcknowledgeAfterFailoverOnMessageTest

public AcknowledgeAfterFailoverOnMessageTest()
Method Detail

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class AcknowledgeOnMessageTest
Throws:
Exception

init

public void init(boolean transacted,
                 int mode)
          throws Exception
Override default init to add connectionListener so we can verify that failover took place

Overrides:
init in class AcknowledgeOnMessageTest
Parameters:
transacted - create a transacted session for this test
mode - if not transacted what ack mode to use for this test
Throws:
Exception - if a problem occured during test setup.

prepBroker

protected void prepBroker(int index)
                   throws Exception
Prepare the broker for the next round. Called after acknowledging the messsage this method shuts the current broker down connnects to the new broker and send a new message for the client to failover to and receive. It ends by restarting the orignal broker so that the cycle can repeat. When we are able to cluster the java broker then will not need to do the message repopulation or QPID_WORK clearing. All that we will need to do is send the initial NUM_MESSAGES during startup and then bring the brokers down at the right time to cause the client to fail between them.

Parameters:
index -
Throws:
Exception

doAcknowlegement

public void doAcknowlegement(Message msg)
                      throws JMSException
Description copied from class: AcknowledgeTest
Perform the acknowledgement of messages if additionally required.

Overrides:
doAcknowlegement in class AcknowledgeTest
Throws:
JMSException

testDirtyAcking

protected void testDirtyAcking(boolean transacted,
                               int mode)
                        throws Exception
Test that Acking/Committing a message received before failover causes an exception at commit/ack time. Expected behaviour is that in: * tx mode commit() throws a transacted RolledBackException * client ack mode throws an IllegalStateException

Parameters:
transacted - is this session trasacted
mode - What ack mode should be used if not trasacted
Throws:
Exception - if something goes wrong.

testDirtyClientAck

public void testDirtyClientAck()
                        throws Exception
Throws:
Exception

testDirtyAckingTransacted

public void testDirtyAckingTransacted()
                               throws Exception
Throws:
Exception

bytesSent

public void bytesSent(long count)
Specified by:
bytesSent in interface org.apache.qpid.jms.ConnectionListener

bytesReceived

public void bytesReceived(long count)
Specified by:
bytesReceived in interface org.apache.qpid.jms.ConnectionListener

preFailover

public boolean preFailover(boolean redirect)
Specified by:
preFailover in interface org.apache.qpid.jms.ConnectionListener

preResubscribe

public boolean preResubscribe()
Specified by:
preResubscribe in interface org.apache.qpid.jms.ConnectionListener

failoverComplete

public void failoverComplete()
Specified by:
failoverComplete in interface org.apache.qpid.jms.ConnectionListener

failBroker

public void failBroker(int port)
Override so we can block until failover has completd

Overrides:
failBroker in class FailoverBaseCase
Parameters:
port -


Licensed to the Apache Software Foundation