You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/01/29 17:15:35 UTC
svn commit: r1727610 - in /qpid/java/branches/6.0.x: ./
bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java
Author: orudyy
Date: Fri Jan 29 16:15:34 2016
New Revision: 1727610
URL: http://svn.apache.org/viewvc?rev=1727610&view=rev
Log:
NO-JIRA: Fix test BDBHAVirtualHostNodeTest#testIntruderProtectionInManagementMode failing due to illegitimate turning of permitted node into intruder
merged from trunk
svn merge -c 1727608 https://svn.apache.org/repos/asf/qpid/java/trunk
Modified:
qpid/java/branches/6.0.x/ (props changed)
qpid/java/branches/6.0.x/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java
Propchange: qpid/java/branches/6.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 29 16:15:34 2016
@@ -9,5 +9,5 @@
/qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
/qpid/branches/java-network-refactor/qpid/java:805429-821809
/qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720664,1721151,1721198,1722019,1722246,1722339,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1726244-1726246,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778
+/qpid/java/trunk:1715445-1715447,1715586,1715940,1716086-1716087,1716127-1716128,1716141,1716153,1716155,1716194,1716204,1716209,1716227,1716277,1716357,1716368,1716370,1716374,1716432,1716444-1716445,1716455,1716461,1716474,1716489,1716497,1716515,1716555,1716602,1716606-1716610,1716619,1716636,1717269,1717299,1717401,1717446,1717449,1717626,1717691,1717735,1717780,1718744,1718889,1718893,1718918,1718922,1719026,1719028,1719033,1719037,1719047,1719051,1720664,1721151,1721198,1722019,1722246,1722339,1723064,1723194,1723563,1724216,1724251,1724257,1724292,1724375,1724397,1724432,1724582,1724603,1724780,1724843-1724844,1725295,1725569,1726244-1726246,1726358,1726436,1726449,1726456,1726646,1726653,1726755,1726778,1727608
/qpid/trunk/qpid:796646-796653
Modified: qpid/java/branches/6.0.x/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.0.x/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java?rev=1727610&r1=1727609&r2=1727610&view=diff
==============================================================================
--- qpid/java/branches/6.0.x/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java (original)
+++ qpid/java/branches/6.0.x/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java Fri Jan 29 16:15:34 2016
@@ -40,6 +40,8 @@ import com.sleepycat.je.Durability;
import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.rep.ReplicatedEnvironment;
import com.sleepycat.je.rep.ReplicationConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.AbstractConfiguredObject;
@@ -65,6 +67,8 @@ import org.apache.qpid.util.FileUtils;
public class BDBHAVirtualHostNodeTest extends QpidTestCase
{
+ private final static Logger LOGGER = LoggerFactory.getLogger(BDBHAVirtualHostNodeTest.class);
+
private BDBHAVirtualHostNodeTestHelper _helper;
private PortHelper _portHelper = new PortHelper();
@@ -597,13 +601,14 @@ public class BDBHAVirtualHostNodeTest ex
String groupName = "group";
String nodeName = "node";
- Map<String, Object> nodeAttributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, nodePortNumber, intruderPortNumber);
+ Map<String, Object> nodeAttributes = _helper.createNodeAttributes(nodeName,
+ groupName,
+ helperAddress,
+ helperAddress,
+ nodeName,
+ nodePortNumber);
BDBHAVirtualHostNode<?> node = _helper.createAndStartHaVHN(nodeAttributes);
- Map<String, Object> intruderAttributes = _helper.createNodeAttributes("intruder", groupName, "localhost:" + intruderPortNumber, helperAddress, nodeName);
- intruderAttributes.put(BDBHAVirtualHostNode.PRIORITY, 0);
- BDBHAVirtualHostNode<?> intruder = _helper.createAndStartHaVHN(intruderAttributes);
-
final CountDownLatch stopLatch = new CountDownLatch(1);
ConfigurationChangeListener listener = new NoopConfigurationChangeListener()
{
@@ -618,17 +623,51 @@ public class BDBHAVirtualHostNodeTest ex
};
node.addChangeListener(listener);
- List<String> permittedNodes = new ArrayList<String>();
- permittedNodes.add(helperAddress);
- node.setAttributes(Collections.<String, Object>singletonMap(BDBHAVirtualHostNode.PERMITTED_NODES, permittedNodes));
+ File environmentPathFile = new File(_helper.getMessageStorePath() + File.separator + "intruder");
+ Durability durability = Durability.parse((String) nodeAttributes.get(BDBHAVirtualHostNode.DURABILITY));
+ joinIntruder(intruderPortNumber, "intruder", groupName, helperAddress, durability, environmentPathFile);
- assertTrue("Intruder protection was not triggered during expected timeout", stopLatch.await(10, TimeUnit.SECONDS));
+ LOGGER.debug("Permitted and intruder nodes are created");
- // test that if management mode is enabled then the node can start without exception
+ assertTrue("Intruder protection was not triggered during expected timeout",
+ stopLatch.await(10, TimeUnit.SECONDS));
+
+ LOGGER.debug("Master node transited into ERRORED state due to intruder protection");
when(_helper.getBroker().isManagementMode()).thenReturn(true);
+
+ LOGGER.debug("Starting node in management mode");
+
+ final CountDownLatch stateChangeLatch = new CountDownLatch(1);
+ final CountDownLatch roleChangeLatch = new CountDownLatch(1);
+ node.addChangeListener(new NoopConfigurationChangeListener()
+ {
+ @Override
+ public void stateChanged(final ConfiguredObject<?> object, final State oldState, final State newState)
+ {
+ if (newState == State.ERRORED)
+ {
+ stateChangeLatch.countDown();
+ }
+ }
+
+ @Override
+ public void attributeSet(final ConfiguredObject<?> object,
+ final String attributeName,
+ final Object oldAttributeValue,
+ final Object newAttributeValue)
+ {
+ if (BDBHAVirtualHostNode.ROLE.equals(attributeName) && NodeRole.DETACHED.equals(NodeRole.DETACHED))
+ {
+ roleChangeLatch.countDown();
+ }
+ }
+ });
node.start();
+ LOGGER.debug("Node is started");
- _helper.awaitForAttributeChange(node, AbstractConfiguredObject.STATE, State.ERRORED);
+ // verify that intruder detection is triggered after restart and environment is closed
+ assertTrue("Node state was not set to ERRORED", stateChangeLatch.await(10, TimeUnit.SECONDS));
+ assertTrue("Node role was not set to DETACHED", roleChangeLatch.await(10, TimeUnit.SECONDS));
}
public void testPermittedNodesChangedOnReplicaNodeOnlyOnceAfterBeingChangedOnMaster() throws Exception
@@ -725,14 +764,28 @@ public class BDBHAVirtualHostNodeTest ex
String node2Name = "node2";
File environmentPathFile = new File(_helper.getMessageStorePath() + File.separator + node2Name);
+ Durability durability = Durability.parse((String) node1Attributes.get(BDBHAVirtualHostNode.DURABILITY));
+ joinIntruder(node2PortNumber, node2Name, groupName, helperAddress, durability, environmentPathFile);
+
+ assertTrue("Intruder protection was not triggered during expected timeout", stopLatch.await(20, TimeUnit.SECONDS));
+ }
+
+ private void joinIntruder(final int nodePortNumber,
+ final String nodeName,
+ final String groupName,
+ final String helperAddress,
+ final Durability durability,
+ final File environmentPathFile)
+ {
environmentPathFile.mkdirs();
- ReplicationConfig replicationConfig = new ReplicationConfig(groupName, node2Name, "localhost:" + node2PortNumber );
+ ReplicationConfig replicationConfig = new ReplicationConfig(groupName, nodeName, "localhost:" + nodePortNumber );
+ replicationConfig.setNodePriority(0);
replicationConfig.setHelperHosts(helperAddress);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
- envConfig.setDurability(Durability.parse((String) node1Attributes.get(BDBHAVirtualHostNode.DURABILITY)));
+ envConfig.setDurability(durability);
ReplicatedEnvironment intruder = null;
String originalThreadName = Thread.currentThread().getName();
@@ -754,8 +807,6 @@ public class BDBHAVirtualHostNodeTest ex
Thread.currentThread().setName(originalThreadName);
}
}
-
- assertTrue("Intruder protection was not triggered during expected timeout", stopLatch.await(20, TimeUnit.SECONDS));
}
public void testValidateOnCreateForNonExistingHelperNode() throws Exception
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org