You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2015/10/13 10:02:43 UTC

svn commit: r1708297 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment: CompactionMapTest.java TestUtils.java

Author: mduerig
Date: Tue Oct 13 08:02:42 2015
New Revision: 1708297

URL: http://svn.apache.org/viewvc?rev=1708297&view=rev
Log:
OAK-3511: Test failure: CompactionMapTest.removeSome
@Ignored test case

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactionMapTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/TestUtils.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactionMapTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactionMapTest.java?rev=1708297&r1=1708296&r2=1708297&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactionMapTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/CompactionMapTest.java Tue Oct 13 08:02:42 2015
@@ -23,8 +23,10 @@ import static com.google.common.collect.
 import static com.google.common.collect.Maps.newHashMap;
 import static com.google.common.collect.Sets.newHashSet;
 import static java.io.File.createTempFile;
+import static java.util.Collections.singleton;
 import static org.apache.commons.io.FileUtils.deleteDirectory;
 import static org.apache.jackrabbit.oak.plugins.segment.CompactionMap.sum;
+import static org.apache.jackrabbit.oak.plugins.segment.TestUtils.newRecordId;
 import static org.apache.jackrabbit.oak.plugins.segment.TestUtils.randomRecordIdMap;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
@@ -44,6 +46,7 @@ import javax.annotation.Nonnull;
 import com.google.common.collect.ImmutableList;
 import org.apache.jackrabbit.oak.plugins.segment.file.FileStore;
 import org.junit.After;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -206,4 +209,24 @@ public class CompactionMapTest {
         assertEquals(expectedGeneration + 1, consed.getGeneration());
     }
 
+    /**
+     * See OAK-3511
+     */
+    @Test
+    @Ignore("OAK-3511")  // FIXME OAK-3511
+    public void removeRecentKey() {
+        compactionMap1.compress();
+
+        // Find a key not present in the compaction map
+        RecordId key = newRecordId(store.getTracker(), rnd);
+        while (compactionMap1.get(key) != null) {
+            key = newRecordId(store.getTracker(), rnd);
+        }
+
+        // Add it and immediately remove it, after which is should be gone
+        compactionMap1.put(key, newRecordId(store.getTracker(), rnd));
+        compactionMap1.remove(singleton(key.asUUID()));
+        assertNull("Compaction map must not contain removed key", compactionMap1.get(key));
+    }
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/TestUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/TestUtils.java?rev=1708297&r1=1708296&r2=1708297&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/TestUtils.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/segment/TestUtils.java Tue Oct 13 08:02:42 2015
@@ -28,10 +28,20 @@ import java.util.Random;
 
 import javax.annotation.Nonnull;
 
+// FIXME SegmentTestUtils duplicates this
 public final class TestUtils {
     private TestUtils() {}
 
-    // FIXME SegmentTestUtils duplicates this
+    public static RecordId newRecordId(SegmentTracker factory, Random random) {
+        SegmentId id = factory.newDataSegmentId();
+        RecordId r = new RecordId(id, newValidOffset(random));
+        return r;
+    }
+
+    public static int newValidOffset(Random random) {
+        return random.nextInt(MAX_SEGMENT_SIZE >> RECORD_ALIGN_BITS) << RECORD_ALIGN_BITS;
+    }
+
     /**
      * Returns a new valid record offset, between {@code a} and {@code b},
      * exclusive.