activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1367626 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java
Date Tue, 31 Jul 2012 15:53:29 GMT
Author: gtully
Date: Tue Jul 31 15:53:29 2012
New Revision: 1367626

URL: http://svn.apache.org/viewvc?rev=1367626&view=rev
Log:
 add test that seems to show index growth with repeated use of durable subs

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java?rev=1367626&r1=1367625&r2=1367626&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionOfflineTest.java
Tue Jul 31 15:53:29 2012
@@ -44,6 +44,7 @@ import org.apache.activemq.store.jdbc.JD
 import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
 import org.apache.activemq.util.Wait;
 import org.apache.kahadb.journal.Journal;
+import org.apache.kahadb.page.PageFile;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -755,6 +756,57 @@ public class DurableSubscriptionOfflineT
         assertEquals(0, listener.count);
     }
 
+    public void testRemovedDurableSubDeletesFromIndex() throws Exception {
+
+        if (! (broker.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter)) {
+            return;
+        }
+
+        // fails for numMessages > 3000
+        final int numMessages = 100;
+
+        KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter)broker.getPersistenceAdapter();
+        PageFile pageFile = kahaDBPersistenceAdapter.getStore().getPageFile();
+        LOG.info("PageCount " + pageFile.getPageCount() + " f:" + pageFile.getFreePageCount()
+ ", fileSize:" + pageFile.getFile().length());
+
+        long lastDiff = 0;
+        for (int repeats=0; repeats<4; repeats++) {
+
+            LOG.info("Iteration: "+ repeats  + " Count:" + pageFile.getPageCount() + " f:"
+ pageFile.getFreePageCount());
+
+            Connection con = createConnection("cliId1" + "-" + repeats);
+            Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            session.createDurableSubscriber(topic, "SubsId", "filter = 'true'", true);
+            session.close();
+            con.close();
+
+            // send messages
+            con = createConnection();
+            session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = session.createProducer(null);
+
+            for (int i = 0; i < numMessages; i++) {
+                Message message = session.createMessage();
+                message.setStringProperty("filter", "true");
+                producer.send(topic, message);
+            }
+            con.close();
+
+            Connection con2 = createConnection("cliId1" + "-" + repeats);
+            Session session2 = con2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            session2.unsubscribe("SubsId");
+            session2.close();
+            con2.close();
+
+            LOG.info("PageCount " + pageFile.getPageCount() + " f:" + pageFile.getFreePageCount()
+  " diff: " + (pageFile.getPageCount() - pageFile.getFreePageCount()) + " fileSize:" + pageFile.getFile().length());
+
+            if (lastDiff != 0) {
+                assertEquals("Only use X pages per iteration", lastDiff, pageFile.getPageCount()
- pageFile.getFreePageCount());
+            }
+            lastDiff = pageFile.getPageCount() - pageFile.getFreePageCount();
+        }
+    }
+
     public void initCombosForTestOfflineSubscriptionWithSelectorAfterRestart() throws Exception
{
         this.addCombinationValues("defaultPersistenceAdapter",
                 new Object[]{ PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.JDBC});



Mime
View raw message