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

ACS-5471: Secondary path support #2585

Merged
merged 26 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
990fb2b
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
62813bf
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
e6d7b02
Merge branch 'master' into feature/ACS-5471-Secondary_path_support
krdabrowski Sep 28, 2023
57a761c
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
84bcee8
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
6887859
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
894d9f5
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
d89a698
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
02a559c
ACS-5471: Secondary path support
krdabrowski Sep 28, 2023
224dab1
Update tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsear…
krdabrowski Sep 28, 2023
e70d36d
Update tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsear…
krdabrowski Sep 28, 2023
2533a24
Update tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsear…
krdabrowski Sep 28, 2023
7f29166
Update tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsear…
krdabrowski Sep 28, 2023
bdddc98
ACS-5471: Secondary path support
krdabrowski Sep 29, 2023
3b95526
Merge branch 'master' into feature/ACS-5471-Secondary_path_support
krdabrowski Sep 29, 2023
7836f6a
ACS-5471: Secondary path support
krdabrowski Sep 29, 2023
131ce5e
ACS-5471: Suppressing PMD warning.
mpichura Oct 5, 2023
75101a1
Merge branch 'master' into feature/ACS-5471-Secondary_path_support
mpichura Oct 5, 2023
a3f1876
Merge branch 'master' into feature/ACS-5471-Secondary_path_support
mpichura Oct 9, 2023
fc4b215
Merge branch 'master' into feature/ACS-5471-Secondary_path_support
krdabrowski Oct 9, 2023
7765aa1
ACS-5471: Secondary path support
krdabrowski Oct 9, 2023
b775e67
ACS-5471: Secondary path support
krdabrowski Oct 10, 2023
1a0a9b5
ACS-5471: Secondary path support
krdabrowski Oct 10, 2023
cec2927
ACS-5471: Secondary path support
krdabrowski Oct 10, 2023
12bed20
ACS-5471: Secondary path support
krdabrowski Oct 10, 2023
dcbe833
ACS-5471: Secondary path support [skip tests]
krdabrowski Oct 10, 2023
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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<groupId>org.alfresco</groupId>
<artifactId>alfresco-enterprise-repo</artifactId>
<relativePath>../alfresco-enterprise-repo/pom.xml</relativePath>
<version>23.1.0.208</version>
<version>23.1.0.209-SNAPSHOT</version>
</parent>

<properties>
<dependency.alfresco-enterprise-repo.version>23.1.0.208</dependency.alfresco-enterprise-repo.version>
<dependency.alfresco-enterprise-repo.version>23.1.0.209-SNAPSHOT</dependency.alfresco-enterprise-repo.version>
<dependency.alfresco-enterprise-share.version>23.1.0.238</dependency.alfresco-enterprise-share.version>

<alfresco.rm-enterprise-rest-api-explorer.version>3.0.2</alfresco.rm-enterprise-rest-api-explorer.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
package org.alfresco.elasticsearch.reindexing;

import static org.alfresco.elasticsearch.SearchQueryService.req;
import static org.alfresco.utility.report.log.Step.STEP;

