Author: reschke
Date: Thu Jul 11 13:32:12 2019
New Revision: 1862926

URL: http://svn.apache.org/viewvc?rev=1862926&view=rev
Log:
OAK-8476: RDBVersionGCSupport returns incorrect value for "oldest deleted 
document" - add ignored test

Modified:
    
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java

Modified: 
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java?rev=1862926&r1=1862925&r2=1862926&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCSupportTest.java
 Thu Jul 11 13:32:12 2019
@@ -24,14 +24,15 @@ import com.google.common.collect.Iterabl
 import com.google.common.collect.Lists;
 import com.mongodb.ReadPreference;
 
-import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
 import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore;
 import org.apache.jackrabbit.oak.plugins.document.mongo.MongoTestUtils;
 import org.apache.jackrabbit.oak.plugins.document.mongo.MongoVersionGCSupport;
 import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentStore;
 import org.apache.jackrabbit.oak.plugins.document.rdb.RDBVersionGCSupport;
 import org.apache.jackrabbit.oak.plugins.document.util.Utils;
+import org.apache.jackrabbit.oak.stats.Clock;
 import org.junit.After;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -41,6 +42,7 @@ import static org.apache.jackrabbit.oak.
 import static 
org.apache.jackrabbit.oak.plugins.document.DocumentStoreFixture.MONGO;
 import static 
org.apache.jackrabbit.oak.plugins.document.DocumentStoreFixture.RDB_H2;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 @RunWith(Parameterized.class)
 public class VersionGCSupportTest {
@@ -51,35 +53,38 @@ public class VersionGCSupportTest {
     private List<String> ids = Lists.newArrayList();
 
     @Parameterized.Parameters(name="{0}")
-    public static java.util.Collection<Object[]> fixtures() {
-        List<Object[]> fixtures = Lists.newArrayList();
+    public static java.util.Collection<DocumentStoreFixture> fixtures() {
+        List<DocumentStoreFixture> fixtures = Lists.newArrayList();
         if (RDB_H2.isAvailable()) {
-            RDBDocumentStore store = (RDBDocumentStore) 
RDB_H2.createDocumentStore();
-            fixtures.add(new Object[]{RDB_H2, store, new 
RDBVersionGCSupport(store)});
+            fixtures.add(RDB_H2);
         }
         if (MONGO.isAvailable()) {
-            MongoDocumentStore store = (MongoDocumentStore) 
MONGO.createDocumentStore();
+            fixtures.add(MONGO);
+        }
+        if (MEMORY.isAvailable()) {
+            fixtures.add(MEMORY);
+        }
+        return fixtures;
+    }
+
+    public VersionGCSupportTest(DocumentStoreFixture fixture) {
+        this.fixture = fixture;
+        this.store = fixture.createDocumentStore();
+        if (this.store instanceof MongoDocumentStore) {
             // Enforce primary read preference, otherwise tests may fail on a
             // replica set with a read preference configured to secondary.
             // Revision GC usually runs with a modified range way in the past,
             // which means changes made it to the secondary, but not in this
             // test using a virtual clock
             MongoTestUtils.setReadPreference(store, ReadPreference.primary());
-            fixtures.add(new Object[]{MONGO, store, new 
MongoVersionGCSupport(store)});
         }
-        if (MEMORY.isAvailable()) {
-            DocumentStore store = new MemoryDocumentStore();
-            fixtures.add(new Object[]{MEMORY, store, new 
VersionGCSupport(store)});
+        if (this.store instanceof MongoDocumentStore) {
+            this.gcSupport = new MongoVersionGCSupport((MongoDocumentStore) 
store);
+        } else if (this.store instanceof RDBDocumentStore) {
+            this.gcSupport = new RDBVersionGCSupport((RDBDocumentStore) store);
+        } else {
+            this.gcSupport = new VersionGCSupport(store);
         }
-        return fixtures;
-    }
-
-    public VersionGCSupportTest(DocumentStoreFixture fixture,
-                                DocumentStore store,
-                                VersionGCSupport gcSupport) {
-        this.fixture = fixture;
-        this.store = store;
-        this.gcSupport = gcSupport;
     }
 
     @After
@@ -122,6 +127,23 @@ public class VersionGCSupportTest {
         assertPossiblyDeleted(51, 60, 0);
     }
 
+    @Test
+    @Ignore("OAK-8476")
+    public void findOldest() {
+        long secs = 123456;
+        long offset = SECONDS.toMillis(secs);
+        Revision r = new Revision(offset, 0, 1);
+        String id = Utils.getIdFromPath("/doc-del");
+        ids.add(id);
+        UpdateOp op = new UpdateOp(id, true);
+        NodeDocument.setModified(op, r);
+        NodeDocument.setDeleted(op, r, true);
+        store.create(Collection.NODES, Lists.newArrayList(op));
+
+        long reportedsecs = 
gcSupport.getOldestDeletedOnceTimestamp(Clock.SIMPLE, 1) / SECONDS.toMillis(1);
+        assertTrue("diff (s) should be < 5: " + Math.abs(secs - reportedsecs), 
Math.abs(secs - reportedsecs) < 5);
+    }
+
     private void assertPossiblyDeleted(long fromSeconds, long toSeconds, long 
num) {
         Iterable<NodeDocument> docs = 
gcSupport.getPossiblyDeletedDocs(SECONDS.toMillis(fromSeconds), 
SECONDS.toMillis(toSeconds));
         assertEquals(num, Iterables.size(docs));


Reply via email to