diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index 47a87e155..eb38f3b68 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -10,9 +10,9 @@ Search Analytics E2E Tests Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share - 1.47 - 1.13 - 3.0.27 + 1.49 + 1.16 + 3.0.33 3.3.1 src/test/resources/SearchSuite.xml @@ -128,4 +128,4 @@ 12-ea+10 - \ No newline at end of file + diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/solr/admin/SolrE2eActionTest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/solr/admin/SolrE2eActionTest.java new file mode 100644 index 000000000..31bea224b --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/solr/admin/SolrE2eActionTest.java @@ -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 . + * #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); + } + } + +} diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/solr/admin/SolrE2eAdminTest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/solr/admin/SolrE2eAdminTest.java index 5582bf01a..3c3718c8b 100644 --- a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/solr/admin/SolrE2eAdminTest.java +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/solr/admin/SolrE2eAdminTest.java @@ -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; diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java index 6f059b3ad..997acb053 100644 --- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java +++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/SolrInformationServer.java @@ -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)