-
Notifications
You must be signed in to change notification settings - Fork 37
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
Changes from 7 commits
990fb2b
62813bf
e6d7b02
57a761c
84bcee8
6887859
894d9f5
d89a698
02a559c
224dab1
e70d36d
2533a24
7f29166
bdddc98
3b95526
7836f6a
131ce5e
75101a1
a3f1876
fc4b215
7765aa1
b775e67
1a0a9b5
cec2927
12bed20
dcbe833
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
*/ | ||
@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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} |
There was a problem hiding this comment.
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!