SEARCH-2460: Correct validation of "isIndexed" property.

Index "unidexed" nodes only when global property to ignore them is not set.
Cherry picked from c2bc8a8
This commit is contained in:
Angel Borroy
2020-11-13 10:12:40 +01:00
parent ca8c69e53f
commit fb9d2753e3
4 changed files with 139 additions and 9 deletions

View File

@@ -10,9 +10,9 @@
<name>Search Analytics E2E Tests</name>
<description>Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share</description>
<properties>
<tas.rest.api.version>1.47</tas.rest.api.version>
<tas.cmis.api.version>1.13</tas.cmis.api.version>
<tas.utility.version>3.0.27</tas.utility.version>
<tas.rest.api.version>1.49</tas.rest.api.version>
<tas.cmis.api.version>1.16</tas.cmis.api.version>
<tas.utility.version>3.0.33</tas.utility.version>
<rm.version>3.3.1</rm.version>
<suiteXmlFile>src/test/resources/SearchSuite.xml</suiteXmlFile>
<test.exclude />
@@ -128,4 +128,4 @@
<version>12-ea+10</version>
</dependency>
</dependencies>
</project>
</project>

View File

@@ -0,0 +1,122 @@
/*
* #%L
* Alfresco Search Services E2E Test
* %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.test.search.functional.searchServices.solr.admin;
import static org.testng.Assert.assertEquals;
import org.alfresco.rest.core.RestResponse;
import org.alfresco.rest.search.RestRequestQueryModel;
import org.alfresco.rest.search.SearchRequest;
import org.alfresco.rest.search.SearchResponse;
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
import org.alfresco.utility.data.CustomObjectTypeProperties;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel;
import org.springframework.context.annotation.Configuration;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Tests validating the results of SOLR REST API Actions
*/
@Configuration
public class SolrE2eActionTest extends AbstractE2EFunctionalTest
{
// DBID (sys:node-dbid) value for the document
Integer dbId;
/**
* Create a new document and get the DBID value for it
*/
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
// Create a new document
FolderModel folder = new FolderModel("folder-aspect");
dataContent.usingUser(testUser).usingSite(testSite).createCustomContent(folder, "cmis:folder",
new CustomObjectTypeProperties());
FileModel file = new FileModel("file-aspect-" + System.currentTimeMillis() + ".txt");
file.setContent("content file aspect");
dataContent.usingUser(testUser).usingResource(folder).createCustomContent(file, "cmis:document",
new CustomObjectTypeProperties());
waitForMetadataIndexing(file.getName(), true);
// Get the DBID for the create document
String queryFile = "cm:name:" + file.getName();
restClient.authenticateUser(dataContent.getAdminUser()).withParams(queryFile).withSolrAPI()
.getSelectQueryJson();
dbId = Integer.valueOf(
restClient.onResponse().getResponse().body().jsonPath().get("response.docs[0].DBID").toString());
}
/**
* REINDEX for specific core using DBID
*
* @throws Exception
*/
@Test
public void testReindexNodeId()
{
final String deleteQueryBody = "{\"delete\":{\"query\": \"DBID:" + dbId + "\"}}";
try
{
// Remove document from SOLR
restClient.withSolrAPI().postAction("delete", deleteQueryBody);
// Re-index document using nodeId
RestResponse response = restClient.withParams("core=alfresco", "nodeId=" + dbId).withSolrAdminAPI()
.getAction("reindex");
String actionStatus = response.getResponse().body().jsonPath().get("action.alfresco.status");
Assert.assertEquals(actionStatus, "scheduled");
waitForMetadataIndexing("DBID:" + dbId, true);
// Verify the node has been re-indexed to its original type "cm:content"
String queryFile = "DBID:" + dbId;
RestRequestQueryModel queryModel = new RestRequestQueryModel();
queryModel.setQuery(queryFile);
queryModel.setLanguage(SearchLanguage.AFTS.toString());
SearchRequest searchRequest = new SearchRequest();
searchRequest.setQuery(queryModel);
SearchResponse searchResponse = restClient.authenticateUser(testUser).withSearchAPI().search(searchRequest);
assertEquals(searchResponse.getEntries().get(0).getModel().getNodeType(), "cm:content");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}

View File

@@ -27,8 +27,6 @@
package org.alfresco.test.search.functional.searchServices.solr.admin;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

View File

@@ -1721,13 +1721,23 @@ public class SolrInformationServer implements InformationServer
boolean isIndexed = ofNullable(pValue)
.map(StringPropertyValue::getValue)
.map(Boolean::parseBoolean)
.orElse(false);
.orElse(true);
addDocCmd.solrDoc = isIndexed
? populateWithMetadata(basicDocument(nodeMetaData, DOC_TYPE_NODE, PartialSolrInputDocument::new), nodeMetaData, nmdp)
: basicDocument(nodeMetaData, DOC_TYPE_UNINDEXED_NODE, SolrInputDocument::new);
? populateWithMetadata(
basicDocument(nodeMetaData, DOC_TYPE_NODE, PartialSolrInputDocument::new),
nodeMetaData, nmdp)
: (recordUnindexedNodes
? basicDocument(nodeMetaData, DOC_TYPE_UNINDEXED_NODE, SolrInputDocument::new)
: null);
// UnindexedNodes are not indexed when solrcore property flag "recordUnindexedNodes" is set to false
if (addDocCmd != null)
{
processor.processAdd(addDocCmd);
}
}
}
}
catch (Exception exception)