You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2016/08/10 10:55:02 UTC

activemq git commit: additional test to validate stats on missing messages and outstanding acks on recovery

Repository: activemq
Updated Branches:
  refs/heads/master aae4b3dda -> fcd9047b9


additional test to validate stats on missing messages and outstanding acks on recovery


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/fcd9047b
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/fcd9047b
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/fcd9047b

Branch: refs/heads/master
Commit: fcd9047b9fb52c140ac77cc23337234570ddfb01
Parents: aae4b3d
Author: gtully <ga...@gmail.com>
Authored: Wed Aug 10 11:54:01 2016 +0100
Committer: gtully <ga...@gmail.com>
Committed: Wed Aug 10 11:54:12 2016 +0100

----------------------------------------------------------------------
 .../store/kahadb/JournalFdRecoveryTest.java     | 47 ++++++++++++++++++--
 1 file changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/fcd9047b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalFdRecoveryTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalFdRecoveryTest.java b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalFdRecoveryTest.java
index 4121e49..633ab5c 100644
--- a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalFdRecoveryTest.java
+++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalFdRecoveryTest.java
@@ -18,6 +18,7 @@ package org.apache.activemq.store.kahadb;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.region.RegionBroker;
 import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.command.ActiveMQQueue;
@@ -81,6 +82,13 @@ public class JournalFdRecoveryTest {
     }
 
     private void doStartBroker(boolean delete) throws Exception {
+        doCreateBroker(delete);
+        LOG.info("Starting broker..");
+        broker.start();
+    }
+
+    private void doCreateBroker(boolean delete) throws Exception {
+
         broker = new BrokerService();
         broker.setDeleteAllMessagesOnStartup(delete);
         broker.setPersistent(true);
@@ -98,9 +106,6 @@ public class JournalFdRecoveryTest {
 
         connectionUri = "vm://localhost?create=false";
         cf = new ActiveMQConnectionFactory(connectionUri);
-
-        broker.start();
-        LOG.info("Starting broker..");
     }
 
     protected void configurePersistence(BrokerService brokerService) throws Exception {
@@ -195,6 +200,42 @@ public class JournalFdRecoveryTest {
 
     }
 
+    @Test
+    public void testRecoveryWithMissingMssagesWithValidAcks() throws Exception {
+
+        doCreateBroker(true);
+        adapter.setCheckpointInterval(50000);
+        adapter.setCleanupInterval(50000);
+        broker.start();
+
+        int toSend = 50;
+        produceMessagesToConsumeMultipleDataFiles(toSend);
+
+        int numFiles = getNumberOfJournalFiles();
+        LOG.info("Num files: " + numFiles);
+        assertTrue("more than x files: " + numFiles, numFiles > 5);
+        assertEquals("Drain", 30, tryConsume(destination, 30));
+
+        LOG.info("Num files after stopped: " + getNumberOfJournalFiles());
+
+        File dataDir = broker.getPersistenceAdapter().getDirectory();
+        broker.stop();
+        broker.waitUntilStopped();
+
+        whackDataFile(dataDir, 4);
+
+        whackIndex(dataDir);
+
+        doStartBroker(false);
+
+        LOG.info("Num files after restarted: " + getNumberOfJournalFiles());
+
+        assertEquals("Empty?", 18, tryConsume(destination, 20));
+
+        assertEquals("no queue size ", 0l,  ((RegionBroker)broker.getRegionBroker()).getDestinationStatistics().getMessages().getCount());
+
+    }
+
     private long totalOpenFileDescriptorCount(BrokerService broker) {
         long result = 0;
         try {