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 2014/08/14 10:14:45 UTC

svn commit: r1617895 - in /qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication: GroupCreator.java JMXManagementTest.java TwoNodeTest.java

Author: kwall
Date: Thu Aug 14 08:14:44 2014
New Revision: 1617895

URL: http://svn.apache.org/r1617895
Log:
QPID-5991: [Java System Tests]  BDB HA System Test Improvements

* Change failover url so that algorithm for cases where we expect a connection to the broker checks each broker once
  per cycle rather than twice successively.  Doubled the number of cycles and reduced the connect delay so that
  test discover the master node more quickly.
* Use separate negative failover url when expectation is that group will refuse connection.
* Remove duplicated test
* In TwoNodeTest use REST API only.   JMXManagementTest now has sole responsibility for testing HA using the JMX bean.

Modified:
    qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java
    qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/JMXManagementTest.java
    qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/TwoNodeTest.java

Modified: qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java?rev=1617895&r1=1617894&r2=1617895&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java (original)
+++ qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/GroupCreator.java Thu Aug 14 08:14:44 2014
@@ -75,9 +75,9 @@ public class GroupCreator
     private static final String MANY_BROKER_URL_FORMAT = "amqp://guest:guest@/%s?brokerlist='%s'&failover='roundrobin?cyclecount='%d''";
     private static final String BROKER_PORTION_FORMAT = "tcp://localhost:%d?connectdelay='%d',retries='%d'";
 
-    private static final int FAILOVER_CYCLECOUNT = 10;
-    private static final int FAILOVER_RETRIES = 1;
-    private static final int FAILOVER_CONNECTDELAY = 1000;
+    private static final int FAILOVER_CYCLECOUNT = 20;
+    private static final int FAILOVER_RETRIES = 0;
+    private static final int FAILOVER_CONNECTDELAY = 500;
 
     private static final String SINGLE_BROKER_URL_WITH_RETRY_FORMAT = "amqp://guest:guest@/%s?brokerlist='tcp://localhost:%d?connectdelay='%d',retries='%d''";
     private static final String SINGLE_BROKER_URL_WITHOUT_RETRY_FORMAT = "amqp://guest:guest@/%s?brokerlist='tcp://localhost:%d'";

Modified: qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/JMXManagementTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/JMXManagementTest.java?rev=1617895&r1=1617894&r2=1617895&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/JMXManagementTest.java (original)
+++ qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/JMXManagementTest.java Thu Aug 14 08:14:44 2014
@@ -206,20 +206,6 @@ public class JMXManagementTest extends Q
         }
     }
 
