qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1731073 - in /qpid/java/trunk: bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
Date Thu, 18 Feb 2016 13:37:31 GMT
Author: kwall
Date: Thu Feb 18 13:37:31 2016
New Revision: 1731073

URL: http://svn.apache.org/viewvc?rev=1731073&view=rev
Log:
QPID-7080: [Java Tests - BDB HA] Prevent sporadic failure from MultiNodeTest#testQuorumOverride

Modified:
    qpid/java/trunk/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/MultiNodeTest.java
    qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.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=1731073&r1=1731072&r2=1731073&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 Feb 18 13:37:31 2016
@@ -62,10 +62,6 @@ import org.apache.qpid.test.utils.QpidBr
 import org.apache.qpid.test.utils.TestUtils;
 import org.apache.qpid.util.FileUtils;
 
-/**
- * The HA black box tests test the BDB cluster as a opaque unit.  Client connects to
- * the cluster via a failover url
- */
 public class MultiNodeTest extends QpidBrokerTestCase
 {
     protected static final Logger LOGGER = LoggerFactory.getLogger(MultiNodeTest.class);
@@ -633,6 +629,10 @@ public class MultiNodeTest extends QpidB
         }
     }
 
+    /**
+     * Tests aims to demonstrate that in a disaster situation (where all nodes except the
master is lost), that operation
+     * can be continued from a single node using the QUORUM_OVERRIDE feature.
+     */
     public void testQuorumOverride() throws Exception
     {
         final Connection connection = getConnection(_positiveFailoverUrl);
@@ -648,6 +648,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.
+
         Map<String, Object> attributes = _groupCreator.getNodeAttributes(activeBrokerPort);
         assertEquals("Broker has unexpected quorum override", new Integer(0), attributes.get(BDBHAVirtualHostNode.QUORUM_OVERRIDE));
         _groupCreator.setNodeAttributes(activeBrokerPort, Collections.<String, Object>singletonMap(BDBHAVirtualHostNode.QUORUM_OVERRIDE,
1));
@@ -655,6 +658,9 @@ 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);
+
         assertProducingConsuming(connection);
     }
 
@@ -764,6 +770,28 @@ public class MultiNodeTest extends QpidB
         }
     }
 
+    private void awaitNextTransaction(final int brokerPort) throws Exception
+    {
+        Map<String, Object> attributes = _groupCreator.getNodeAttributes(brokerPort);
+        final int originalTransactionId = (int) attributes.get(BDBHAVirtualHostNode.LAST_KNOWN_REPLICATION_TRANSACTION_ID);
+        int currentTransactionId = 0;
+        long timeout = System.currentTimeMillis() + 60000;
+        LOGGER.debug("Awaiting next transaction. Original transaction id {}", originalTransactionId);
+        do
+        {
+            Thread.sleep(250);
+            attributes = _groupCreator.getNodeAttributes(brokerPort);
+            currentTransactionId = (int) attributes.get(BDBHAVirtualHostNode.LAST_KNOWN_REPLICATION_TRANSACTION_ID);
+            LOGGER.debug("Current transaction id {}", currentTransactionId);
+        }
+        while (originalTransactionId >= currentTransactionId && timeout > System.currentTimeMillis());
+
+        assertTrue("Group transaction has not occurred within timeout."
+                   + "Current transaction id " + currentTransactionId
+                   + "Original transaction id " + originalTransactionId,
+                   currentTransactionId > originalTransactionId);
+    }
+
     private final class FailoverAwaitingListener implements ConnectionListener
     {
         private final CountDownLatch _failoverCompletionLatch;

Modified: qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1731073&r1=1731072&r2=1731073&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
(original)
+++ qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
Thu Feb 18 13:37:31 2016
@@ -500,6 +500,10 @@ public class QpidBrokerTestCase extends
         return null;
     }
 
+    /**
+     * Tests that a connection is functional by producing and consuming a single message.
+     * Will fail if failover interrupts either transaction.
+     */
     public void assertProducingConsuming(final Connection connection) throws Exception
     {
         Session session = connection.createSession(true, Session.SESSION_TRANSACTED);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message