You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/05/12 14:53:02 UTC
[1/2] qpid-jms git commit: QPIDJMS-46: make tests more aggressive and
fix up used discovery provider options
Repository: qpid-jms
Updated Branches:
refs/heads/master 199cc7351 -> 123990d4d
QPIDJMS-46: make tests more aggressive and fix up used discovery provider options
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/0a7e1480
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/0a7e1480
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/0a7e1480
Branch: refs/heads/master
Commit: 0a7e1480c256bc74c132c139e281f35e1f0bf6b6
Parents: 199cc73
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue May 12 12:50:29 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue May 12 13:30:50 2015 +0100
----------------------------------------------------------------------
.../jms/discovery/JmsAmqpDiscoveryTest.java | 22 +++++++++++---------
1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/0a7e1480/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
index f3a76cb..ce6e468 100644
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
@@ -28,6 +28,7 @@ import org.apache.qpid.jms.JmsConnection;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.apache.qpid.jms.JmsConnectionListener;
import org.apache.qpid.jms.message.JmsInboundMessageDispatch;
+import org.apache.qpid.jms.provider.discovery.DiscoveryProviderFactory;
import org.apache.qpid.jms.support.AmqpTestSupport;
import org.apache.qpid.jms.support.Wait;
import org.junit.Before;
@@ -57,7 +58,7 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
restored = new CountDownLatch(1);
}
- @Test(timeout=60000)
+ @Test(timeout=30000)
public void testRunningBrokerIsDiscovered() throws Exception {
connection = createConnection();
connection.start();
@@ -71,7 +72,7 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
}));
}
- @Test(timeout=60000)
+ @Test(timeout=30000)
public void testConnectionFailsWhenBrokerGoesDown() throws Exception {
connection = createConnection();
connection.start();
@@ -87,10 +88,10 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
LOG.info("Connection established, stopping broker.");
stopPrimaryBroker();
- assertTrue("Interrupted event never fired", interrupted.await(30, TimeUnit.SECONDS));
+ assertTrue("Interrupted event never fired", interrupted.await(10, TimeUnit.SECONDS));
}
- @Test(timeout=60000)
+ @Test(timeout=30000)
public void testConnectionRestoresAfterBrokerRestarted() throws Exception {
connection = createConnection();
connection.start();
@@ -104,12 +105,12 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
}));
stopPrimaryBroker();
- assertTrue(interrupted.await(20, TimeUnit.SECONDS));
+ assertTrue(interrupted.await(10, TimeUnit.SECONDS));
startPrimaryBroker();
- assertTrue(restored.await(20, TimeUnit.SECONDS));
+ assertTrue(restored.await(10, TimeUnit.SECONDS));
}
- @Test(timeout=60000)
+ @Test(timeout=30000)
public void testDiscoversAndReconnectsToSecondaryBroker() throws Exception {
connection = createConnection();
@@ -126,8 +127,8 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
startNewBroker();
stopPrimaryBroker();
- assertTrue(interrupted.await(20, TimeUnit.SECONDS));
- assertTrue(restored.await(20, TimeUnit.SECONDS));
+ assertTrue(interrupted.await(10, TimeUnit.SECONDS));
+ assertTrue(restored.await(10, TimeUnit.SECONDS));
}
@Override
@@ -136,8 +137,9 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
}
protected Connection createConnection() throws Exception {
+ String discoveryPrefix = DiscoveryProviderFactory.DISCOVERY_OPTION_PREFIX;
JmsConnectionFactory factory = new JmsConnectionFactory(
- "discovery:(multicast://default)?maxReconnectDelay=500");
+ "discovery:(multicast://default)?" + discoveryPrefix + "startupMaxReconnectAttempts=25" + "&" + discoveryPrefix +"maxReconnectDelay=500");
connection = factory.createConnection();
jmsConnection = (JmsConnection) connection;
jmsConnection.addConnectionListener(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-jms git commit: QPIDJMS-46: ensure the connection attempt
fails when the attempts are exhausted, if discovery results in no target URIs
Posted by ro...@apache.org.
QPIDJMS-46: ensure the connection attempt fails when the attempts are exhausted, if discovery results in no target URIs
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/123990d4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/123990d4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/123990d4
Branch: refs/heads/master
Commit: 123990d4dae65716bb5b200fed460ad223c8811c
Parents: 0a7e148
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue May 12 13:36:02 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue May 12 13:36:02 2015 +0100
----------------------------------------------------------------------
.../jms/provider/failover/FailoverProvider.java | 8 +++++-
.../jms/discovery/JmsAmqpDiscoveryTest.java | 26 ++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/123990d4/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
index 924192e..6abfd49 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
@@ -634,12 +634,18 @@ public class FailoverProvider extends DefaultProviderListener implements Provide
provider.close();
} catch (Throwable ex) {}
}
+ } else {
+ LOG.debug("No target URI available to connect to");
}
if (reconnectLimit != UNLIMITED && reconnectAttempts >= reconnectLimit) {
LOG.error("Failed to connect after: " + reconnectAttempts + " attempt(s)");
failed.set(true);
- failureCause = IOExceptionSupport.create(failure);
+ if(failure == null) {
+ failureCause = new IOException("Failed to connect after: " + reconnectAttempts + " attempt(s)");
+ } else {
+ failureCause = IOExceptionSupport.create(failure);
+ }
if (listener != null) {
listener.onConnectionFailure(failureCause);
};
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/123990d4/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
index ce6e468..4d9bf5a 100644
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsAmqpDiscoveryTest.java
@@ -17,12 +17,14 @@
package org.apache.qpid.jms.discovery;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.jms.Connection;
+import javax.jms.JMSException;
import org.apache.qpid.jms.JmsConnection;
import org.apache.qpid.jms.JmsConnectionFactory;
@@ -58,6 +60,19 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
restored = new CountDownLatch(1);
}
+ @Test(timeout=10000)
+ public void testFailureToDiscoverLeadsToConnectionFailure() throws Exception {
+ // We are using a different group to ensure failure,
+ // but shut down the broker anyway.
+ stopPrimaryBroker();
+ try {
+ createFailingConnection();
+ fail("Should have failed to connect");
+ } catch (JMSException jmse) {
+ // expected
+ }
+ }
+
@Test(timeout=30000)
public void testRunningBrokerIsDiscovered() throws Exception {
connection = createConnection();
@@ -136,6 +151,17 @@ public class JmsAmqpDiscoveryTest extends AmqpTestSupport implements JmsConnecti
return true;
}
+ protected Connection createFailingConnection() throws JMSException {
+ String discoveryPrefix = DiscoveryProviderFactory.DISCOVERY_OPTION_PREFIX;
+ JmsConnectionFactory factory = new JmsConnectionFactory(
+ "discovery:(multicast://default?group=altGroup)?" + discoveryPrefix + "startupMaxReconnectAttempts=10" + "&" + discoveryPrefix +"maxReconnectDelay=100");
+ connection = factory.createConnection();
+ jmsConnection = (JmsConnection) connection;
+ jmsConnection.addConnectionListener(this);
+ jmsConnection.start();
+ return connection;
+ }
+
protected Connection createConnection() throws Exception {
String discoveryPrefix = DiscoveryProviderFactory.DISCOVERY_OPTION_PREFIX;
JmsConnectionFactory factory = new JmsConnectionFactory(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org