-    public void testSetDesignatedPrimary() throws Exception
-    {
-        int brokerPort = _clusterCreator.getBrokerPortNumbersForNodes().iterator().next();
-        final ManagedBDBHAMessageStore storeBean = getStoreBeanForNodeAtBrokerPort(brokerPort);
-        assertFalse("Unexpected designated primary before change", storeBean.getDesignatedPrimary());
-        storeBean.setDesignatedPrimary(true);
-        long limit = System.currentTimeMillis() + 5000;
-        while(!storeBean.getDesignatedPrimary() && System.currentTimeMillis() < limit)
-        {
-            Thread.sleep(100l);
-        }
-        assertTrue("Unexpected designated primary after change", storeBean.getDesignatedPrimary());
-    }
-
     public void testVirtualHostMbeanOnMasterTransfer() throws Exception
     {
         Connection connection = getConnection(_brokerFailoverUrl);

Modified: qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/TwoNodeTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/TwoNodeTest.java?rev=1617895&r1=1617894&r2=1617895&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/TwoNodeTest.java (original)
+++ qpid/trunk/qpid/java/bdbstore/systests/src/test/java/org/apache/qpid/server/store/berkeleydb/replication/TwoNodeTest.java Thu Aug 14 08:14:44 2014
@@ -20,27 +20,29 @@
 package org.apache.qpid.server.store.berkeleydb.replication;
 
 import java.io.File;
+import java.util.Collections;
+import java.util.Map;
 
 import javax.jms.Connection;
 import javax.jms.JMSException;
-import javax.management.ObjectName;
 
 import org.apache.qpid.jms.ConnectionURL;
-import org.apache.qpid.server.store.berkeleydb.jmx.ManagedBDBHAMessageStore;
-import org.apache.qpid.test.utils.JMXTestUtils;
+import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNode;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 public class TwoNodeTest extends QpidBrokerTestCase
 {
     private static final String VIRTUAL_HOST = "test";
 
-    private static final String MANAGED_OBJECT_QUERY = "org.apache.qpid:type=BDBHAMessageStore,name=" + ObjectName.quote(VIRTUAL_HOST);
     private static final int NUMBER_OF_NODES = 2;
 
     private final GroupCreator _groupCreator = new GroupCreator(this, VIRTUAL_HOST, NUMBER_OF_NODES);
-    private final JMXTestUtils _jmxUtils = new JMXTestUtils(this);
 
-    private ConnectionURL _brokerFailoverUrl;
+    /** Used when expectation is client will not (re)-connect */
+    private ConnectionURL _positiveFailoverUrl;
+
+    /** Used when expectation is client will not (re)-connect */
+    private ConnectionURL _negativeFailoverUrl;
 
     @Override
     protected void setUp() throws Exception
@@ -54,19 +56,6 @@ public class TwoNodeTest extends QpidBro
     }
 
     @Override
-    protected void tearDown() throws Exception
-    {
-        try
-        {
-            _jmxUtils.close();
-        }
-        finally
-        {
-            super.tearDown();
-        }
-    }
-
-    @Override
     public void startBroker() throws Exception
     {
         // Don't start default broker provided by QBTC.
@@ -77,20 +66,21 @@ public class TwoNodeTest extends QpidBro
         setSystemProperty("java.util.logging.config.file", "etc" + File.separator + "log.properties");
         _groupCreator.configureClusterNodes();
         _groupCreator.setDesignatedPrimaryOnFirstBroker(designedPrimary);
-        _brokerFailoverUrl = _groupCreator.getConnectionUrlForAllClusterNodes();
+        _positiveFailoverUrl = _groupCreator.getConnectionUrlForAllClusterNodes();
+        _negativeFailoverUrl = _groupCreator.getConnectionUrlForAllClusterNodes(200, 0, 2);
         _groupCreator.startCluster();
     }
 
     public void testMasterDesignatedPrimaryCanBeRestartedWithoutReplica() throws Exception
     {
         startCluster(true);
-        final Connection initialConnection = getConnection(_brokerFailoverUrl);
+        final Connection initialConnection = getConnection(_positiveFailoverUrl);
         int masterPort = _groupCreator.getBrokerPortNumberFromConnection(initialConnection);
         assertProducingConsuming(initialConnection);
         initialConnection.close();
         _groupCreator.stopCluster();
         _groupCreator.startNode(masterPort);
-        final Connection secondConnection = getConnection(_brokerFailoverUrl);
+        final Connection secondConnection = getConnection(_positiveFailoverUrl);
         assertProducingConsuming(secondConnection);
         secondConnection.close();
     }
@@ -98,12 +88,12 @@ public class TwoNodeTest extends QpidBro
     public void testClusterRestartWithoutDesignatedPrimary() throws Exception
     {
         startCluster(false);
-        final Connection initialConnection = getConnection(_brokerFailoverUrl);
+        final Connection initialConnection = getConnection(_positiveFailoverUrl);
         assertProducingConsuming(initialConnection);
         initialConnection.close();
         _groupCreator.stopCluster();
         _groupCreator.startClusterParallel();
-        final Connection secondConnection = getConnection(_brokerFailoverUrl);
+        final Connection secondConnection = getConnection(_positiveFailoverUrl);
         assertProducingConsuming(secondConnection);
         secondConnection.close();
     }
@@ -112,7 +102,7 @@ public class TwoNodeTest extends QpidBro
     {
         startCluster(true);
         _groupCreator.stopNode(_groupCreator.getBrokerPortNumberOfSecondaryNode());
-        final Connection connection = getConnection(_brokerFailoverUrl);
+        final Connection connection = getConnection(_positiveFailoverUrl);
         assertNotNull("Expected to get a valid connection to primary", connection);
         assertProducingConsuming(connection);
     }
@@ -124,7 +114,7 @@ public class TwoNodeTest extends QpidBro
 
         try
         {
-            Connection connection = getConnection(_brokerFailoverUrl);
+            Connection connection = getConnection(_negativeFailoverUrl);
             assertProducingConsuming(connection);
             fail("Exception not thrown");
         }
@@ -143,7 +133,7 @@ public class TwoNodeTest extends QpidBro
 
         try
         {
-            getConnection(_brokerFailoverUrl);
+            getConnection(_negativeFailoverUrl);
             fail("Connection not expected");
         }
         catch (JMSException e)
@@ -155,41 +145,39 @@ public class TwoNodeTest extends QpidBro
     public void testInitialDesignatedPrimaryStateOfNodes() throws Exception
     {
         startCluster(true);
-        final ManagedBDBHAMessageStore primaryStoreBean = getStoreBeanForNodeAtBrokerPort(_groupCreator.getBrokerPortNumberOfPrimary());
-        assertTrue("Expected primary node to be set as designated primary", primaryStoreBean.getDesignatedPrimary());
 
-        final ManagedBDBHAMessageStore secondaryStoreBean = getStoreBeanForNodeAtBrokerPort(_groupCreator.getBrokerPortNumberOfSecondaryNode());
-        assertFalse("Expected secondary node to NOT be set as designated primary", secondaryStoreBean.getDesignatedPrimary());
+        Map<String, Object> primaryNodeAttributes = _groupCreator.getNodeAttributes(_groupCreator.getBrokerPortNumberOfPrimary());
+        assertTrue("Expected primary node to be set as designated primary",
+                   (Boolean) primaryNodeAttributes.get(BDBHAVirtualHostNode.DESIGNATED_PRIMARY));
+
+        Map<String, Object> secondaryNodeAttributes = _groupCreator.getNodeAttributes(_groupCreator.getBrokerPortNumberOfSecondaryNode());
+        assertFalse("Expected secondary node to NOT be set as designated primary",
+                    (Boolean) secondaryNodeAttributes.get(BDBHAVirtualHostNode.DESIGNATED_PRIMARY));
     }
 
     public void testSecondaryDesignatedAsPrimaryAfterOriginalPrimaryStopped() throws Exception
     {
         startCluster(true);
-        final ManagedBDBHAMessageStore storeBean = getStoreBeanForNodeAtBrokerPort(_groupCreator.getBrokerPortNumberOfSecondaryNode());
+
         _groupCreator.stopNode(_groupCreator.getBrokerPortNumberOfPrimary());
 
-        assertFalse("Expected node to NOT be set as designated primary", storeBean.getDesignatedPrimary());
-        storeBean.setDesignatedPrimary(true);
+        Map<String, Object> secondaryNodeAttributes = _groupCreator.getNodeAttributes(_groupCreator.getBrokerPortNumberOfSecondaryNode());
+        assertFalse("Expected node to NOT be set as designated primary", (Boolean) secondaryNodeAttributes.get(BDBHAVirtualHostNode.DESIGNATED_PRIMARY));
+
+        _groupCreator.setNodeAttributes(_groupCreator.getBrokerPortNumberOfSecondaryNode(), Collections.<String, Object>singletonMap(BDBHAVirtualHostNode.DESIGNATED_PRIMARY, true));
 
-        long limit = System.currentTimeMillis() + 5000;
-        while( !storeBean.getDesignatedPrimary() && System.currentTimeMillis() < limit)
+        int timeout = 5000;
+        long limit = System.currentTimeMillis() + timeout;
+        while( !((Boolean)secondaryNodeAttributes.get(BDBHAVirtualHostNode.DESIGNATED_PRIMARY)) && System.currentTimeMillis() < limit)
         {
             Thread.sleep(100);
+            secondaryNodeAttributes = _groupCreator.getNodeAttributes(_groupCreator.getBrokerPortNumberOfSecondaryNode());
         }
-        assertTrue("Expected node to now be set as designated primary", storeBean.getDesignatedPrimary());
+        assertTrue("Expected secondary to transition to primary within " + timeout, (Boolean) secondaryNodeAttributes.get(BDBHAVirtualHostNode.DESIGNATED_PRIMARY));
 
-        final Connection connection = getConnection(_brokerFailoverUrl);
+        final Connection connection = getConnection(_positiveFailoverUrl);
         assertNotNull("Expected to get a valid connection to new primary", connection);
         assertProducingConsuming(connection);
     }
 
-    private ManagedBDBHAMessageStore getStoreBeanForNodeAtBrokerPort(
-            final int activeBrokerPortNumber) throws Exception
-    {
-        _jmxUtils.open(activeBrokerPortNumber);
-
-        ManagedBDBHAMessageStore storeBean = _jmxUtils.getManagedObject(ManagedBDBHAMessageStore.class, MANAGED_OBJECT_QUERY);
-        return storeBean;
-    }
-
 }



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