mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +00:00
Merge branch 'fix/SEARCH-1641' into 'master'
Fix/search 1641 See merge request search_discovery/insightengine!107
This commit is contained in:
@@ -10,20 +10,24 @@ import java.lang.annotation.Target;
|
||||
public @interface TestGroup
|
||||
{
|
||||
// Used for TestRail test annotation
|
||||
public static final String SEARCH = "search";
|
||||
public static final String REST_API = "rest-api";
|
||||
String SEARCH = "search";
|
||||
String REST_API = "rest-api";
|
||||
|
||||
public static final String PREUPGRADE = "pre-upgrade";
|
||||
public static final String POSTUPGRADE = "post-upgrade";
|
||||
String PREUPGRADE = "pre-upgrade";
|
||||
String POSTUPGRADE = "post-upgrade";
|
||||
|
||||
public static final String ASS_MASTER_SLAVE = "ASS_Master_Slave"; // Alfresco Search Services using master slave configurations
|
||||
public static final String ASS_MASTER ="ASS_Master"; // Alfresco search services using master/stand alone mode
|
||||
String ASS_MASTER_SLAVE = "ASS_Master_Slave"; // Alfresco Search Services using master slave configurations
|
||||
String ASS_MASTER ="ASS_Master"; // Alfresco search services using master/stand alone mode
|
||||
String EXPLICIT_SHARDING ="Explicit_Sharding"; // Alfresco search services using sharded environment and explicit routing
|
||||
|
||||
String NOT_INSIGHT_ENGINE = "Not_InsightEngine"; // When Alfresco Insight Engine 1.0 isn't running
|
||||
|
||||
public static final String NOT_INSIGHT_ENGINE = "Not_InsightEngine"; // When Alfresco Insight Engine 1.0 isn't running
|
||||
|
||||
public static final String ACS_52n = "ACS_52n"; // Alfresco Content Services 5.2.n
|
||||
public static final String ACS_60n = "ACS_60n"; // Alfresco Content Services 6.0 or above
|
||||
public static final String ACS_61n = "ACS_61n"; // Alfresco Content Services 6.1 or above
|
||||
public static final String ACS_611n = "ACS_611n"; // Alfresco Content Services 6.1.1 or above
|
||||
public static final String ACS_62n = "ACS_62n"; // Alfresco Content Services 6.2 or above
|
||||
String ACS_52n = "ACS_52n"; // Alfresco Content Services 5.2.n
|
||||
String ACS_60n = "ACS_60n"; // Alfresco Content Services 6.0 or above
|
||||
String ACS_61n = "ACS_61n"; // Alfresco Content Services 6.1 or above
|
||||
String ACS_611n = "ACS_611n"; // Alfresco Content Services 6.1.1 or above
|
||||
String ACS_62n = "ACS_62n"; // Alfresco Content Services 6.2 or above
|
||||
|
||||
String NOT_BAMBOO = "Not_Bamboo"; // The does not run on bamboo
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ import org.alfresco.rest.core.RestProperties;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.rest.search.RestRequestHighlightModel;
|
||||
import org.alfresco.rest.search.RestRequestQueryModel;
|
||||
import org.alfresco.rest.search.SearchNodeModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.search.SearchResponse;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
@@ -42,14 +41,14 @@ import lombok.Getter;
|
||||
|
||||
import static lombok.AccessLevel.PROTECTED;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author meenal bhave
|
||||
*/
|
||||
@ContextConfiguration("classpath:alfresco-search-e2e-context.xml")
|
||||
public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringContextTests
|
||||
{
|
||||
public static final int SEARCH_MAX_ATTEMPS = 6;
|
||||
|
||||
private static Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@Autowired
|
||||
@@ -249,49 +248,30 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
|
||||
* @param contentToFind that's expected to be included / excluded from the results
|
||||
* @param expectedInResults
|
||||
* @return true if search returns expected results, i.e. is given content is found or excluded from the results
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean isContentInSearchResults(String userQuery, String contentToFind, boolean expectedInResults)
|
||||
throws Exception
|
||||
{
|
||||
boolean resultAsExpected = false;
|
||||
boolean found = !expectedInResults;
|
||||
public boolean isContentInSearchResults(String userQuery, String contentToFind, boolean expectedInResults) {
|
||||
|
||||
String expectedStatusCode = HttpStatus.OK.toString();
|
||||
String contentName = (contentToFind == null) ? "" : contentToFind;
|
||||
|
||||
// Repeat search until the query results are as expected or Search Retry count is hit
|
||||
for (int searchCount = 1; searchCount <= 6; searchCount++)
|
||||
for (int searchCount = 0; searchCount < SEARCH_MAX_ATTEMPS; searchCount++)
|
||||
{
|
||||
SearchRequest searchRequest = createQuery(userQuery);
|
||||
SearchResponse response = query(searchRequest);
|
||||
|
||||
if (restClient.getStatusCode().matches(expectedStatusCode))
|
||||
{
|
||||
List<SearchNodeModel> entries = response.getEntries();
|
||||
if (!entries.isEmpty())
|
||||
{
|
||||
if (contentName.isEmpty())
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (SearchNodeModel entry : entries)
|
||||
{
|
||||
found = (contentName.equalsIgnoreCase(entry.getModel().getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
found = false;
|
||||
}
|
||||
|
||||
boolean found = response.getEntries().stream()
|
||||
.map(entry -> entry.getModel().getName())
|
||||
.filter(name -> name.equalsIgnoreCase(contentName) || contentName.isBlank())
|
||||
.count() > 0;
|
||||
|
||||
// Loop again if result is not as expected: To cater for solr lag: eventual consistency
|
||||
resultAsExpected = (expectedInResults == found);
|
||||
if (resultAsExpected)
|
||||
if (expectedInResults == found)
|
||||
{
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -305,7 +285,7 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
|
||||
}
|
||||
}
|
||||
|
||||
return resultAsExpected;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,16 +6,15 @@
|
||||
*/
|
||||
package org.alfresco.test.search.functional.searchServices.search.tracker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.search.TestGroup;
|
||||
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.model.ContentModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.search.TestGroup;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,15 +41,16 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
// Create a file in the parent folder
|
||||
FileModel childFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.NAME, childFile.getName());
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(parentFolder)
|
||||
.createFile(childFile, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
.createFile(childFile,
|
||||
Map.of(PropertyIds.NAME, childFile.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:document"),
|
||||
VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
// Query to find nodes where Path with original folder name matches
|
||||
String parentQuery = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + parentFolder.getName() + "\"";
|
||||
String parentQuery = "PATH:\"/app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + parentFolder.getName() + "/*\"";
|
||||
|
||||
// Rename parent folder
|
||||
String parentNewName = "parentRenamed";
|
||||
@@ -62,12 +62,13 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
waitForMetadataIndexing(parentNewName, true);
|
||||
|
||||
// Find nodes where Path with new folder name matches
|
||||
String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + parentNewName + "\"";
|
||||
String parentQueryAfterRename = "PATH:\"/app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + parentNewName + "/*\"";
|
||||
boolean indexingInProgress = !isContentInSearchResults(parentQueryAfterRename, childFile.getName(), true);
|
||||
|
||||
// Query using new parent name: Expect parent folder and child file
|
||||
// Query using new parent name: Expect child file
|
||||
int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount();
|
||||
Assert.assertEquals(descendantCountOfNewName, 2, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress, parentQueryAfterRename));
|
||||
Assert.assertEquals(descendantCountOfNewName, 1, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress, parentQueryAfterRename));
|
||||
|
||||
// Query using old parent name: Expect no descendant after rename
|
||||
int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount();
|
||||
@@ -85,18 +86,22 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
|
||||
// Create grand child file
|
||||
FileModel grandChildFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(PropertyIds.NAME, grandChildFile.getName());
|
||||
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(childFolder)
|
||||
.createFile(grandChildFile, properties, VersioningState.MAJOR).assertThat().existsInRepo();
|
||||
.createFile(grandChildFile,
|
||||
Map.of(PropertyIds.NAME, grandChildFile.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:document"),
|
||||
VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
// Wait for file to be indexed
|
||||
waitForMetadataIndexing(grandChildFile.getName(), true);
|
||||
|
||||
// Query to find nodes where Path with original folder name matches
|
||||
String parentQuery = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + grandParentFolder.getName() + "\"";
|
||||
|
||||
String parentQuery = "PATH:\"/app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + grandParentFolder.getName() + "/*\"";
|
||||
|
||||
|
||||
// Rename grand parent folder
|
||||
String grandParentNewName = "grandParentRenamed";
|
||||
@@ -106,12 +111,101 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
dataContent.usingUser(testUser).usingResource(grandParentFolder).renameContent(grandParentFolderRenamed);
|
||||
|
||||
// Find nodes where Path with new folder name matches
|
||||
String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + grandParentNewName + "\"";
|
||||
boolean indexingInProgress = !isContentInSearchResults(parentQueryAfterRename, grandChildFile.getName(), true);
|
||||
String childrenQueryAfterRename = "PATH:\"/app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + grandParentNewName + "/*\"";
|
||||
|
||||
// Query using new parent name: Expect grand parent, child folder, grand child file
|
||||
String grandChildrenQueryAfterRename = "PATH:\"app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + grandParentNewName + "/cm:" + childFolder.getName() + "/*\"";
|
||||
|
||||
boolean indexingInProgress = !isContentInSearchResults(grandChildrenQueryAfterRename, grandChildFile.getName(), true);
|
||||
|
||||
// Query using new parent name: Expect grandchild file
|
||||
int grandChildrenCountOfNewName = query(grandChildrenQueryAfterRename).getPagination().getCount();
|
||||
Assert.assertEquals(grandChildrenCountOfNewName, 1,
|
||||
String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s",
|
||||
indexingInProgress,
|
||||
grandChildrenQueryAfterRename));
|
||||
|
||||
// Query using new parent name: Expect child folder
|
||||
int childrenCountOfNewName = query(childrenQueryAfterRename).getPagination().getCount();
|
||||
Assert.assertEquals(childrenCountOfNewName, 1,
|
||||
String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s",
|
||||
indexingInProgress,
|
||||
childrenQueryAfterRename));
|
||||
|
||||
// Query using old parent name: Expect no descendant after rename
|
||||
int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount();
|
||||
Assert.assertEquals(descendantCountOfOriginalName, 0, "Old path still has descendants: " + parentQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* Index three nodes (parent folder and two files) in two different shards.
|
||||
* Check that, after parent renaming, both the children are searchable in the new path
|
||||
* (computed accordingly with the new parent folder name)
|
||||
*/
|
||||
@Test(priority = 1, groups = {TestGroup.NOT_BAMBOO, TestGroup.EXPLICIT_SHARDING })
|
||||
public void testChildrenPathOnParentRenamedWithChildrenInDifferentShards() throws Exception
|
||||
{
|
||||
|
||||
// Create Parent folder. It will be indexed in shard 0
|
||||
FolderModel parentFolder = FolderModel.getRandomFolderModel();
|
||||
|
||||
List<String> secondaryTypes = List.of("P:shard:sharding");
|
||||
Map<String, Object> parentProperties = Map.of(PropertyIds.NAME, parentFolder.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:folder",
|
||||
"cmis:secondaryObjectTypeIds", secondaryTypes,
|
||||
"shard:shardId", "0");
|
||||
|
||||
// Create a first child in parent folder. It will be indexed in the parent shard (shard 0)
|
||||
FileModel firstChildFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> propertiesFirstChild = Map.of(PropertyIds.NAME, firstChildFile.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:document",
|
||||
"cmis:secondaryObjectTypeIds", secondaryTypes,
|
||||
"shard:shardId", "0");
|
||||
|
||||
// Create a second child in parent folder. It will be indexed in shard 1.
|
||||
FileModel secondChildFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> propertiesSecondChild = Map.of(PropertyIds.NAME, secondChildFile.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:document",
|
||||
"cmis:secondaryObjectTypeIds", secondaryTypes,
|
||||
"shard:shardId", "1");
|
||||
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder, parentProperties).then()
|
||||
.usingResource(parentFolder)
|
||||
.createFile(firstChildFile, propertiesFirstChild, VersioningState.MAJOR)
|
||||
.createFile(secondChildFile, propertiesSecondChild, VersioningState.MAJOR);
|
||||
|
||||
// Check everything is indexed
|
||||
Assert.assertTrue(waitForIndexing(firstChildFile.getName(), true), "file: " + firstChildFile.getName() + " has not been indexed.");
|
||||
Assert.assertTrue(waitForIndexing(secondChildFile.getName(), true), "file: " + secondChildFile.getName() + " has not been indexed.");
|
||||
Assert.assertTrue(waitForIndexing(parentFolder.getName(), true), "file: " + parentFolder.getName() + " has not been indexed.");
|
||||
|
||||
// Query to find nodes where Path with original folder name matches
|
||||
String parentQuery = "PATH:\"/app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + parentFolder.getName() + "/*\"";
|
||||
|
||||
// Rename parent folder
|
||||
String parentNewName = "parentRenamedSharding";
|
||||
parentFolder.setName(parentNewName);
|
||||
ContentModel parentNewNameModel = new ContentModel(parentNewName);
|
||||
dataContent.usingUser(testUser).usingResource(parentFolder).renameContent(parentNewNameModel);
|
||||
|
||||
String parentQueryAfterRename = "PATH:\"/app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + parentNewName + "/*\"";
|
||||
|
||||
// Query using new parent name: Expect the two children
|
||||
int descendantCountOfNewNameBeforeUpdate = query(parentQueryAfterRename).getPagination().getCount();
|
||||
Assert.assertEquals(descendantCountOfNewNameBeforeUpdate, 0, "There should be 0 results performing the new query before updating parent name");
|
||||
|
||||
|
||||
Assert.assertTrue(waitForMetadataIndexing(parentNewName, true), "failing while renaming " + parentFolder.getName() + " to " + parentNewName);
|
||||
|
||||
boolean indexingInProgress = !isContentInSearchResults(parentQueryAfterRename, firstChildFile.getName(), true);
|
||||
|
||||
// Query using new parent name: Expect the two children
|
||||
int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount();
|
||||
Assert.assertEquals(descendantCountOfNewName, 3, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress, parentQueryAfterRename));
|
||||
Assert.assertEquals(descendantCountOfNewName, 2, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress, parentQuery));
|
||||
|
||||
// Query using old parent name: Expect no descendant after rename
|
||||
int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount();
|
||||
|
Reference in New Issue
Block a user