You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2016/03/03 11:39:31 UTC
svn commit: r1733436 -
/qpid/java/trunk/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java
Author: kwall
Date: Thu Mar 3 10:39:31 2016
New Revision: 1733436
URL: http://svn.apache.org/viewvc?rev=1733436&view=rev
Log:
QPID-7080: [Java Tests - BDB HA] Prevent sporadic failure from MultiNodeTest#testQuorumOverride
* Second attempt, first attempt the reasoning was flawed. I had assumed that the ping continues to
generate transactions, but this is wrong. ping creates a transaction only when the constituency changes.
Modified:
qpid/java/trunk/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java
Modified: qpid/java/trunk/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java?rev=1733436&r1=1733435&r2=1733436&view=diff
==============================================================================
--- qpid/java/trunk/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java (original)
+++ qpid/java/trunk/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java Thu Mar 3 10:39:31 2016
@@ -636,6 +636,7 @@ public class MultiNodeTest extends QpidB
public void testQuorumOverride() throws Exception
{
final Connection connection = getConnection(_positiveFailoverUrl);
+ ((AMQConnection)connection).setConnectionListener(_failoverListener);
Set<Integer> ports = _groupCreator.getBrokerPortNumbersForNodes();
@@ -648,8 +649,9 @@ public class MultiNodeTest extends QpidB
_groupCreator.stopNode(p);
}
- // Failover may or may not occur. It depends on the relative timing of the internal db-ping and the application of the
- // QUORUM_OVERRIDE.
+ LOGGER.info("Awaiting failover to start");
+ _failoverListener.awaitPreFailover(20000);
+ LOGGER.info("Failover has begun");
Map<String, Object> attributes = _groupCreator.getNodeAttributes(activeBrokerPort);
assertEquals("Broker has unexpected quorum override", new Integer(0), attributes.get(BDBHAVirtualHostNode.QUORUM_OVERRIDE));
@@ -658,8 +660,8 @@ public class MultiNodeTest extends QpidB
attributes = _groupCreator.getNodeAttributes(activeBrokerPort);
assertEquals("Broker has unexpected quorum override", new Integer(1), attributes.get(BDBHAVirtualHostNode.QUORUM_OVERRIDE));
- // Be certain the failover isn't going to occur, or has completed, by awaiting the transaction counter to rise
- awaitNextTransaction(activeBrokerPort);
+ _failoverListener.awaitFailoverCompletion(20000);
+ LOGGER.info("Failover has finished");
assertProducingConsuming(connection);
}
@@ -795,6 +797,7 @@ public class MultiNodeTest extends QpidB
private final class FailoverAwaitingListener implements ConnectionListener
{
private final CountDownLatch _failoverCompletionLatch;
+ private final CountDownLatch _preFailoverLatch;
private volatile boolean _failoverStarted;
private FailoverAwaitingListener()
@@ -805,6 +808,7 @@ public class MultiNodeTest extends QpidB
private FailoverAwaitingListener(int connectionNumber)
{
_failoverCompletionLatch = new CountDownLatch(connectionNumber);
+ _preFailoverLatch = new CountDownLatch(1);
}
@Override
@@ -817,6 +821,7 @@ public class MultiNodeTest extends QpidB
public synchronized boolean preFailover(boolean redirect)
{
_failoverStarted = true;
+ _preFailoverLatch.countDown();
return true;
}
@@ -840,6 +845,12 @@ public class MultiNodeTest extends QpidB
assertEquals("Failover occurred unexpectedly", 1L, _failoverCompletionLatch.getCount());
}
+ public void awaitPreFailover(long delay) throws InterruptedException
+ {
+ boolean complete = _preFailoverLatch.await(delay, TimeUnit.MILLISECONDS);
+ assertTrue("Failover was expected to begin within " + delay + " ms.", complete);
+ }
+
@Override
public void failoverComplete()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org