Author: alexparvulescu Date: Thu Mar 30 14:26:54 2017 New Revision: 1789531
URL: http://svn.apache.org/viewvc?rev=1789531&view=rev Log: OAK-5971 Offline compaction corrupts the journal - added test Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java?rev=1789531&r1=1789530&r2=1789531&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java (original) +++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/CompactionAndCleanupIT.java Thu Mar 30 14:26:54 2017 @@ -67,6 +67,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions; import org.apache.jackrabbit.oak.segment.file.FileStore; import org.apache.jackrabbit.oak.segment.file.FileStoreGCMonitor; +import org.apache.jackrabbit.oak.segment.tool.Compact; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry; @@ -505,6 +506,43 @@ public class CompactionAndCleanupIT { } } + /** + * Test for the Offline compaction tool (OAK-5971) + */ + @Test + public void offlineCompactionTool() throws Exception { + SegmentGCOptions gcOptions = defaultGCOptions().setOffline(); + ScheduledExecutorService executor = newSingleThreadScheduledExecutor(); + FileStore fileStore = fileStoreBuilder(getFileStoreFolder()) + .withMaxFileSize(1) + .withGCOptions(gcOptions) + .withStatisticsProvider(new DefaultStatisticsProvider(executor)) + .build(); + SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build(); + try { + NodeBuilder root = nodeStore.getRoot().builder(); + root.child("content"); + nodeStore.merge(root, EmptyHook.INSTANCE, CommitInfo.EMPTY); + fileStore.flush(); + } finally { + fileStore.close(); + } + + Compact.builder().withPath(getFileStoreFolder()).build().run(); + + fileStore = fileStoreBuilder(getFileStoreFolder()) + .withMaxFileSize(1) + .withGCOptions(gcOptions) + .withStatisticsProvider(new DefaultStatisticsProvider(executor)) + .build(); + nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build(); + try { + assertTrue(nodeStore.getRoot().hasChildNode("content")); + } finally { + fileStore.close(); + } + } + private static void assertSize(String info, long size, long lower, long upper) { log.debug("File Store {} size {}, expected in interval [{},{}]", info, size, lower, upper);
