Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAK-11298 Fix test IncrementalStoreTest #1888

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ public void incrementalFFSTest(boolean customRegexFilter, boolean customExcluded
Predicate<String> pathPredicate = s -> true;
Set<String> basePreferredPathElements = Set.of();

Path initialFfsPath = createFFS(roBackend, pathPredicate, basePreferredPathElements, List.of(new PathFilter(List.of("/"), Collections.EMPTY_LIST)), initialCheckpoint, "initial", getNodeStateAtCheckpoint1(customRegexFilter, customExcludedPathsFilter));
Path initialFfsPath = createFFS(roBackend, pathPredicate, basePreferredPathElements, List.of(new PathFilter(List.of("/"), Collections.emptyList())), initialCheckpoint, "initial", getNodeStateAtCheckpoint1(customRegexFilter, customExcludedPathsFilter));

createIncrementalContent(rwBackend.documentNodeStore);
String finalCheckpoint = rwBackend.documentNodeStore.checkpoint(3600000);
Backend roBackend1 = createNodeStore(true);

Path finalFfsPath = createFFS(roBackend1, pathPredicate, basePreferredPathElements, List.of(new PathFilter(List.of("/"), Collections.EMPTY_LIST)), finalCheckpoint, "final", getNodeStateAtCheckpoint2(customRegexFilter, customExcludedPathsFilter));
Path finalFfsPath = createFFS(roBackend1, pathPredicate, basePreferredPathElements, List.of(new PathFilter(List.of("/"), Collections.emptyList())), finalCheckpoint, "final", getNodeStateAtCheckpoint2(customRegexFilter, customExcludedPathsFilter));

Backend roBackend2 = createNodeStore(true);
IndexStore indexStore = getDocumentIndexer(roBackend2, finalCheckpoint).buildStore(initialCheckpoint, finalCheckpoint);
Expand All @@ -237,7 +237,7 @@ public void incrementalFFSTest(boolean customRegexFilter, boolean customExcluded

compareFinalFFSAndMergedFFS(finalFfsPath, mergedFile, mergedStore);

Set<String> preferredPathElements = new ListOrderedSet();
Set<String> preferredPathElements = new ListOrderedSet<>();
preferredPathElements.add("04");
preferredPathElements.add("30");
preferredPathElements.add("29");
Expand All @@ -247,7 +247,7 @@ public void incrementalFFSTest(boolean customRegexFilter, boolean customExcluded
Predicate<String> filterPredicate = t -> t.startsWith("/content/dam");

File finalFFSForIndexingFromMergedFFS = createFFSFromBaseFFSUsingPreferredPathElementsAndFilterPredicate(mergedFile, preferredPathElements, filterPredicateMergedFFS);
Path finalFFSForIndexingFromMongo = createFFS(roBackend2, filterPredicate, preferredPathElements, Collections.EMPTY_LIST, finalCheckpoint, "final",
Path finalFFSForIndexingFromMongo = createFFS(roBackend2, filterPredicate, preferredPathElements, Collections.emptyList(), finalCheckpoint, "final",
getNodeStatesWithPrefferedPathsAndPathPredicatesOverBaseFFSAfterMerging(customRegexFilter));

assertEquals(IndexStoreUtils.createReader(finalFFSForIndexingFromMongo.toFile(), algorithm).lines().collect(Collectors.toList()),
Expand Down Expand Up @@ -309,7 +309,7 @@ private Path createFFS(Backend roBackend, Predicate<String> pathPredicate, Set<S
Path initialFilePath = Files.move(baseFFSAtCheckpoint1.toPath(),
new File(baseFFSAtCheckpoint1.getParent(), algorithm.addSuffix(identifier + ".json")).toPath(),
StandardCopyOption.REPLACE_EXISTING);
Path initialMetadataFilePath = Files.move(metadataAtCheckpoint1.toPath(),
Files.move(metadataAtCheckpoint1.toPath(),
new File(baseFFSAtCheckpoint1.getParent(), algorithm.addSuffix(identifier + ".json.metadata")).toPath(),
StandardCopyOption.REPLACE_EXISTING);
Files.move(new File(baseFFSAtCheckpoint1.getParent() + "/sort-work-dir").toPath(),
Expand Down Expand Up @@ -416,7 +416,7 @@ private void createBaseContent(NodeStore rwNodeStore) throws CommitFailedExcepti
contentBuilder.child("2023").child("01").setProperty("p1", "v202301");

@NotNull NodeBuilder contentDamBuilder = contentBuilder.child("dam");
contentDamBuilder.child("1000").child("12").setProperty("p1", "v100012");
contentDamBuilder.child("1000").child("12");
contentDamBuilder.child("2022").child("02").setProperty("p1", "v202202");
contentDamBuilder.child("2022").child("02").child("1").setProperty("p1", "v2022021");
contentDamBuilder.child("2022").child("02").child("27").setProperty("p1", "v20220227");
Expand All @@ -440,9 +440,7 @@ private void createBaseContent(NodeStore rwNodeStore) throws CommitFailedExcepti
@NotNull NodeBuilder varBuilder = rootBuilder.child("var");
varBuilder.child("foo").setProperty("p0", "v202202");
varBuilder.child("foo").child("01").setProperty("p1", "v202202");
varBuilder.child("foo").child("01").setProperty("p2", "v202202");
varBuilder.child("bar").child("01").setProperty("p1", "v202202");
varBuilder.child("bar").child("01").setProperty("p2", "v202202");
rwNodeStore.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}

Expand Down Expand Up @@ -470,15 +468,15 @@ private void createIncrementalContent(NodeStore rwNodeStore) throws CommitFailed
varBuilder.child("foo").child("01").setProperty("p1", "v202202-new");
varBuilder.child("foo").child("02");
varBuilder.child("bar").child("01").setProperty("p1", "v202202-new");
varBuilder.child("bar").child("01").setProperty("p3", "v202202");
varBuilder.child("bar").child("02");
rwNodeStore.merge(rootBuilder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}


@NotNull
private static List<String> getNodeStateAtCheckpoint1(boolean customRegexFilter, boolean customExcludedPathsFilter) {
List<String> expectedPathsAtCheckpoint1 = new ArrayList<>(List.of("/|{}",
List<String> expectedPathsAtCheckpoint1 = new ArrayList<>(List.of(
"/|{}",
"/content|{}",
"/content/2022|{}",
"/content/2022/02|{\"p1\":\"v202202\"}",
Expand All @@ -488,7 +486,7 @@ private static List<String> getNodeStateAtCheckpoint1(boolean customRegexFilter,
"/content/2023/01|{\"p1\":\"v202301\"}",
"/content/dam|{}",
"/content/dam/1000|{}",
"/content/dam/1000/12|{\"p1\":\"v100012\"}",
"/content/dam/1000/12|{}",
"/content/dam/2022|{}",
"/content/dam/2022/02|{\"p1\":\"v202202\"}",
"/content/dam/2022/02/1|{\"p1\":\"v2022021\"}",
Expand Down Expand Up @@ -531,9 +529,9 @@ private static List<String> getNodeStateAtCheckpoint1(boolean customRegexFilter,
"/oak:index/fooIndex|{}",
"/var|{}",
"/var/bar|{}",
"/var/bar/01|{\"p1\":\"v202202\",\"p2\":\"v202202\"}",
"/var/bar/01|{\"p1\":\"v202202\"}",
"/var/foo|{\"p0\":\"v202202\"}",
"/var/foo/01|{\"p1\":\"v202202\",\"p2\":\"v202202\"}"));
"/var/foo/01|{\"p1\":\"v202202\"}"));

if (customRegexFilter) {
expectedPathsAtCheckpoint1.removeAll(List.of("/content/dam/2024/jcr:content/renditions/foo.metadata.xml|{}",
Expand All @@ -551,7 +549,7 @@ private static List<String> getNodeStateAtCheckpoint1(boolean customRegexFilter,
"/oak:index/barIndex|{}",
"/oak:index/fooIndex|{}",
//"/var/foo|{}",
"/var/foo/01|{\"p1\":\"v202202\",\"p2\":\"v202202\"}"));
"/var/foo/01|{\"p1\":\"v202202\"}"));
}

return expectedPathsAtCheckpoint1;
Expand All @@ -569,7 +567,7 @@ private static List<String> getNodeStateAtCheckpoint2(boolean customRegexFilter,
"/content/2023/01|{\"p1\":\"v202301\"}",
"/content/dam|{}",
"/content/dam/1000|{}",
"/content/dam/1000/12|{\"p1\":\"v100012\",\"p2\":\"v100012\"}",
"/content/dam/1000/12|{\"p2\":\"v100012\"}",
"/content/dam/2022|{}",
"/content/dam/2022/02|{\"p1\":\"v202202-new\"}",
"/content/dam/2022/02/1|{\"p1\":\"v2022021\"}",
Expand Down Expand Up @@ -615,14 +613,15 @@ private static List<String> getNodeStateAtCheckpoint2(boolean customRegexFilter,
"/oak:index/fooIndex-2|{}",
"/var|{}",
"/var/bar|{}",
"/var/bar/01|{\"p1\":\"v202202-new\",\"p2\":\"v202202\",\"p3\":\"v202202\"}",
"/var/bar/01|{\"p1\":\"v202202-new\"}",
"/var/bar/02|{}",
"/var/foo|{\"p0\":\"v202202-new\"}",
"/var/foo/01|{\"p1\":\"v202202-new\",\"p2\":\"v202202\"}",
"/var/foo/01|{\"p1\":\"v202202-new\"}",
"/var/foo/02|{}"));

if (customRegexFilter) {
expectedPathsAtCheckpoint2.removeAll(List.of("/content/dam/2024/jcr:content/renditions/foo.metadata.xml|{}",
expectedPathsAtCheckpoint2.removeAll(List.of(
"/content/dam/2024/jcr:content/renditions/foo.metadata.xml|{}",
"/content/dam/2024/jcr:content/renditions/foo.metadata.xml/jcr:content|{\"foo\":\"bar\"}",
"/content/dam/2025/jcr:content/metadata/fooBar|{\"foo\":\"bar\"}",
"/content/dam/2026/jcr:content/renditions/foo.metadata.bar1|{}",
Expand All @@ -639,7 +638,7 @@ private static List<String> getNodeStateAtCheckpoint2(boolean customRegexFilter,
"/oak:index/barIndex-2|{}",
"/oak:index/fooIndex|{}",
"/oak:index/fooIndex-2|{}",
"/var/foo/01|{\"p1\":\"v202202-new\",\"p2\":\"v202202\"}",
"/var/foo/01|{\"p1\":\"v202202-new\"}",
"/var/foo/02|{}"));
}

Expand All @@ -648,9 +647,10 @@ private static List<String> getNodeStateAtCheckpoint2(boolean customRegexFilter,
}

private static List<String> getNodeStatesWithPrefferedPathsAndPathPredicatesOverBaseFFSAfterMerging(boolean customRegexFilter) {
List<String> expectedPaths = new ArrayList<>(List.of("/content/dam|{}",
List<String> expectedPaths = new ArrayList<>(List.of(
"/content/dam|{}",
"/content/dam/1000|{}",
"/content/dam/1000/12|{\"p1\":\"v100012\",\"p2\":\"v100012\"}",
"/content/dam/1000/12|{\"p2\":\"v100012\"}",
"/content/dam/2022|{}",
"/content/dam/2022/04|{}",
"/content/dam/2022/04/30|{\"p1\":\"v20220430\"}",
Expand Down
Loading