diff options
| author | Keith Wall <kwall@apache.org> | 2014-09-01 13:41:33 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2014-09-01 13:41:33 +0000 |
| commit | 4d7d63621523d4ca43e7a41de0d37239ec5278e7 (patch) | |
| tree | 2acee7c0cd501df1603839571512476025564f1a /qpid/java/bdbstore/src/test | |
| parent | 334478a7ad358641b4dfd0f8ca48d7679972ce0d (diff) | |
| download | qpid-python-4d7d63621523d4ca43e7a41de0d37239ec5278e7.tar.gz | |
QPID-6063: [Java Broker] Disambiguate the concept of a node being unreachable from a node awaiting election
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1621775 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/bdbstore/src/test')
4 files changed, 38 insertions, 37 deletions
diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java index 7b03539625..acebaf55a0 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java @@ -50,6 +50,7 @@ import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHARemoteReplicationN import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHARemoteReplicationNodeImpl; import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNode; import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNodeTestHelper; +import org.apache.qpid.server.virtualhostnode.berkeleydb.NodeRole; import org.apache.qpid.test.utils.QpidTestCase; public class BDBHAVirtualHostNodeTest extends QpidTestCase @@ -91,7 +92,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase BDBHAVirtualHostNode<?> node = _helper.createHaVHN(attributes); node.start(); - _helper.assertNodeRole(node, "MASTER", "REPLICA"); + _helper.assertNodeRole(node, NodeRole.MASTER, NodeRole.REPLICA); assertEquals("Unexpected node state", State.ACTIVE, node.getState()); @@ -155,7 +156,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase assertEquals("Unexpected electable group override value after mutation", 1, environment.getRepMutableConfig().getElectableGroupSizeOverride()); assertNotNull("Join time should be set", node.getJoinTime()); - assertNotNull("Last known replication transaction idshould be set", node.getLastKnownReplicationTransactionId()); + assertNotNull("Last known replication transaction id should be set", node.getLastKnownReplicationTransactionId()); } public void testTransferMasterToSelf() throws Exception @@ -177,11 +178,11 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase Map<String, Object> node3Attributes = _helper.createNodeAttributes("node3", groupName, "localhost:" + node3PortNumber, helperAddress, nodeName); _helper.createAndStartHaVHN(node3Attributes); - BDBHAVirtualHostNode<?> replica = _helper.awaitAndFindNodeInRole("REPLICA"); + BDBHAVirtualHostNode<?> replica = _helper.awaitAndFindNodeInRole(NodeRole.REPLICA); - replica.setAttribute(BDBHAVirtualHostNode.ROLE, "REPLICA", "MASTER"); + replica.setAttribute(BDBHAVirtualHostNode.ROLE, replica.getRole(), NodeRole.MASTER); - _helper.assertNodeRole(replica, "MASTER"); + _helper.assertNodeRole(replica, NodeRole.MASTER); } public void testTransferMasterToRemoteReplica() throws Exception @@ -222,12 +223,12 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase assertTrue("Replication nodes have not been seen during 5s", remoteNodeLatch.await(5, TimeUnit.SECONDS)); BDBHARemoteReplicationNodeImpl replicaRemoteNode = (BDBHARemoteReplicationNodeImpl)lastSeenReplica.get(); - _helper.awaitForAttributeChange(replicaRemoteNode, BDBHARemoteReplicationNodeImpl.ROLE, "REPLICA"); + _helper.awaitForAttributeChange(replicaRemoteNode, BDBHARemoteReplicationNodeImpl.ROLE, NodeRole.REPLICA); - replicaRemoteNode.setAttributes(Collections.<String,Object>singletonMap(BDBHARemoteReplicationNode.ROLE, "MASTER")); + replicaRemoteNode.setAttributes(Collections.<String,Object>singletonMap(BDBHARemoteReplicationNode.ROLE, NodeRole.MASTER)); BDBHAVirtualHostNode<?> replica = replicaRemoteNode.getName().equals(node2.getName())? node2 : node3; - _helper.assertNodeRole(replica, "MASTER"); + _helper.assertNodeRole(replica, NodeRole.MASTER); } public void testMutatingRoleWhenNotReplica_IsDisallowed() throws Exception @@ -239,11 +240,11 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, nodePortNumber); BDBHAVirtualHostNode<?> node = _helper.createAndStartHaVHN(node1Attributes); - _helper.assertNodeRole(node, "MASTER"); + _helper.assertNodeRole(node, NodeRole.MASTER); try { - node.setAttributes(Collections.<String,Object>singletonMap(BDBHAVirtualHostNode.ROLE, "REPLICA")); + node.setAttributes(Collections.<String,Object>singletonMap(BDBHAVirtualHostNode.ROLE, NodeRole.REPLICA)); fail("Role mutation should fail"); } catch(IllegalStateException e) @@ -272,10 +273,10 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase Map<String, Object> node3Attributes = _helper.createNodeAttributes("node3", groupName, "localhost:" + node3PortNumber, helperAddress, nodeName); _helper.createAndStartHaVHN(node3Attributes); - BDBHAVirtualHostNode<?> master = _helper.awaitAndFindNodeInRole("MASTER"); + BDBHAVirtualHostNode<?> master = _helper.awaitAndFindNodeInRole(NodeRole.MASTER); _helper.awaitRemoteNodes(master, 2); - BDBHAVirtualHostNode<?> replica = _helper.awaitAndFindNodeInRole("REPLICA"); + BDBHAVirtualHostNode<?> replica = _helper.awaitAndFindNodeInRole(NodeRole.REPLICA); assertNotNull("Remote node " + replica.getName() + " is not found", _helper.findRemoteNode(master, replica.getName())); replica.delete(); @@ -297,7 +298,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase BDBHAVirtualHostNode<?> node = _helper.createHaVHN(nodeAttributes); node.start(); - _helper.assertNodeRole(node, "MASTER", "REPLICA"); + _helper.assertNodeRole(node, NodeRole.MASTER, NodeRole.REPLICA); assertEquals("Unexpected node state", State.ACTIVE, node.getState()); _helper.awaitForVirtualhost(node,30000); @@ -324,7 +325,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase try { virtualHost.setAttributes(Collections.<String, Object>singletonMap(BDBHAVirtualHost.LOCAL_TRANSACTION_SYNCHRONIZATION_POLICY, "INVALID")); - fail("Invalid syncronization policy is set"); + fail("Invalid synchronization policy is set"); } catch(IllegalArgumentException e) { @@ -334,7 +335,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase try { virtualHost.setAttributes(Collections.<String, Object>singletonMap(BDBHAVirtualHost.REMOTE_TRANSACTION_SYNCHRONIZATION_POLICY, "INVALID")); - fail("Invalid syncronization policy is set"); + fail("Invalid synchronization policy is set"); } catch(IllegalArgumentException e) { diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java index 0d64d87aef..8522a39918 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeTest.java @@ -82,7 +82,7 @@ public class BDBHARemoteReplicationNodeTest extends QpidTestCase String remoteReplicationName = getName(); BDBHARemoteReplicationNode remoteReplicationNode = createRemoteReplicationNode(remoteReplicationName); - remoteReplicationNode.setAttribute(BDBHARemoteReplicationNode.ROLE, "UNKNOWN", "MASTER"); + remoteReplicationNode.setAttribute(BDBHARemoteReplicationNode.ROLE, remoteReplicationNode.getRole(), NodeRole.MASTER); verify(_facade).transferMasterAsynchronously(remoteReplicationName); } diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java index 1937eefc0b..31af574ee5 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java @@ -76,7 +76,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); assertEquals("Unexpected VHN log subject", "[grp(/group)/vhn(/node1)] ", node1.getVirtualHostNodeLogSubject().getLogString()); assertEquals("Unexpected group log subject", "[grp(/group)] ", node1.getGroupLogSubject().getLogString()); @@ -85,7 +85,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase verify(_eventLogger).message(argThat(new LogSubjectMatcher(node1.getVirtualHostNodeLogSubject())), argThat(new LogMessageMatcher(expectedMessage, HighAvailabilityMessages.CREATED_LOG_HIERARCHY))); - expectedMessage = HighAvailabilityMessages.ROLE_CHANGED(node1.getName(), node1.getAddress(), "UNKNOWN", "MASTER").toString(); + expectedMessage = HighAvailabilityMessages.ROLE_CHANGED(node1.getName(), node1.getAddress(), NodeRole.WAITING.name(), NodeRole.MASTER.name()).toString(); verify(_eventLogger).message(argThat(new LogSubjectMatcher(node1.getGroupLogSubject())), argThat(new LogMessageMatcher(expectedMessage, HighAvailabilityMessages.ROLE_CHANGED_LOG_HIERARCHY))); } @@ -99,7 +99,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); reset(_eventLogger); @@ -120,7 +120,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); reset(_eventLogger); @@ -143,7 +143,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); reset(_eventLogger); @@ -166,7 +166,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); reset(_eventLogger); @@ -190,7 +190,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber, node2PortNumber); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); reset(_eventLogger); @@ -219,7 +219,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber, node2PortNumber); node1Attributes.put(BDBHAVirtualHostNode.DESIGNATED_PRIMARY, true); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); resetEventLogger(); @@ -251,7 +251,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber, node2PortNumber); node1Attributes.put(BDBHAVirtualHostNode.DESIGNATED_PRIMARY, true); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); Map<String, Object> node2Attributes = _helper.createNodeAttributes("node2", groupName, "localhost:" + node2PortNumber, helperAddress, nodeName); BDBHAVirtualHostNodeImpl node2 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node2Attributes); @@ -284,7 +284,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase Map<String, Object> node1Attributes = _helper.createNodeAttributes(nodeName, groupName, helperAddress, helperAddress, nodeName, node1PortNumber, node2PortNumber); node1Attributes.put(BDBHAVirtualHostNode.DESIGNATED_PRIMARY, true); BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes); - _helper.assertNodeRole(node1, "MASTER"); + _helper.assertNodeRole(node1, NodeRole.MASTER); resetEventLogger(); @@ -302,7 +302,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase node2Attributes.put(BDBHAVirtualHostNode.PERMITTED_NODES, node1Attributes.get(BDBHAVirtualHostNode.PERMITTED_NODES)); node2 = (BDBHAVirtualHostNodeImpl)_helper.recoverHaVHN(node2.getId(), node2Attributes); - _helper.assertNodeRole(node2, "REPLICA", "MASTER"); + _helper.assertNodeRole(node2, NodeRole.REPLICA, NodeRole.MASTER); waitForNodeDetachedField(remoteNode, false); final String expectedMessage = HighAvailabilityMessages.JOINED(node2.getName(), node2.getAddress()).toString(); diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java index 6f18878a1d..0facfb0785 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeTestHelper.java @@ -164,31 +164,31 @@ public class BDBHAVirtualHostNodeTestHelper assertEquals("Unexpected attribute " + name + " on " + object, expectedValue, object.getAttribute(name) ); } - public BDBHAVirtualHostNode<?> awaitAndFindNodeInRole(String role) throws InterruptedException + public BDBHAVirtualHostNode<?> awaitAndFindNodeInRole(NodeRole desiredRole) throws InterruptedException { BDBHAVirtualHostNode<?> replica = null; int findReplicaCount = 0; while(replica == null) { - replica = findNodeInRole(role); + replica = findNodeInRole(desiredRole); if (replica == null) { Thread.sleep(100); } if (findReplicaCount > 50) { - fail("Could not find a node in replica role"); + fail("Could not find a node in role " + desiredRole); } findReplicaCount++; } return replica; } - public BDBHAVirtualHostNode<?> findNodeInRole(String role) + public BDBHAVirtualHostNode<?> findNodeInRole(NodeRole role) { for (BDBHAVirtualHostNode<?> node : _nodes) { - if (role.equals(node.getRole())) + if (role == node.getRole()) { return node; } @@ -218,15 +218,15 @@ public class BDBHAVirtualHostNodeTestHelper return node; } - public void assertNodeRole(BDBHAVirtualHostNode<?> node, String... roleName) throws InterruptedException + public void assertNodeRole(BDBHAVirtualHostNode<?> node, NodeRole... roleName) throws InterruptedException { int iterationCounter = 0; boolean inRole =false; do { - for (String role : roleName) + for (NodeRole role : roleName) { - if (role.equals(node.getRole())) + if (role == node.getRole()) { inRole = true; break; @@ -252,7 +252,7 @@ public class BDBHAVirtualHostNodeTestHelper public BDBHAVirtualHostNode<?> startNodeAndWait(BDBHAVirtualHostNode<?> node) throws InterruptedException { node.start(); - assertNodeRole(node, "MASTER", "REPLICA"); + assertNodeRole(node, NodeRole.MASTER, NodeRole.REPLICA); assertEquals("Unexpected node state", State.ACTIVE, node.getState()); return node; } @@ -273,7 +273,7 @@ public class BDBHAVirtualHostNodeTestHelper { Map<String, Object> node1Attributes = new HashMap<String, Object>(); node1Attributes.put(BDBHAVirtualHostNode.ID, UUID.randomUUID()); - node1Attributes.put(BDBHAVirtualHostNode.TYPE, "BDB_HA"); + node1Attributes.put(BDBHAVirtualHostNode.TYPE, BDBHAVirtualHostNodeImpl.VIRTUAL_HOST_NODE_TYPE); node1Attributes.put(BDBHAVirtualHostNode.NAME, nodeName); node1Attributes.put(BDBHAVirtualHostNode.GROUP_NAME, groupName); node1Attributes.put(BDBHAVirtualHostNode.ADDRESS, address); |
