Skip to content
Permalink
Browse files
Merge pull request #596 from apache/OAK-9804
OAK-9804 Flaky unit test FlatFileStoreTest.resumePreviousUnfinishedDownload()
  • Loading branch information
thomasmueller committed Jun 16, 2022
2 parents 7f3916f + c60ebd2 commit a4fd27c18cf9e72be32b67095305aea9cb2a129f
Showing 1 changed file with 10 additions and 3 deletions.
@@ -23,6 +23,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.oak.index.indexer.document.CompositeException;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntry.NodeStateEntryBuilder;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntryTraverser;
import org.apache.jackrabbit.oak.index.indexer.document.NodeStateEntryTraverserFactory;
import org.apache.jackrabbit.oak.plugins.document.mongo.DocumentStoreSplitter;
@@ -397,7 +398,11 @@ public void resumePreviousUnfinishedDownloadAndMerge() throws Exception {
assertContainsMergeFolder(spyBuilder.getFlatFileStoreDir(), true);

List<String> sortedPaths = TestUtils.sortPaths(mongoDocs.stream().map(md -> md.path).collect(Collectors.toList()));
assertEquals(mongoDocs.size(), nsetf.getTotalProvidedDocCount());
// with multi-threaded download and multiple threads,
// we can't expect that each entry is downloaded exactly once,
// as there could be some overlap (the range check happends
// _after_ retrieving the entry)
assertTrue(mongoDocs.size() <= nsetf.getTotalProvidedDocCount());
assertEquals(sortedPaths, entryPaths);
} finally {
System.clearProperty(OAK_INDEXER_SORT_STRATEGY_TYPE);
@@ -479,7 +484,8 @@ public NodeStateEntryTraverser create(MongoDocumentTraverser.TraversingRange ran
String traverserId = getId();
return new Iterator<NodeStateEntry>() {

NodeStateEntry lastReturnedDoc;
// ensure we don't get a NullPointerException in logger.debug below
NodeStateEntry lastReturnedDoc = new NodeStateEntryBuilder(null, "/").build();

@Override
public boolean hasNext() {
@@ -488,7 +494,8 @@ public boolean hasNext() {

@Override
public NodeStateEntry next() {
if (providedDocuments.get() == breakAfterDelivering.get()) {
// multiple threads could fail at the same time, that's fine
if (providedDocuments.get() >= breakAfterDelivering.get()) {
logger.debug("{} Breaking after getting docs with id {}", traverserId, lastReturnedDoc.getId());
throw new IllegalStateException(EXCEPTION_MESSAGE);
}

0 comments on commit a4fd27c

Please sign in to comment.