import org.alfresco.rest.search.SearchRequest;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.TestGroup;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/**
* Tests verifying live indexing of secondary children and ANCESTOR index in Elasticsearch.
*/
@SuppressWarnings({"PMD.JUnitTestsShouldIncludeAssert", "PMD.JUnit4TestShouldUseTestAnnotation"}) // these are testng tests and use searchQueryService.expectResultsFromQuery for assertion
public class NodesSecondaryAncestorIndexingTests extends NodesSecondaryChildrenRelatedTests
{

private FileModel fileInP;

/**
* Creates a user and a private site containing bellow hierarchy of folders.
* <pre>
* Site
* DL (Document Library)
* += fA += fB += fC (folderC)
* / / |
* + + +
* += fK += fL += fM
* | +
* + |
* += fX += fY += fZ
* += fP += file -+ fA
* += fQ
* += fR
* += fS
* </pre>
* Parent += Child - primary parent-child relationship
* Parent +- Child - secondary parent-child relationship
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really helpful - thanks!

*/
@BeforeClass(alwaysRun = true)
@Override
public void dataPreparation()
{
super.dataPreparation();

// given
STEP("Create few sets of nested folders in site's Document Library.");
folders().createNestedFolders(A, B, C);
folders().createNestedFolders(K, L, M);
folders().createNestedFolders(X, Y, Z);
folders().createFolder(P);
folders().createFolder(Q);
folders().createFolder(R);
folders().createFolder(S);
fileInP = folders(P).createRandomDocument();

STEP("Create few secondary parent-child relationships.");
folders(K).addSecondaryChild(folders(B));
folders(X).addSecondaryChild(folders(K));
folders(L).addSecondaryChildren(folders(C), folders(Y));
folders(M).addSecondaryChild(folders(C));
folders(A).addSecondaryChild(fileInP);
}

@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithNodeHavingOneSecondaryChild()
{
// then
STEP("Verify that searching by ANCESTOR and folderM will find one descendant node: folderC.");
SearchRequest query = req("ANCESTOR:" + folders(M).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
folders(C).getName());
}

@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithNodeHavingTwoSecondaryChildren()
{
// then
STEP("Verify that searching by ANCESTOR and folderC will find nodes: .");
krdabrowski marked this conversation as resolved.
Show resolved Hide resolved
SearchRequest queryAncestorC = req("ANCESTOR:" + folders(L).getNodeRef());
krdabrowski marked this conversation as resolved.
Show resolved Hide resolved
searchQueryService.expectResultsFromQuery(queryAncestorC, testUser,
krdabrowski marked this conversation as resolved.
Show resolved Hide resolved
// primary descendant
folders(M).getName(),
// secondary descendants
folders(C).getName(),
folders(Y).getName(),
folders(Z).getName());
}

@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithDocumentAsSecondaryChild()
{
// then
STEP("Verify that searching by ANCESTOR and folderA will find nodes: .");
krdabrowski marked this conversation as resolved.
Show resolved Hide resolved
SearchRequest query = req("ANCESTOR:" + folders(A).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
// primary descendants
folders(B).getName(),
folders(C).getName(),
// secondary descendant
fileInP.getName());
}

@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithNodeHavingComplexSecondaryRelationship()
{
// then
STEP("Verify that all descendant of folderX can be found.");
SearchRequest query = req("ANCESTOR:" + folders(X).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
// primary descendants
folders(Y).getName(),
folders(Z).getName(),
// secondary descendants
folders(B).getName(),
folders(C).getName(),
folders(K).getName(),
folders(L).getName(),
folders(M).getName()
);
}

/**
* Verify that removing secondary parent-child relationship will result in updating ES index: ANCESTOR.
* Test changes bellow folders hierarchy:
* <pre>
* DL
* += fQ
* +
* |
* += fR
* </pre>
* into:
* <pre>
* DL
* += fQ
* += fR
* </pre>
*/
@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithDeletedSecondaryRelationship()
{
// given
STEP("Add to folderQ a secondary child folderR and verify if it can be found using ANCESTOR index and secondary child node reference.");
folders(Q).addSecondaryChild(folders(R));

STEP("Verify that searching by ANCESTOR and folderQ will find secondary descendant node: folderR.");
SearchRequest query = req("ANCESTOR:" + folders(Q).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
// secondary descendant
folders(R).getName());

// when
STEP("Delete the secondary parent-child relationship between folderQ and FolderR.");
folders(Q).removeSecondaryChild(folders(R));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a risk that this test will be intermittent. I think we've seen the worst ES offenders are tests which change paths and then expect updates to happen soon afterwards. Could we instead change this to perform the add and remove in the precondition?

Alternatively we could just keep an eye out to see whether this test actually does fail frequently or not. Perhaps it will be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point, but before PTO I'm not able to fix all the tests, which change paths and then expect updates to happen soon afterwards. Lets keep eye on them and I can fix them after my PTO.


// then
STEP("Verify that folderQ cannot be found by ANCESTOR and folderQ anymore.");
searchQueryService.expectNoResultsFromQuery(query, testUser);
}

/**
* Verify that removing a node D (fD) having a secondary children relationship will remove the relationships and update ANCESTOR index in ES.
* Test changes bellow folders hierarchy from:
* <pre>
* DL
* += fQ
* +
* |
* += fD += fE
* +
* |
* += fR
* </pre>
* into:
* <pre>
* DL
* += fQ
* += fR
* </pre>
*/
@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithDeletedSecondaryParentNode()
{
// given
STEP("Create two nested folders (D and E) in Document Library.");
Folder folderD = folders().createFolder( "D");
Folder folderE = folderD.createNestedFolder( "E");
STEP("Make folderD a secondary children of folderQ and folderR a secondary children of folderD.");
folders(Q).addSecondaryChild(folderD);
folderD.addSecondaryChild(folders(R));

STEP("Verify that searching by ANCESTOR and folderQ will find it's secondary descendant: folderD, folderE and folderR.");
SearchRequest queryAncestorQ = req("ANCESTOR:" + folders(Q).getNodeRef());
searchQueryService.expectResultsFromQuery(queryAncestorQ, testUser,
// secondary descendants
folderD.getName(),
folderE.getName(),
folders(R).getName());

// when
STEP("Delete folderD with it's content.");
folders().delete(folderD);

// then
STEP("Verify that searching by ANCESTOR and folderQ will not find any nodes.");
searchQueryService.expectNoResultsFromQuery(queryAncestorQ, testUser);
}

/**
* Verify that moving folderD (fD) containing secondary children from hierarchy:
* <pre>
* DL
* += fQ += fD +- fP += file
* += fR
* </pre>
* to:
* <pre>
* DL
* += fQ
* += fR += fD +- fP += file
* </pre>
* will update ANCESTOR index in ES.
*/
@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithMovedSecondaryParentNode()
{
// given
STEP("Create folderD inside folderQ, and add folderP to D as a secondary child.");
Folder folderD = folders(Q).createNestedFolder( "D");
folderD.addSecondaryChild(folders(P));

STEP("Verify that searching by ANCESTOR and folderQ will find it's primary and secondary descendant nodes: folderD, folderP and file.");
SearchRequest queryAncestorQ = req("ANCESTOR:" + folders(Q).getNodeRef());
searchQueryService.expectResultsFromQuery(queryAncestorQ, testUser,
// primary descendant
folderD.getName(),
// secondary descendants
folders(P).getName(),
fileInP.getName());
STEP("Verify that searching by ANCESTOR and folderR will not find any descendant nodes.");
SearchRequest queryAncestorR = req("ANCESTOR:" + folders(R).getNodeRef());
searchQueryService.expectNoResultsFromQuery(queryAncestorR, testUser);

// when
STEP("Move folderD from folderQ to folderR.");
folderD.moveTo(folders(R));

// then
STEP("Verify that search result for ANCESTOR and folderQ will not find any descendant anymore.");
searchQueryService.expectNoResultsFromQuery(queryAncestorQ, testUser);
STEP("Verify that searching by ANCESTOR and folderR will find it's primary and secondary descendant nodes: folderD, folderP and file.");
searchQueryService.expectResultsFromQuery(queryAncestorR, testUser,
// primary descendant
folderD.getName(),
// secondary descendants
folders(P).getName(),
fileInP.getName());

STEP("Clean-up - delete folderD.");
folders().delete(folderD);
}

/**
* Verify that copying folder will also result in copying folder's secondary children and update ANCESTOR index in ES.
* Test change bellow folders hierarchy:
* <pre>
* DL
* += fS += fG += fH
* +
* /
* += fP += file
* += fT
* </pre>
* into:
* <pre>
* DL
* += fS += fG += fH
* +
* /
* += fP += file
* \
* +
* += fT += fG-c += fH-c
* </pre>
*/
@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithCopiedSecondaryParentNode()
{
// given
STEP("Create nested folders (G and H) inside folderS and folderT in Document Library. Make folderP a secondary child of folderG.");
Folder folderG = folders(S).createNestedFolder( "G");
Folder folderH = folderG.createNestedFolder("H");
Folder folderT = folders().createFolder("T");
folderG.addSecondaryChild(folders(P));

STEP("Verify that searching by ANCESTOR and folderS will find it's descendant nodes: folderG, folderH, folderP and file in P.");
SearchRequest queryAncestorS = req("ANCESTOR:" + folders(S).getNodeRef());
searchQueryService.expectResultsFromQuery(queryAncestorS, testUser,
// primary descendants
folderG.getName(),
folderH.getName(),
// secondary descendants
folders(P).getName(),
fileInP.getName());
STEP("Verify that searching by ANCESTOR and folderT will not find any nodes.");
SearchRequest queryAncestorT = req("ANCESTOR:" + folderT.getNodeRef());
searchQueryService.expectNoResultsFromQuery(queryAncestorT, testUser);

// when
STEP("Copy folderG with it's content to folderT.");
Folder folderGCopy = folderG.copyTo(folderT);

// then
STEP("Verify that searching by ANCESTOR and folderS will find it's descendant nodes: folderG, folderH, folderP and file in P.");
searchQueryService.expectResultsFromQuery(queryAncestorS, testUser,
// primary descendants
folderG.getName(),
folderH.getName(),
// secondary descendants
folders(P).getName(),
fileInP.getName());
STEP("Verify that searching by ANCESTOR and folderT will find it's descendant nodes: folderG-copy, folderH-copy, folderP, file.");
searchQueryService.expectResultsFromQuery(queryAncestorT, testUser,
// primary descendants
folderGCopy.getName(),
folderH.getName(), // the same name as folderH-copy
// secondary descendants
folders(P).getName(),
fileInP.getName());

STEP("Clean-up - delete folderG and folderT (with G's copy).");
folders().delete(folderG);
folders().delete(folderT);
}
}
Loading
Loading