You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/03/18 15:14:57 UTC
[activemq-artemis] branch master updated: NO-JIRA Fix
FailoverTest#testForceBlockingReturn
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new 6099742 NO-JIRA Fix FailoverTest#testForceBlockingReturn
new 41c0c17 This closes #2586
6099742 is described below
commit 6099742ca0a09d4e6da727efac35e3f1ffc6b00f
Author: Howard Gao <ho...@gmail.com>
AuthorDate: Mon Mar 18 11:54:42 2019 +0800
NO-JIRA Fix FailoverTest#testForceBlockingReturn
The test may fail if the live crashes too soon and the
message is directly sent to backup and the expected
blocking send will never happen.
To fix that a wait is added to ensure the message
is sent to the live (and intercepted) before
crashing the live.
---
.../tests/integration/cluster/failover/DelayInterceptor.java | 10 ++++++++++
.../tests/integration/cluster/failover/FailoverTest.java | 8 +++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java
index 49daf27..38e1603 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/DelayInterceptor.java
@@ -22,15 +22,25 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
public class DelayInterceptor implements Interceptor {
+ private final CountDownLatch latch = new CountDownLatch(1);
+
@Override
public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException {
if (packet.getType() == PacketImpl.SESS_SEND) {
+ latch.countDown();
// Lose the send
return false;
} else {
return true;
}
}
+
+ public boolean await() throws InterruptedException {
+ return latch.await(10, TimeUnit.SECONDS);
+ }
}
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java
index 0a37abf..3d35027 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTest.java
@@ -1917,7 +1917,8 @@ public class FailoverTest extends FailoverTestBase {
createClientSessionFactory();
// Add an interceptor to delay the send method so we can get time to cause failover before it returns
- liveServer.getServer().getRemotingService().addIncomingInterceptor(new DelayInterceptor());
+ DelayInterceptor interceptor = new DelayInterceptor();
+ liveServer.getServer().getRemotingService().addIncomingInterceptor(interceptor);
final ClientSession session = createSession(sf, true, true, 0);
@@ -1947,6 +1948,11 @@ public class FailoverTest extends FailoverTestBase {
sender.start();
+ //if server crash too early,
+ //sender will directly send to backup. so
+ //need some waiting here.
+ assertTrue(interceptor.await());
+
crash(session);
sender.join();