mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'fix/SEARCH-1829_e2e_test' into 'master'
[SEARCH-1829] See merge request search_discovery/insightengine!161
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<model name="shard:contentModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
|
||||
|
||||
<description>Explicit Routing for Sharding Sample Model</description>
|
||||
|
||||
<imports>
|
||||
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
|
||||
</imports>
|
||||
|
||||
<namespaces>
|
||||
<namespace uri="http://www.alfresco.org/model/sharding/1.0" prefix="shard"/>
|
||||
</namespaces>
|
||||
|
||||
<aspects>
|
||||
<aspect name="shard:sharding">
|
||||
<title>Sharding</title>
|
||||
<properties>
|
||||
<!-- Shard number to index this content -->
|
||||
<property name="shard:shardId">
|
||||
<title>Shard Id</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
</aspects>
|
||||
|
||||
</model>
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package org.alfresco.test.search.functional.searchServices.search;
|
||||
|
||||
import org.alfresco.search.TestGroup;
|
||||
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FileType;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
public class ExplicitRoutingTest extends AbstractE2EFunctionalTest {
|
||||
|
||||
|
||||
/**
|
||||
* Checks indexing still works after sharding model used for explicit routing has been disabled
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 1, groups = {TestGroup.NOT_BAMBOO, TestGroup.EXPLICIT_SHARDING })
|
||||
public void testIndexingStillWorkingAfterShardModelIsDeactivated() throws Exception
|
||||
{
|
||||
|
||||
// Deploy sharding model
|
||||
assertTrue(deployCustomModel("model/sharding-content-model.xml"),
|
||||
"failing while deploying sharding model");
|
||||
|
||||
// Create a first child in parent folder. It will be indexed in the parent shard (shard 0)
|
||||
FileModel file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> propertiesFirstChild = Map.of(PropertyIds.NAME, file.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:document",
|
||||
"cmis:secondaryObjectTypeIds", List.of("P:shard:sharding"),
|
||||
"shard:shardId", "0");
|
||||
|
||||
// Create file using shard:shardId
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite)
|
||||
.createFile(file,
|
||||
Map.of(PropertyIds.NAME, file.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:document"),
|
||||
VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
// Wait for file to be indexed
|
||||
assertTrue(isContentInSearchResults(file.getName(), file.getName(), true),
|
||||
"A file using sharding model has not been indexed");
|
||||
|
||||
|
||||
// Deleting file
|
||||
dataContent.usingSite(testSite).usingUser(testUser).usingResource(file).deleteContent();
|
||||
restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(file);
|
||||
|
||||
// Deleting sharding model
|
||||
assertTrue(deactivateCustomModel("sharding-content-model.xml"),
|
||||
"failing while deactivating sharding model");
|
||||
assertTrue(deleteCustomModel("sharding-content-model.xml"),
|
||||
"failing while removing sharding model");
|
||||
|
||||
assertTrue(waitForIndexing("TYPE:'" + "shard:shardId" + "'", false),
|
||||
"Indexes are not updated after deactivating a model");
|
||||
|
||||
// Create a file in the parent folder
|
||||
file = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite)
|
||||
.createFile(file,
|
||||
Map.of(PropertyIds.NAME, file.getName(),
|
||||
PropertyIds.OBJECT_TYPE_ID, "cmis:document"),
|
||||
VersioningState.MAJOR)
|
||||
.assertThat().existsInRepo();
|
||||
|
||||
|
||||
assertTrue(isContentInSearchResults(file.getName(), file.getName(), true),
|
||||
"Indexing is not working after the sharding model has been removed");
|
||||
|
||||
}
|
||||
}
|
||||
+64
-19
@@ -19,8 +19,12 @@ import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test class tests cascading updates for a child node when parent node is updated
|
||||
*
|
||||
@@ -31,6 +35,46 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
{
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
private FolderModel parentFolderSharded;
|
||||
private FileModel firstChildFileSharded;
|
||||
private FileModel secondChildFileSharded;
|
||||
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment()
|
||||
{
|
||||
assertTrue(deployCustomModel("model/sharding-content-model.xml"),
|
||||
"failing while deploying sharding model");
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public void cleanUpEnvironment()
|
||||
{
|
||||
if (firstChildFileSharded != null)
|
||||
{
|
||||
dataContent.usingSite(testSite).usingUser(testUser).usingResource(firstChildFileSharded).deleteContent();
|
||||
restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(firstChildFileSharded);
|
||||
}
|
||||
|
||||
if (secondChildFileSharded != null)
|
||||
{
|
||||
dataContent.usingSite(testSite).usingUser(testUser).usingResource(secondChildFileSharded).deleteContent();
|
||||
restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(secondChildFileSharded);
|
||||
}
|
||||
|
||||
if (parentFolderSharded != null)
|
||||
{
|
||||
dataContent.usingSite(testSite).usingUser(testUser).usingResource(parentFolderSharded).deleteContent();
|
||||
restClient.withCoreAPI().usingTrashcan().deleteNodeFromTrashcan(parentFolderSharded);
|
||||
}
|
||||
|
||||
dataContent.deleteSite(testSite);
|
||||
assertTrue(deactivateCustomModel("sharding-content-model.xml"),
|
||||
"failing while deactivating sharding model");
|
||||
assertTrue(deleteCustomModel("sharding-content-model.xml"),
|
||||
"failing while removing sharding model");
|
||||
}
|
||||
|
||||
@Test(priority = 1)
|
||||
public void testChildPathWhenParentRenamed() throws Exception
|
||||
@@ -143,53 +187,53 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
* 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 })
|
||||
@Test(priority = 3, 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();
|
||||
parentFolderSharded = FolderModel.getRandomFolderModel();
|
||||
|
||||
List<String> secondaryTypes = List.of("P:shard:sharding");
|
||||
Map<String, Object> parentProperties = Map.of(PropertyIds.NAME, parentFolder.getName(),
|
||||
Map<String, Object> parentProperties = Map.of(PropertyIds.NAME, parentFolderSharded.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(),
|
||||
firstChildFileSharded = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> propertiesFirstChild = Map.of(PropertyIds.NAME, firstChildFileSharded.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(),
|
||||
secondChildFileSharded = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
|
||||
Map<String, Object> propertiesSecondChild = Map.of(PropertyIds.NAME, secondChildFileSharded.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);
|
||||
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolderSharded, parentProperties).then()
|
||||
.usingResource(parentFolderSharded)
|
||||
.createFile(firstChildFileSharded, propertiesFirstChild, VersioningState.MAJOR)
|
||||
.createFile(secondChildFileSharded, 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.");
|
||||
assertTrue(waitForIndexing(firstChildFileSharded.getName(), true), "file: " + firstChildFileSharded.getName() + " has not been indexed.");
|
||||
assertTrue(waitForIndexing(secondChildFileSharded.getName(), true), "file: " + secondChildFileSharded.getName() + " has not been indexed.");
|
||||
assertTrue(waitForIndexing(parentFolderSharded.getName(), true), "file: " + parentFolderSharded.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() + "/*\"";
|
||||
"/cm:documentLibrary/cm:" + parentFolderSharded.getName() + "/*\"";
|
||||
|
||||
// Rename parent folder
|
||||
String parentNewName = "parentRenamedSharding";
|
||||
parentFolder.setName(parentNewName);
|
||||
parentFolderSharded.setName(parentNewName);
|
||||
ContentModel parentNewNameModel = new ContentModel(parentNewName);
|
||||
dataContent.usingUser(testUser).usingResource(parentFolder).renameContent(parentNewNameModel);
|
||||
dataContent.usingUser(testUser).usingResource(parentFolderSharded).renameContent(parentNewNameModel);
|
||||
|
||||
String parentQueryAfterRename = "PATH:\"/app:company_home/st:sites/cm:" + testSite.getTitle() +
|
||||
"/cm:documentLibrary/cm:" + parentNewName + "/*\"";
|
||||
@@ -199,9 +243,9 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
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);
|
||||
assertTrue(waitForMetadataIndexing(parentNewName, true), "failing while renaming " + parentFolderSharded.getName() + " to " + parentNewName);
|
||||
|
||||
boolean indexingInProgress = !isContentInSearchResults(parentQueryAfterRename, firstChildFile.getName(), true);
|
||||
boolean indexingInProgress = !isContentInSearchResults(parentQueryAfterRename, firstChildFileSharded.getName(), true);
|
||||
|
||||
// Query using new parent name: Expect the two children
|
||||
int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount();
|
||||
@@ -210,6 +254,7 @@ public class CascadingTrackerIntegrationTest extends AbstractE2EFunctionalTest
|
||||
// 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user