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 2015/02/26 16:08:27 UTC
[1/2] activemq-6 git commit: fixed test to be more robust
Repository: activemq-6
Updated Branches:
refs/heads/master 5d72befae -> 197607012
fixed test to be more robust
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/e6a501a4
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/e6a501a4
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/e6a501a4
Branch: refs/heads/master
Commit: e6a501a43a430184c509db531c2c011a66c0261f
Parents: 5d72bef
Author: Andy Taylor <an...@apache.org>
Authored: Thu Feb 26 13:40:36 2015 +0000
Committer: Andy Taylor <an...@apache.org>
Committed: Thu Feb 26 13:41:56 2015 +0000
----------------------------------------------------------------------
.../cluster/failover/FailoverListenerTest.java | 36 +++++++++++++++++---
1 file changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e6a501a4/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/cluster/failover/FailoverListenerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/cluster/failover/FailoverListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/cluster/failover/FailoverListenerTest.java
index 5c63277..9d467a8 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/cluster/failover/FailoverListenerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/cluster/failover/FailoverListenerTest.java
@@ -17,6 +17,8 @@
package org.apache.activemq.tests.integration.cluster.failover;
import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.apache.activemq.api.core.SimpleString;
import org.apache.activemq.api.core.TransportConfiguration;
@@ -68,19 +70,22 @@ public class FailoverListenerTest extends FailoverTestBase
public void testFailoverListenerCall() throws Exception
{
createSessionFactory(2);
-
- SessionFactoryFailoverListener listener = new SessionFactoryFailoverListener();
+ CountDownLatch failureLatch = new CountDownLatch(1);
+ CountDownLatch failureDoneLatch = new CountDownLatch(1);
+ SessionFactoryFailoverListener listener = new SessionFactoryFailoverListener(failureLatch, failureDoneLatch);
sf.addFailoverListener(listener);
ClientSession session = sendAndConsume(sf, true);
liveServer.crash();
+ assertTrue(failureLatch.await(5, TimeUnit.SECONDS));
assertEquals(FailoverEventType.FAILURE_DETECTED, listener.getFailoverEventType().get(0));
log.info("backup (nowLive) topology = " + backupServer.getServer().getClusterManager().getDefaultConnection(null).getTopology().describe());
log.info("Server Crash!!!");
- Thread.sleep(1000);
+
+ assertTrue(failureDoneLatch.await(5, TimeUnit.SECONDS));
//the backup server should be online by now
assertEquals(FailoverEventType.FAILOVER_COMPLETED, listener.getFailoverEventType().get(1));
@@ -158,14 +163,17 @@ public class FailoverListenerTest extends FailoverTestBase
//make sure no backup server is running
backupServer.stop();
-
- SessionFactoryFailoverListener listener = new SessionFactoryFailoverListener();
+ CountDownLatch failureLatch = new CountDownLatch(1);
+ CountDownLatch failureDoneLatch = new CountDownLatch(1);
+ SessionFactoryFailoverListener listener = new SessionFactoryFailoverListener(failureLatch, failureDoneLatch);
sf.addFailoverListener(listener);
ClientSession session = sendAndConsume(sf, true);
liveServer.crash(session);
+ assertTrue(failureLatch.await(5, TimeUnit.SECONDS));
assertEquals(FailoverEventType.FAILURE_DETECTED, listener.getFailoverEventType().get(0));
+ assertTrue(failureDoneLatch.await(5, TimeUnit.SECONDS));
assertEquals(FailoverEventType.FAILOVER_FAILED, listener.getFailoverEventType().get(1));
assertEquals("Expected 2 FailoverEvents to be triggered", 2, listener.getFailoverEventType().size());
@@ -290,6 +298,16 @@ public class FailoverListenerTest extends FailoverTestBase
private final ArrayList<FailoverEventType> failoverTypeEvent = new ArrayList<FailoverEventType>();
+ private final CountDownLatch failureLatch;
+
+ private final CountDownLatch failureDoneLatch;
+
+ public SessionFactoryFailoverListener(CountDownLatch failureLatch, CountDownLatch failureDoneLatch)
+ {
+ this.failureLatch = failureLatch;
+ this.failureDoneLatch = failureDoneLatch;
+ }
+
public ArrayList<FailoverEventType> getFailoverEventType()
{
return this.failoverTypeEvent;
@@ -300,6 +318,14 @@ public class FailoverListenerTest extends FailoverTestBase
{
this.failoverTypeEvent.add(eventType);
log.info("Failover event just happen : " + eventType.toString());
+ if (eventType == FailoverEventType.FAILURE_DETECTED)
+ {
+ failureLatch.countDown();
+ }
+ else if (eventType == FailoverEventType.FAILOVER_COMPLETED || eventType == FailoverEventType.FAILOVER_FAILED)
+ {
+ failureDoneLatch.countDown();
+ }
}
}
[2/2] activemq-6 git commit: This closes #119 - test changes
Posted by cl...@apache.org.
This closes #119 - test changes
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/19760701
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/19760701
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/19760701
Branch: refs/heads/master
Commit: 197607012dd0f4f94a06674ff1c7e5fa7bcecb4b
Parents: 5d72bef e6a501a
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Feb 26 10:07:29 2015 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Feb 26 10:07:29 2015 -0500
----------------------------------------------------------------------
.../cluster/failover/FailoverListenerTest.java | 36 +++++++++++++++++---
1 file changed, 31 insertions(+), 5 deletions(-)
----------------------------------------------------------------------