summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorAlex Rudyy <orudyy@apache.org>2014-07-25 12:03:50 +0000
committerAlex Rudyy <orudyy@apache.org>2014-07-25 12:03:50 +0000
commitee593a12663f770fa96fd0a0b06b0e7f63a8396c (patch)
tree04df6b7b49c74979f860f78206fc5ac3067d009a /qpid/java
parent2e7d440399866a9743c93a14208d7f57876c2d0f (diff)
downloadqpid-python-ee593a12663f770fa96fd0a0b06b0e7f63a8396c.tar.gz
QPID-5891: Strengthen BDB HA operational logging tests
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1613401 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/bdbstore/src/test/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeOperationalLoggingTest.java32
1 files changed, 22 insertions, 10 deletions
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 e73d4a27fd..ac67c86f5e 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
@@ -21,12 +21,10 @@
package org.apache.qpid.server.virtualhostnode.berkeleydb;
import static org.mockito.Matchers.argThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
import org.apache.qpid.server.logging.EventLogger;
@@ -36,6 +34,7 @@ import org.apache.qpid.server.logging.messages.HighAvailabilityMessages;
import org.apache.qpid.server.model.SystemContext;
import org.apache.qpid.test.utils.QpidTestCase;
import org.hamcrest.Description;
+import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatcher;
/**
@@ -244,6 +243,9 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase
BDBHAVirtualHostNodeImpl node2 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node2Attributes);
_helper.awaitRemoteNodes(node1, 1);
+ // make sure that task executor thread finishes all scheduled tasks
+ node2.stop();
+
// Verify ADDED message from node2 when its created
String expectedMessage = HighAvailabilityMessages.ADDED(node2.getName(), groupName).toString();
verify(_eventLogger).message(argThat(new LogSubjectMatcher(node2.getVirtualHostNodeLogSubject())),
@@ -279,6 +281,9 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase
node2.delete();
_helper.awaitRemoteNodes(node1, 0);
+ // make sure that task executor thread finishes all scheduled tasks
+ node1.stop();
+
String expectedMessage = HighAvailabilityMessages.DELETED(node2.getName(), groupName).toString();
verify(_eventLogger).message(argThat(new LogSubjectMatcher(node1.getVirtualHostNodeLogSubject())),
argThat(new LogMessageMatcher(expectedMessage, HighAvailabilityMessages.DELETED_LOG_HIERARCHY)));
@@ -329,6 +334,7 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase
BDBHAVirtualHostNodeImpl node1 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node1Attributes);
_helper.assertNodeRole(node1, "MASTER");
+ resetEventLogger();
int node2PortNumber = getNextAvailable(node1PortNumber + 1);
Map<String, Object> node2Attributes = _helper.createNodeAttributes("node2", groupName, "localhost:" + node2PortNumber, helperAddress);
BDBHAVirtualHostNodeImpl node2 = (BDBHAVirtualHostNodeImpl)_helper.createHaVHN(node2Attributes);
@@ -336,23 +342,29 @@ public class BDBHAVirtualHostNodeOperationalLoggingTest extends QpidTestCase
BDBHARemoteReplicationNodeImpl remoteNode = (BDBHARemoteReplicationNodeImpl)node1.getRemoteReplicationNodes().iterator().next();
- // stop remote node
- node2.stop();
+ node2.close();
waitForNodeDetachedField(remoteNode, true);
reset(_eventLogger);
- resetEventLogger();
node2 = (BDBHAVirtualHostNodeImpl)_helper.recoverHaVHN(node2.getId(), node2Attributes);
_helper.assertNodeRole(node2, "REPLICA");
waitForNodeDetachedField(remoteNode, false);
- // verify that remaining node issues the ATTACHED operational logging for remote node
+ ArgumentCaptor<LogSubject> subjectArgument = ArgumentCaptor.forClass(LogSubject.class);
+ ArgumentCaptor<LogMessage> messageArgument = ArgumentCaptor.forClass(LogMessage.class);
+ verify(_eventLogger, times(2)).message(subjectArgument.capture(), messageArgument.capture());
+
+ assertEquals("Unexpected subject", node1.getVirtualHostNodeLogSubject(), subjectArgument.getValue());
+
String expectedMessage = HighAvailabilityMessages.ATTACHED(node2.getName(), groupName, "REPLICA").toString();
- verify(_eventLogger).message(argThat(new LogSubjectMatcher(node1.getVirtualHostNodeLogSubject())),
- argThat(new LogMessageMatcher(expectedMessage, HighAvailabilityMessages.ATTACHED_LOG_HIERARCHY)));
+ String expectedMessage2 = HighAvailabilityMessages.ATTACHED(node2.getName(), groupName, "UNKNOWN").toString();
+
+ List<LogMessage> capturedValues = messageArgument.getAllValues();
+ String m = capturedValues.get(0).toString();
+ assertTrue("Unexpected attached message :" + m, m.equals(expectedMessage) || m.equals(expectedMessage2));
}
private void waitForNodeDetachedField(BDBHARemoteReplicationNodeImpl remoteNode, boolean expectedDetached) throws InterruptedException {