You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2018/03/19 21:02:37 UTC
qpid-jms git commit: QPIDJMS-366 Add a test of no response to TX
commit and remote close
Repository: qpid-jms
Updated Branches:
refs/heads/master 4b022971b -> 3e8061b44
QPIDJMS-366 Add a test of no response to TX commit and remote close
Test that failover send commit failed on remote close when commit is
pending.
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/3e8061b4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/3e8061b4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/3e8061b4
Branch: refs/heads/master
Commit: 3e8061b448d934fbc5dab0e2d7119125e06c2265
Parents: 4b02297
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Mar 19 16:59:48 2018 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Mar 19 17:02:22 2018 -0400
----------------------------------------------------------------------
.../failover/FailoverIntegrationTest.java | 73 ++++++++++++++++++++
1 file changed, 73 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/3e8061b4/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
index 0abf459..b2f402e 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/failover/FailoverIntegrationTest.java
@@ -1564,6 +1564,79 @@ public class FailoverIntegrationTest extends QpidJmsTestCase {
}
}
+ @Test(timeout=20000)
+ public void testTxCommitThrowsAfterMaxReconnectsWhenNoDischargeResponseSent() throws Exception {
+ try (TestAmqpPeer testPeer = new TestAmqpPeer()) {
+
+ final CountDownLatch testConnected = new CountDownLatch(1);
+ final CountDownLatch failedConnection = new CountDownLatch(1);
+
+ // Create a peer to connect to, then one to reconnect to
+ final String testPeerURI = createPeerURI(testPeer);
+
+ LOG.info("test peer is at: {}", testPeerURI);
+
+ testPeer.expectSaslAnonymous();
+ testPeer.expectOpen();
+ testPeer.expectBegin();
+
+ final JmsConnection connection = establishAnonymousConnecton(
+ "failover.maxReconnectAttempts=10&failover.useReconnectBackOff=false", testPeer);
+ connection.addConnectionListener(new JmsDefaultConnectionListener() {
+ @Override
+ public void onConnectionEstablished(URI remoteURI) {
+ LOG.info("Connection Established: {}", remoteURI);
+ if (testPeerURI.equals(remoteURI.toString())) {
+ testConnected.countDown();
+ }
+ }
+
+ @Override
+ public void onConnectionFailure(Throwable cause) {
+ LOG.info("Connection Failed: {}", cause);
+ failedConnection.countDown();
+ }
+ });
+ connection.start();
+
+ assertTrue("Should connect to test peer", testConnected.await(5, TimeUnit.SECONDS));
+
+ testPeer.expectBegin();
+ testPeer.expectCoordinatorAttach();
+
+ // First expect an unsettled 'declare' transfer to the txn coordinator, and
+ // reply with a Declared disposition state containing the txnId.
+ Binary txnId = new Binary(new byte[]{ (byte) 5, (byte) 6, (byte) 7, (byte) 8});
+ testPeer.expectDeclare(txnId);
+
+ // The session should send a commit but we don't respond, then drop the connection
+ // and check that the commit is failed due to dropped connection.
+ testPeer.expectDischargeButDoNotRespond(txnId, false);
+ testPeer.expectDeclareButDoNotRespond();
+
+ testPeer.remotelyCloseConnection(true, ConnectionError.CONNECTION_FORCED, "Server is going away", 100);
+
+ // --- Failover should handle the connection close ---------------//
+
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+
+ try {
+ session.commit();
+ fail("Commit should have thrown an exception");
+ } catch (JMSException jmsEx) {
+ LOG.debug("Commit threw: ", jmsEx);
+ }
+
+ assertTrue("Should reported failed", failedConnection.await(5, TimeUnit.SECONDS));
+
+ try {
+ connection.close();
+ } catch (JMSException jmsEx) {}
+
+ testPeer.waitForAllHandlersToComplete(2000);
+ }
+ }
+
private JmsConnection establishAnonymousConnecton(TestAmqpPeer... peers) throws JMSException {
return establishAnonymousConnecton(null, null, peers);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org