mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-09-17 14:21:20 +00:00
Merge branch 'feature/SEARCH-2014_SolrAdminAPI_CherryPickMaster' into 'master'
Merge branch 'feature/SEARCH-2014_SolrAdminAPI_14x' into 'release/V1.4.x' See merge request search_discovery/insightengine!369
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
<description>Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share</description>
|
||||
<properties>
|
||||
<tas.rest.api.version>1.30</tas.rest.api.version>
|
||||
<tas.rest.api.version>1.26</tas.rest.api.version>
|
||||
<tas.cmis.api.version>1.13</tas.cmis.api.version>
|
||||
<tas.utility.version>3.0.19</tas.utility.version>
|
||||
<rm.version>3.3.0</rm.version>
|
||||
|
@@ -23,16 +23,18 @@ public class TestGroup
|
||||
// Used for TestRail test annotation
|
||||
public static final String SEARCH = "search";
|
||||
public static final String REST_API = "rest-api";
|
||||
|
||||
|
||||
public static final String PREUPGRADE = "pre-upgrade";
|
||||
public static final 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
|
||||
public static final String EXPLICIT_SHARDING ="Explicit_Sharding"; // Alfresco search services using sharded environment and explicit routing
|
||||
public static final String ASS_SHARDING = "ASS_Sharding"; // Alfresco Search Services using Sharding
|
||||
public static final String ASS_SHARDING_DB_ID_RANGE = "ASS_Sharding_DB_ID_RANGE"; // Alfresco Search Services using Sharding with DB_ID_RANGE
|
||||
|
||||
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
|
||||
|
@@ -0,0 +1,519 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Alfresco Software Limited.
|
||||
* This file is part of Alfresco
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.test.search.functional.searchServices.solr.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.search.TestGroup;
|
||||
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* End to end tests for SOLR Admin actions REST API, available from:
|
||||
*
|
||||
* http://<server>:<port>/solr/admin/cores?action=*
|
||||
*
|
||||
* @author aborroy
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class SolrE2eAdminTest extends AbstractE2EFunctionalTest
|
||||
{
|
||||
|
||||
|
||||
// SOLR default response status codes (returned in responseHeader.status)
|
||||
private static final String SOLR_RESPONSE_STATUS_OK = "0";
|
||||
private static final String SOLR_RESPONSE_STATUS_INTERNAL_ERROR = "400";
|
||||
|
||||
// Alfresco SOLR action response status identifiers
|
||||
private static final String ACTION_RESPONSE_REPORT = "report";
|
||||
|
||||
// Default Alfresco SOLR Core Names
|
||||
List<String> defaultCoreNames = new ArrayList<>(List.of("alfresco", "archive"));
|
||||
|
||||
@Test(priority = 1)
|
||||
public void testNodeReport() throws Exception
|
||||
{
|
||||
String nodeid = "200";
|
||||
RestResponse response = restClient.withParams("nodeid=" + nodeid).withSolrAdminAPI().getAction("nodeReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String report = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT).toString();
|
||||
Assert.assertNotNull(report);
|
||||
|
||||
defaultCoreNames.forEach(core -> {
|
||||
Assert.assertNotNull(response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Node Report requires "nodeid" parameter.
|
||||
* This test will fail as we are missing to pass the parameter.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 2)
|
||||
public void testNodeReportError() throws Exception
|
||||
{
|
||||
RestResponse response = restClient.withSolrAdminAPI().getAction("nodeReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@Test(priority = 3)
|
||||
public void testAclReport() throws Exception
|
||||
{
|
||||
String aclid = "1";
|
||||
RestResponse response = restClient.withParams("aclid=" + aclid).withSolrAdminAPI().getAction("aclReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String report = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT).toString();
|
||||
Assert.assertNotNull(report);
|
||||
}
|
||||
|
||||
/**
|
||||
* Acl Report requires "aclid" parameter.
|
||||
* This test will fail as we are missing to pass the parameter.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 4)
|
||||
public void testAclReportError() throws Exception
|
||||
{
|
||||
RestResponse response = restClient.withSolrAdminAPI().getAction("aclReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@Test(priority = 5)
|
||||
public void testTxReport() throws Exception
|
||||
{
|
||||
String coreName = "alfresco";
|
||||
String txid = "1";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + coreName, "txid=" + txid).withSolrAdminAPI().getAction("txReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String report = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT).toString();
|
||||
Assert.assertNotNull(report);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transaction report requires "txid" parameter.
|
||||
* This test will fail as we are missing to pass the parameter.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 6)
|
||||
public void testTxReportError() throws Exception
|
||||
{
|
||||
RestResponse response = restClient.withSolrAdminAPI().getAction("txReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@Test(priority = 7)
|
||||
public void testAclTxReport() throws Exception
|
||||
{
|
||||
String acltxid = "1";
|
||||
|
||||
RestResponse response = restClient.withParams("acltxid=" + acltxid).withSolrAdminAPI().getAction("aclTxReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String report = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT).toString();
|
||||
Assert.assertNotNull(report);
|
||||
}
|
||||
|
||||
/**
|
||||
* AclTx report requires "acltxid" parameter.
|
||||
* This test will fail as we are missing to pass the parameter.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 8)
|
||||
public void testAclTxReportError() throws Exception
|
||||
{
|
||||
RestResponse response = restClient.withSolrAdminAPI().getAction("aclTxReport");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@Test(priority = 9)
|
||||
public void testReport() throws Exception
|
||||
{
|
||||
RestResponse response = restClient.withSolrAdminAPI().getAction(ACTION_RESPONSE_REPORT);
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String report = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT).toString();
|
||||
Assert.assertNotNull(report);
|
||||
}
|
||||
|
||||
@Test(priority = 10)
|
||||
public void testSummary() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
|
||||
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("summary");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String report = response.getResponse().body().jsonPath().get("Summary").toString();
|
||||
Assert.assertNotNull(report);
|
||||
}
|
||||
|
||||
@Test(priority = 11)
|
||||
public void testCheck() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
|
||||
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("check");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* This action only applies to DB_ID_RANGE Sharding method.
|
||||
* This test verifies expected result when using another deployment
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 12)
|
||||
public void testRangeCheck() throws Exception
|
||||
{
|
||||
String coreName = "alfresco";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + coreName).withSolrAdminAPI().getAction("rangeCheck");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String expand = response.getResponse().body().jsonPath().get("expand").toString();
|
||||
Assert.assertEquals(expand, "-1");
|
||||
}
|
||||
|
||||
/**
|
||||
* When using DB_ID_RANGE Sharding method, expand param is including a number of nodes to be extended.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 13, groups = { TestGroup.ASS_SHARDING_DB_ID_RANGE })
|
||||
public void testRangeCheckSharding() throws Exception
|
||||
{
|
||||
String coreName = "alfresco";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + coreName).withSolrAdminAPI().getAction("rangeCheck");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String expand = response.getResponse().body().jsonPath().get("expand").toString();
|
||||
Assert.assertNotEquals(expand, "-1");
|
||||
}
|
||||
|
||||
/**
|
||||
* This action only applies to DB_ID_RANGE Sharding method.
|
||||
* This test verifies expected result when using another deployment
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 14)
|
||||
public void testExpand() throws Exception
|
||||
{
|
||||
String coreName = "alfresco";
|
||||
String add = "1000";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + coreName, "add=" + add).withSolrAdminAPI().getAction("expand");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
// This action only applies to DB_ID_RANGE Sharding method
|
||||
String expand = response.getResponse().body().jsonPath().get("expand").toString();
|
||||
Assert.assertEquals(expand, "-1");
|
||||
}
|
||||
|
||||
/**
|
||||
* When using DB_ID_RANGE Sharding method, expand param is including a number of nodes extended.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 15, groups = { TestGroup.ASS_SHARDING_DB_ID_RANGE })
|
||||
public void testExpandSharding() throws Exception
|
||||
{
|
||||
String coreName = "alfresco";
|
||||
String add = "1000";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + coreName, "add=" + add).withSolrAdminAPI().getAction("expand");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
// This action only applies to DB_ID_RANGE Sharding method
|
||||
String expand = response.getResponse().body().jsonPath().get("expand").toString();
|
||||
Assert.assertNotEquals(expand, "-1");
|
||||
}
|
||||
|
||||
@Test(priority = 16)
|
||||
public void testPurge() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
String txid = "1";
|
||||
|
||||
RestResponse response = restClient.withParams("core=" + core, "txid=" + txid).withSolrAdminAPI().getAction("purge");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "scheduled");
|
||||
}
|
||||
|
||||
@Test(priority = 17)
|
||||
public void testFix() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
|
||||
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("fix");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
Assert.assertNotNull(response.getResponse().body().jsonPath().get("action." + core +".txToReindex"));
|
||||
Assert.assertNotNull(response.getResponse().body().jsonPath().get("action." + core + ".aclChangeSetToReindex"));
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "scheduled");
|
||||
}
|
||||
|
||||
@Test(priority = 18)
|
||||
public void testReindex() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
String txid = "1";
|
||||
|
||||
RestResponse response = restClient.withParams("core=" + core, "txid=" + txid).withSolrAdminAPI().getAction("reindex");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "scheduled");
|
||||
}
|
||||
|
||||
@Test(priority = 19)
|
||||
public void testRetry() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
|
||||
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("retry");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "scheduled");
|
||||
}
|
||||
|
||||
@Test(priority = 20)
|
||||
public void testIndex() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
String txid = "1";
|
||||
|
||||
RestResponse response = restClient.withParams("core=" + core, "txid=" + txid).withSolrAdminAPI().getAction("index");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "scheduled");
|
||||
}
|
||||
|
||||
@Test(priority = 21)
|
||||
public void testLog4J() throws Exception
|
||||
{
|
||||
RestResponse response = restClient.withSolrAdminAPI().getAction("log4j");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* This test will fail if it's executed twice
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 22)
|
||||
public void testNewCore() throws Exception
|
||||
{
|
||||
String core = "newCore";
|
||||
String storeRef = "workspace://SpacesStore";
|
||||
String template = "rerank";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + core, "storeRef=" + storeRef, "template=" + template)
|
||||
.withSolrAdminAPI().getAction("newCore");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* When creating a core that already exists, this action fails.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 23)
|
||||
public void testNewCoreError() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
String template = "rerank";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + core, "template=" + template)
|
||||
.withSolrAdminAPI().getAction("newCore");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "error");
|
||||
}
|
||||
|
||||
@Test(priority = 24)
|
||||
public void testUpdateCore() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + core).withSolrAdminAPI().getAction("updateCore");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* When updating a core that doesn't exist, this action fails.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 25)
|
||||
public void testUpdateCoreError() throws Exception
|
||||
{
|
||||
String core = "nonExistingCore";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + core).withSolrAdminAPI().getAction("updateCore");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "error");
|
||||
}
|
||||
|
||||
/**
|
||||
* This test updates "shared.properties" memory loading for every SOLR core.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 26)
|
||||
public void testUpdateShared() throws Exception
|
||||
{
|
||||
RestResponse response = restClient.withSolrAdminAPI().getAction("updateShared");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* This test will fail if it's executed twice
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 27)
|
||||
public void testNewDefaultCore() throws Exception
|
||||
{
|
||||
String core = "newDefaultCore";
|
||||
String storeRef = "workspace://SpacesStore";
|
||||
String template = "rerank";
|
||||
|
||||
RestResponse response = restClient
|
||||
.withParams("coreName=" + core, "storeRef=" + storeRef, "template=" + template)
|
||||
.withSolrAdminAPI().getAction("newDefaultIndex");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "success");
|
||||
}
|
||||
|
||||
/**
|
||||
* When creating a core that already exists, this action fails.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(priority = 28)
|
||||
public void testNewDefaultCoreError() throws Exception
|
||||
{
|
||||
String core = "alfresco";
|
||||
String template = "rerank";
|
||||
|
||||
RestResponse response = restClient.withParams("coreName=" + core, "template=" + template)
|
||||
.withSolrAdminAPI().getAction("newDefaultIndex");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
|
||||
String actionStatus = response.getResponse().body().jsonPath().get("action.status").toString();
|
||||
Assert.assertEquals(actionStatus, "error");
|
||||
}
|
||||
|
||||
/**
|
||||
* This test has to be executed after "testNewCore" test, otherwise it will fail
|
||||
*/
|
||||
@Test(priority = 99, dependsOnMethods = ("testNewCore"))
|
||||
public void testRemoveCore() throws Exception
|
||||
{
|
||||
String core = "newCore";
|
||||
String storeRef = "workspace://SpacesStore";
|
||||
|
||||
RestResponse response = restClient
|
||||
.withParams("coreName=" + core, "storeRef=" + storeRef)
|
||||
.withSolrAdminAPI().getAction("removeCore");
|
||||
|
||||
String status = response.getResponse().body().jsonPath().get("responseHeader.status").toString();
|
||||
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK);
|
||||
}
|
||||
|
||||
}
|
@@ -20,7 +20,21 @@
|
||||
<exclude name="org.alfresco.test.search.functional.searchServices.search.rm"/>
|
||||
</package>
|
||||
</packages>
|
||||
<!-- Despite this class is included in Search Services package, needs to be excluded in order to be executed as the last one -->
|
||||
<classes>
|
||||
<class name="org.alfresco.test.search.functional.searchServices.solr.admin.SolrE2eAdminTest">
|
||||
<methods>
|
||||
<exclude name=".*" />
|
||||
</methods>
|
||||
</class>
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
<!-- This is deliberately scheduled at the end of the test suite because it messes with the cores and might break other tests -->
|
||||
<test name="Admin">
|
||||
<classes>
|
||||
<class name="org.alfresco.test.search.functional.searchServices.solr.admin.SolrE2eAdminTest" />
|
||||
</classes>
|
||||
</test>
|
||||
|
||||
</suite>
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -135,8 +135,13 @@ public class AclTracker extends AbstractTracker
|
||||
indexAcl(readers, false);
|
||||
}
|
||||
this.infoSrv.indexAclTransaction(changeSet, false);
|
||||
log.info("INDEX ACTION - AclChangeSetId {} has been indexed", aclChangeSetId);
|
||||
requiresCommit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("INDEX ACTION - AclChangeSetId {} was not found in database, it has NOT been reindexed", aclChangeSetId);
|
||||
}
|
||||
}
|
||||
checkShutdown();
|
||||
}
|
||||
@@ -160,6 +165,7 @@ public class AclTracker extends AbstractTracker
|
||||
//AclReaders r = readers.get(0);
|
||||
//System.out.println("############## READERS ID:"+r.getId()+":"+r.getReaders());
|
||||
indexAcl(readers, false);
|
||||
log.info("INDEX ACTION - AclId {} has been indexed", aclId);
|
||||
}
|
||||
checkShutdown();
|
||||
}
|
||||
@@ -187,8 +193,13 @@ public class AclTracker extends AbstractTracker
|
||||
}
|
||||
|
||||
this.infoSrv.indexAclTransaction(changeSet, true);
|
||||
log.info("REINDEX ACTION - AclChangeSetId {} has been reindexed", aclChangeSetId);
|
||||
requiresCommit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("REINDEX ACTION - AclChangeSetId {} was not found in database, it has NOT been reindexed", aclChangeSetId);
|
||||
}
|
||||
}
|
||||
checkShutdown();
|
||||
}
|
||||
@@ -212,6 +223,7 @@ public class AclTracker extends AbstractTracker
|
||||
Acl acl = new Acl(0, aclId);
|
||||
List<AclReaders> readers = client.getAclReaders(Collections.singletonList(acl));
|
||||
indexAcl(readers, true);
|
||||
log.info("REINDEX ACTION - aclId {} has been reindexed", aclId);
|
||||
requiresCommit = true;
|
||||
}
|
||||
checkShutdown();
|
||||
@@ -231,6 +243,7 @@ public class AclTracker extends AbstractTracker
|
||||
if (aclChangeSetId != null)
|
||||
{
|
||||
this.infoSrv.deleteByAclChangeSetId(aclChangeSetId);
|
||||
log.info("PURGE ACTION - Purged aclChangeSetId {}", aclChangeSetId);
|
||||
}
|
||||
checkShutdown();
|
||||
}
|
||||
@@ -245,6 +258,7 @@ public class AclTracker extends AbstractTracker
|
||||
if (aclId != null)
|
||||
{
|
||||
this.infoSrv.deleteByAclId(aclId);
|
||||
log.info("PURGE ACTION - Purged aclId {}", aclId);
|
||||
}
|
||||
checkShutdown();
|
||||
}
|
||||
|
@@ -359,10 +359,15 @@ public class MetadataTracker extends CoreStatePublisher implements Tracker
|
||||
|
||||
// Index the transaction doc after the node - if this is not found then a reindex will be done.
|
||||
this.infoSrv.indexTransaction(info, false);
|
||||
log.info("INDEX ACTION - Transaction {} has been indexed", transactionId);
|
||||
requiresCommit = true;
|
||||
|
||||
trackerStats.addTxDocs(nodes.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("INDEX ACTION - Transaction {} was not found in database, it has NOT been reindexed", transactionId);
|
||||
}
|
||||
}
|
||||
|
||||
if (docCount > batchCount)
|
||||
@@ -402,6 +407,7 @@ public class MetadataTracker extends CoreStatePublisher implements Tracker
|
||||
node.setTxnId(Long.MAX_VALUE);
|
||||
|
||||
this.infoSrv.indexNode(node, false);
|
||||
log.info("INDEX ACTION - Node {} has been reindexed", node.getId());
|
||||
requiresCommit = true;
|
||||
}
|
||||
checkShutdown();
|
||||
@@ -452,6 +458,11 @@ public class MetadataTracker extends CoreStatePublisher implements Tracker
|
||||
|
||||
// Index the transaction doc after the node - if this is not found then a reindex will be done.
|
||||
this.infoSrv.indexTransaction(info, true);
|
||||
log.info("REINDEX ACTION - Transaction {} has been reindexed", transactionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("REINDEX ACTION - Transaction {} was not found in database, it has NOT been reindexed", transactionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,6 +505,7 @@ public class MetadataTracker extends CoreStatePublisher implements Tracker
|
||||
node.setTxnId(Long.MAX_VALUE);
|
||||
|
||||
this.infoSrv.indexNode(node, true);
|
||||
log.info("REINDEX ACTION - Node {} has been reindexed", node.getId());
|
||||
requiresCommit = true;
|
||||
}
|
||||
checkShutdown();
|
||||
@@ -515,6 +527,7 @@ public class MetadataTracker extends CoreStatePublisher implements Tracker
|
||||
if (query != null)
|
||||
{
|
||||
this.infoSrv.reindexNodeByQuery(query);
|
||||
log.info("REINDEX ACTION - Nodes from query {} have been reindexed", query);
|
||||
requiresCommit = true;
|
||||
}
|
||||
checkShutdown();
|
||||
@@ -539,6 +552,7 @@ public class MetadataTracker extends CoreStatePublisher implements Tracker
|
||||
// make sure it is cleaned out so we do not miss deletes
|
||||
this.infoSrv.deleteByTransactionId(transactionId);
|
||||
requiresCommit = true;
|
||||
log.info("PURGE ACTION - Purged transactionId {}", transactionId);
|
||||
}
|
||||
checkShutdown();
|
||||
}
|
||||
@@ -559,6 +573,7 @@ public class MetadataTracker extends CoreStatePublisher implements Tracker
|
||||
{
|
||||
// make sure it is cleaned out so we do not miss deletes
|
||||
this.infoSrv.deleteByNodeId(nodeId);
|
||||
log.info("PURGE ACTION - Purged nodeId {}", nodeId);
|
||||
}
|
||||
checkShutdown();
|
||||
}
|
||||
|
@@ -61,6 +61,7 @@ import org.apache.solr.common.params.CoreAdminParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
@@ -368,7 +369,7 @@ public class AlfrescoCoreAdminHandlerIT
|
||||
|
||||
invalidNames.forEach(spy::setupNewDefaultCores);
|
||||
|
||||
verify(spy, never()).newCore(any(), anyInt(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any(), any());
|
||||
verify(spy, never()).newCore(any(), anyInt(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any());
|
||||
|
||||
reset(spy);
|
||||
|
||||
@@ -376,16 +377,17 @@ public class AlfrescoCoreAdminHandlerIT
|
||||
String commaSeparatedNames = String.join(",", invalidNames);
|
||||
spy.setupNewDefaultCores(commaSeparatedNames);
|
||||
|
||||
verify(spy, never()).newCore(any(), anyInt(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any(), any());
|
||||
verify(spy, never()).newCore(any(), anyInt(), any(), any(), anyInt(), anyInt(), anyInt(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void coreNamesAreTrimmed_oneCoreNameAtTime() {
|
||||
AlfrescoCoreAdminHandler spy = spy(new AlfrescoCoreAdminHandler() {
|
||||
@Override
|
||||
protected void newCore(String coreName, int numShards, StoreRef storeRef, String templateName, int replicationFactor, int nodeInstance, int numNodes, String shardIds, Properties extraProperties, SolrQueryResponse rsp)
|
||||
protected NamedList<Object> newCore(String coreName, int numShards, StoreRef storeRef, String templateName, int replicationFactor, int nodeInstance, int numNodes, String shardIds, Properties extraProperties)
|
||||
{
|
||||
// Do nothing here otherwise we cannot spy it
|
||||
return new SimpleOrderedMap<>();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -399,18 +401,19 @@ public class AlfrescoCoreAdminHandlerIT
|
||||
|
||||
coreNames.forEach(spy::setupNewDefaultCores);
|
||||
|
||||
verify(spy).newCore(eq(ARCHIVE_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ARCHIVE_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any());
|
||||
verify(spy).newCore(eq(ALFRESCO_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ALFRESCO_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any());
|
||||
verify(spy).newCore(eq(VERSION_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(VERSION_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any());
|
||||
verify(spy).newCore(eq(ARCHIVE_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ARCHIVE_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
|
||||
verify(spy).newCore(eq(ALFRESCO_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ALFRESCO_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
|
||||
verify(spy).newCore(eq(VERSION_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(VERSION_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validAndInvalidCoreNames() {
|
||||
AlfrescoCoreAdminHandler spy = spy(new AlfrescoCoreAdminHandler() {
|
||||
@Override
|
||||
protected void newCore(String coreName, int numShards, StoreRef storeRef, String templateName, int replicationFactor, int nodeInstance, int numNodes, String shardIds, Properties extraProperties, SolrQueryResponse rsp)
|
||||
protected NamedList<Object> newCore(String coreName, int numShards, StoreRef storeRef, String templateName, int replicationFactor, int nodeInstance, int numNodes, String shardIds, Properties extraProperties)
|
||||
{
|
||||
// Do nothing here otherwise we cannot spy it
|
||||
return new SimpleOrderedMap<>();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -426,8 +429,8 @@ public class AlfrescoCoreAdminHandlerIT
|
||||
String commaSeparatedNames = String.join(",", coreNames);
|
||||
spy.setupNewDefaultCores(commaSeparatedNames);
|
||||
|
||||
verify(spy).newCore(eq(ARCHIVE_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ARCHIVE_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any());
|
||||
verify(spy).newCore(eq(ALFRESCO_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ALFRESCO_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any());
|
||||
verify(spy).newCore(eq(VERSION_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(VERSION_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null), any());
|
||||
verify(spy).newCore(eq(ARCHIVE_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ARCHIVE_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
|
||||
verify(spy).newCore(eq(ALFRESCO_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ALFRESCO_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
|
||||
verify(spy).newCore(eq(VERSION_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(VERSION_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
|
||||
}
|
||||
}
|
@@ -881,14 +881,16 @@ public class AlfrescoSolrUtils
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
if(shards > 1 )
|
||||
{
|
||||
NamedList vals = response.getValues();
|
||||
List<String> coreNames = vals.getAll("core");
|
||||
NamedList action = (NamedList) response.getValues().get("action");
|
||||
List<String> coreNames = action.getAll("core");
|
||||
assertEquals(shards,coreNames.size());
|
||||
testingCore = getCore(coreContainer, coreNames.get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
assertEquals(coreName, response.getValues().get("core"));
|
||||
|
||||
NamedList action = (NamedList) response.getValues().get("action");
|
||||
assertEquals(coreName, action.get("core"));
|
||||
//Get a reference to the new core
|
||||
testingCore = getCore(coreContainer, coreName);
|
||||
}
|
||||
|
Reference in New Issue
Block a user