Merge branch 'master' of https://git.alfresco.com/search_discovery/insightengine into fix/Search-2096

This commit is contained in:
mbhave
2020-02-17 17:04:11 +00:00
17 changed files with 1869 additions and 213 deletions
@@ -23,7 +23,7 @@ services:
-Dsolr.host=<%=searchSolrHost%>
-Dsolr.port.ssl=8983
-Dsolr.secureComms=<%=secureComms%>
-Dsolr.base.url=/solr
-Dsolr.baseUrl=/solr
-Dindex.subsystem.name=solr6
-Dshare.host=localhost
-Dalfresco.port=8080
@@ -22,7 +22,7 @@ services:
-Dsolr.host=<%=searchSolrHost%>
-Dsolr.port.ssl=8983
-Dsolr.secureComms=<%=secureComms%>
-Dsolr.base.url=/solr <% if (sharding == 'true') { %>
-Dsolr.baseUrl=/solr <% if (sharding == 'true') { %>
-Dsolr.useDynamicShardRegistration=true <% } %>
-Dindex.subsystem.name=solr6
-Dalfresco-pdf-renderer.url=http://alfresco-pdf-renderer:8090/
@@ -24,7 +24,7 @@ services:
-Dsolr.host=<%=searchSolrHost%>
-Dsolr.port.ssl=8983
-Dsolr.secureComms=<%=secureComms%>
-Dsolr.base.url=/solr
-Dsolr.baseUrl=/solr
-Dindex.subsystem.name=solr6
-Dshare.host=localhost
-Dalfresco.port=8080
@@ -22,7 +22,7 @@ services:
-Dsolr.host=<%=searchSolrHost%>
-Dsolr.port.ssl=8983
-Dsolr.secureComms=<%=secureComms%>
-Dsolr.base.url=/solr <% if (sharding == 'true') { %>
-Dsolr.baseUrl=/solr <% if (sharding == 'true') { %>
-Dsolr.useDynamicShardRegistration=true <% } %>
-Dindex.subsystem.name=solr6
+1 -1
View File
@@ -14,7 +14,7 @@
<tas.rest.api.version>1.31</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>
<rm.version>3.3.0.1</rm.version>
<suiteXmlFile>src/test/resources/SearchSuite.xml</suiteXmlFile>
<test.exclude></test.exclude>
<test.include></test.include>
@@ -23,7 +23,7 @@ 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";
@@ -31,8 +31,13 @@ public class TestGroup
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 SHARDING ="Sharding"; // Alfresco search services using sharded environment
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
@@ -107,6 +107,7 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
deployCustomModel("model/music-model.xml");
deployCustomModel("model/finance-model.xml");
deployCustomModel("model/sharding-content-model.xml");
}
@BeforeClass (alwaysRun = true)
@@ -20,9 +20,13 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Sets;
import org.alfresco.rest.search.RestInstanceModel;
import org.alfresco.rest.search.RestShardInfoModel;
@@ -127,4 +131,80 @@ public class ShardInfoTest extends AbstractE2EFunctionalTest
restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo();
restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR);
}
/**
* This is a test to check that sharding is correctly working on bamboo and locally.
* Include test group 'sharding' on bamboo to enable this test to run
* @throws JsonProcessingException
*/
@Test(groups = { TestGroup.ACS_60n, TestGroup.SHARDING })
public void getShardInfoWith2OrMoreShards() throws JsonProcessingException
{
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo();
restClient.assertStatusCodeIs(HttpStatus.OK);
info.assertThat().entriesListIsNotEmpty();
assertEquals(info.getPagination().getTotalItems().intValue(), 2, "Pagination is: " + info.getPagination().getTotalItems().intValue() + " not expected value of 2");
Set<String> stores = Sets.newHashSet("workspace://SpacesStore", "archive://SpacesStore");
List<String> baseUrls = Arrays.asList("/solr/alfresco", "/solr/archive");
List<RestShardInfoModel> entries = info.getEntries();
Set<String> actualStores = entries.stream().map(shardInfoModel -> shardInfoModel.getModel().getStores()).collect(Collectors.toSet());
assertEquals(actualStores, stores, "The number of stores do not match the expected number of stores");
for (RestShardInfoModel shardInfoModel : entries)
{
RestShardInfoModel model = shardInfoModel.getModel();
assertEquals(model.getTemplate(), "rerank", "Template is not rerank, template found: "+ model.getTemplate());
assertEquals(model.getMode(), "MASTER", "Mode is not MASTER, mode found: "+ model.getMode());
assertTrue(model.getHasContent(), "There is no content on the shards");
assertTrue(model.getNumberOfShards()>=2, "Number of shards is not equal to or greater than 2");
List<String> shardingMethods = Arrays.asList("DB_ID", "DB_ID_RANGE", "EXPLICIT_ID", "ACL_ID", "MOD_ACL_ID", "DATE", "PROPERTY");
String shardingMethod = model.getShardMethod();
assertTrue(shardingMethods.contains(shardingMethod), "Unexpected Sharding Method Found: " + shardingMethod);
List<RestShardModel> shards = model.getShards();
assertNotNull(shards, "There are no shards present");
for (RestShardModel shardInstance : shards)
{
List<RestInstanceModel> instanceList = shardInstance.getInstances();
for (RestInstanceModel instanceX : instanceList)
{
assertTrue(baseUrls.contains(instanceX.getBaseUrl()), "The baseUrl is not present, baseUrl found is: " + instanceX.getBaseUrl());
assertEquals(instanceX.getState(), "ACTIVE", "Shard state is not ACTIVE, shard state is: " + instanceX.getState());
assertNotNull(instanceX.getPort(), "There is not port found for the instance");
assertEquals(instanceX.getMode(), "MASTER", "Mode is not MASTER, mode found: "+ instanceX.getMode());
assertTrue(instanceX.getTransactionsRemaining() >= 0, "Transactions remaining is not more than 0, transactions remaining: " + instanceX.getTransactionsRemaining());
String shardParams = (instanceX).getShardParams();
switch (shardingMethod)
{
case "MOD_ACL_ID":
break;
case "ACL_ID":
break;
case "DB_ID":
break;
case "DB_ID_RANGE":
// TODO: Uncomment the following assert when fixed: https://issues.alfresco.com/jira/browse/SEARCH-2110
//assertEquals(shardParams.contains("shard.range="), "Unexpected shard params defined for DB_ID_RANGE");
break;
case "DATE":
assertTrue(shardParams.contains("shard.key="), "Unexpected shard params defined for DATE");
assertTrue(shardParams.contains("shard.grouping="), "Unexpected shard grouping defined for DATE");
break;
case "PROPERTY":
assertTrue(shardParams.contains("shard.key="), "Unexpected shard params defined for PROPERTY");
break;
case "EXPLICIT_ID":
assertTrue(shardParams.contains("shard.key="), "Unexpected shard params defined for EXPLICIT_ID");
break;
default:
throw new AssertionError("Not as expected: " + shardParams.toString());
}
}
}
}
}
}
@@ -0,0 +1,973 @@
/*
* 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.Arrays;
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=(actionName)
*
* @author aborroy
*
*/
@Configuration
public class SolrE2eAdminTest extends AbstractE2EFunctionalTest
{
// SOLR default response status codes (returned in responseHeader.status)
private static final Integer SOLR_RESPONSE_STATUS_OK = 0;
// Alfresco SOLR action response status identifiers
private static final String ACTION_RESPONSE_REPORT = "report";
// Default Alfresco SOLR Core Names
private static final List<String> DEFAULT_CORE_NAMES = new ArrayList<>(List.of("alfresco", "archive"));
/**
* Check that SOLR Response Header contains a Query Time (qtime) and status equals to 0
* @param response SOLR REST API Response in JSON
*/
private void checkResponseStatusOk(RestResponse response)
{
Integer qtime = response.getResponse().body().jsonPath().get("responseHeader.QTime");
Assert.assertTrue(qtime >= 0, "Expeted responseHeader.QTime to be a positive number");
Integer status = response.getResponse().body().jsonPath().get("responseHeader.status");
Assert.assertEquals(status, SOLR_RESPONSE_STATUS_OK, "Expected " + SOLR_RESPONSE_STATUS_OK + " in responseHeader.status,");
}
/**
* Node Report for every core.
* @throws Exception
*/
@Test(priority = 1)
public void testNodeReport() throws Exception
{
Integer nodeid = 200;
RestResponse response = restClient.withParams("nodeid=" + nodeid).withSolrAdminAPI().getAction("nodeReport");
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
Integer reportNodeid = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".'Node DBID'");
Assert.assertEquals(reportNodeid, nodeid, "Expected " + nodeid + " in " + ACTION_RESPONSE_REPORT + "." + core + ".'Node DBID',");
});
}
/**
* Node Report for an specific core.
* @throws Exception
*/
@Test(priority = 2)
public void testNodeReportCore() throws Exception
{
final Integer nodeid = 200;
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("nodeid=" + nodeid, "core=" + core).withSolrAdminAPI().getAction("nodeReport");
checkResponseStatusOk(response);
Integer reportNodeid = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".'Node DBID'");
Assert.assertEquals(reportNodeid, nodeid, "Expected " + nodeid + " in " + ACTION_RESPONSE_REPORT + "." + core + ".'Node DBID',");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* Node Report requires "nodeid" parameter.
* This test will return an error as we are missing to pass the parameter.
* @throws Exception
*/
@Test(priority = 3)
public void testNodeReportError() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("nodeReport");
checkResponseStatusOk(response);
String reportError = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + ".error");
Assert.assertEquals(reportError, "No nodeid parameter set.", "Unexpected message in " + ACTION_RESPONSE_REPORT + ".error,");
}
/**
* ACL Report for every core.
* @throws Exception
*/
@Test(priority = 4)
public void testAclReport() throws Exception
{
Integer aclid = 1;
RestResponse response = restClient.withParams("aclid=" + aclid).withSolrAdminAPI().getAction("aclReport");
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
Integer reportAclid = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".'Acl Id'");
Assert.assertEquals(reportAclid, aclid, "Expected " + aclid + " in " + ACTION_RESPONSE_REPORT + "." + core + ".'Acl Id',");
});
}
/**
* ACL Report for an specific core.
* @throws Exception
*/
@Test(priority = 5)
public void testAclReportCore() throws Exception
{
final Integer aclid = 1;
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("aclid=" + aclid, "core=" + core).withSolrAdminAPI().getAction("aclReport");
checkResponseStatusOk(response);
Integer reportAclid = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".'Acl Id'");
Assert.assertEquals(reportAclid, aclid, "Expected " + aclid + " in " + ACTION_RESPONSE_REPORT + "." + core + ".'Acl Id',");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* ACL Report requires "aclid" parameter.
* This test will fail as we are missing to pass the parameter.
* @throws Exception
*/
@Test(priority = 6)
public void testAclReportError() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("aclReport");
checkResponseStatusOk(response);
String reportError = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + ".error");
Assert.assertEquals(reportError, "No aclid parameter set.", "Unexpected message in " + ACTION_RESPONSE_REPORT + ".error,");
}
/**
* TX Report for every core.
* @throws Exception
*/
@Test(priority = 7)
public void testTxReport() throws Exception
{
Integer txid = 1;
RestResponse response = restClient.withParams("txid=" + txid).withSolrAdminAPI().getAction("txReport");
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
Integer reportTxid = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".TXID");
Assert.assertEquals(reportTxid, txid, "Expected " + txid + " in " + ACTION_RESPONSE_REPORT + "." + core + ".TXID,");
});
}
/**
* TX Report for an specific core.
* @throws Exception
*/
@Test(priority = 8)
public void testTxReportCore() throws Exception
{
final Integer txid = 1;
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("coreName=" + core, "txid=" + txid).withSolrAdminAPI().getAction("txReport");
checkResponseStatusOk(response);
Integer reportTxid = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".TXID");
Assert.assertEquals(reportTxid, txid, "Expected " + txid + " in " + ACTION_RESPONSE_REPORT + "." + core + ".TXID,");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* Transaction report requires "txid" parameter.
* This test will fail as we are missing to pass the parameter.
* @throws Exception
*/
@Test(priority = 9)
public void testTxReportError() throws Exception
{
String coreName = "alfresco";
RestResponse response = restClient.withParams("coreName=" + coreName).withSolrAdminAPI().getAction("txReport");
checkResponseStatusOk(response);
String reportError = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + ".error");
Assert.assertEquals(reportError, "No txid parameter set.", "Unexpected message in " + ACTION_RESPONSE_REPORT + ".error,");
}
/**
* ACL TX Report for every core.
* @throws Exception
*/
@Test(priority = 10)
public void testAclTxReport() throws Exception
{
Integer acltxid = 1;
RestResponse response = restClient.withParams("acltxid=" + acltxid).withSolrAdminAPI().getAction("aclTxReport");
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
Integer reportAcltxidCount = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".aclTxDbAclCount");
Assert.assertEquals(reportAcltxidCount, Integer.valueOf(2), "Expected 2 in " + ACTION_RESPONSE_REPORT + "." + core + ".aclTxDbAclCount,");
});
}
/**
* ACL TX Report for specific core.
* @throws Exception
*/
@Test(priority = 11)
public void testAclTxReportCore() throws Exception
{
final Integer acltxid = 1;
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("acltxid=" + acltxid, "core=" + core).withSolrAdminAPI().getAction("aclTxReport");
checkResponseStatusOk(response);
Integer reportAcltxidCount = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".aclTxDbAclCount");
Assert.assertEquals(reportAcltxidCount, Integer.valueOf(2), "Expected 2 in " + ACTION_RESPONSE_REPORT + "." + core + ".aclTxDbAclCount,");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* AclTx report requires "acltxid" parameter.
* This test will fail as we are missing to pass the parameter.
* @throws Exception
*/
@Test(priority = 12)
public void testAclTxReportError() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("aclTxReport");
checkResponseStatusOk(response);
String reportError = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + ".error");
Assert.assertEquals(reportError, "No acltxid parameter set.", "Unexpected message in " + ACTION_RESPONSE_REPORT + ".error,");
}
/**
* Report for every core.
* @throws Exception
*/
@Test(priority = 13)
public void testReport() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction(ACTION_RESPONSE_REPORT);
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
Integer reportTxCount = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".'DB transaction count'");
Assert.assertTrue(reportTxCount > 0, "Expecting a positive integer in " + ACTION_RESPONSE_REPORT + "." + core + ".'DB transaction count',");
});
}
/**
* Report for specific core.
* @throws Exception
*/
@Test(priority = 14)
public void testReportCore() throws Exception
{
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("coreName=" + core).withSolrAdminAPI().getAction(ACTION_RESPONSE_REPORT);
checkResponseStatusOk(response);
Integer reportTxCount = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".'DB transaction count'");
Assert.assertTrue(reportTxCount > 0, "Expecting a positive integer in " + ACTION_RESPONSE_REPORT + "." + core + ".'DB transaction count',");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* Report using params.
* @throws Exception
*/
@Test(priority = 15)
public void testReportWithParams() throws Exception
{
Long fromTime = 0l;
Long toTime = 0l;
RestResponse response = restClient.withParams("fromTime=" + fromTime, "toTime=" + toTime).withSolrAdminAPI()
.getAction(ACTION_RESPONSE_REPORT);
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
Integer reportTxCount = response.getResponse().body().jsonPath().get(ACTION_RESPONSE_REPORT + "." + core + ".'DB transaction count'");
Assert.assertTrue(reportTxCount == 0, "Expecting 0 in " + ACTION_RESPONSE_REPORT + "." + core + ".'DB transaction count',");
});
}
/**
* Summary for every core.
* @throws Exception
*/
@Test(priority = 16)
public void testSummary() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("summary");
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
Integer reportTxCount = response.getResponse().body().jsonPath().get("Summary." + core + ".'Alfresco Transactions in Index'");
Assert.assertTrue(reportTxCount > 0, "Expecting a positive integer in Summary." + core + ".'Alfresco Transactions in Index',");
});
}
/**
* Summary for specific core.
* @throws Exception
*/
@Test(priority = 17)
public void testSummaryCore() throws Exception
{
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("summary");
checkResponseStatusOk(response);
Integer reportTxCount = response.getResponse().body().jsonPath().get("Summary." + core + ".'Alfresco Transactions in Index'");
Assert.assertTrue(reportTxCount > 0, "Expecting a positive integer in Summary." + core + ".'Alfresco Transactions in Index',");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* Check every core.
* @throws Exception
*/
@Test(priority = 18)
public void testCheck() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("check");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
}
/**
* Check specific core.
* @throws Exception
*/
@Test(priority = 19)
public void testCheckCore() throws Exception
{
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("check");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* This action only applies to DB_ID_RANGE Sharding method.
* This test verifies expected result when using another deployment
* @throws Exception
*/
@Test(priority = 20)
public void testRangeCheck() throws Exception
{
String coreName = "alfresco";
RestResponse response = restClient.withParams("coreName=" + coreName).withSolrAdminAPI().getAction("rangeCheck");
checkResponseStatusOk(response);
Integer expand = response.getResponse().body().jsonPath().get("expand");
Assert.assertEquals(expand, Integer.valueOf(-1), "Expansion is not allowed when not using Shard DB_ID_RANGE method,");
}
/**
* When using DB_ID_RANGE Sharding method, expand param is including a number of nodes to be extended.
* @throws Exception
*/
@Test(priority = 21, groups = { TestGroup.ASS_SHARDING_DB_ID_RANGE })
public void testRangeCheckSharding() throws Exception
{
String coreName = "alfresco";
RestResponse response = restClient.withParams("coreName=" + coreName).withSolrAdminAPI().getAction("rangeCheck");
checkResponseStatusOk(response);
Integer expand = response.getResponse().body().jsonPath().get("expand");
Assert.assertNotEquals(expand, Integer.valueOf(-1), "Expansion is a positive number when using Shard DB_ID_RANGE method,");
}
/**
* This action only applies to DB_ID_RANGE Sharding method.
* This test verifies expected result when using another deployment
* @throws Exception
*/
@Test(priority = 22)
public void testExpand() throws Exception
{
String coreName = "alfresco";
String add = "1000";
RestResponse response = restClient.withParams("coreName=" + coreName, "add=" + add).withSolrAdminAPI().getAction("expand");
checkResponseStatusOk(response);
// This action only applies to DB_ID_RANGE Sharding method
Integer expand = response.getResponse().body().jsonPath().get("expand");
Assert.assertEquals(expand, Integer.valueOf(-1), "Expansion is not allowed when not using Shard DB_ID_RANGE method,");
}
/**
* When using DB_ID_RANGE Sharding method, expand param is including a number of nodes extended.
* @throws Exception
*/
@Test(priority = 23, 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");
checkResponseStatusOk(response);
// This action only applies to DB_ID_RANGE Sharding method
Integer expand = response.getResponse().body().jsonPath().get("expand");
Assert.assertNotEquals(expand, Integer.valueOf(-1), "Expansion is a positive number when using Shard DB_ID_RANGE method,");
}
/**
* Purge TX in every core.
* @throws Exception
*/
@Test(priority = 24)
public void testPurge() throws Exception
{
Integer txid = 1;
RestResponse response = restClient.withParams("txid=" + txid).withSolrAdminAPI().getAction("purge");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
/**
* Purge TX in specific core.
* @throws Exception
*/
@Test(priority = 25)
public void testPurgeCore() throws Exception
{
final Integer txid = 1;
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("core=" + core, "txid=" + txid).withSolrAdminAPI().getAction("purge");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* Purge with no params produces an empty response.
* @throws Exception
*/
@Test(priority = 26)
public void testPurgeEmpty() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("purge");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
/**
* FIX for every core.
* @throws Exception
*/
@Test(priority = 27, dependsOnMethods = "testPurge")
public void testFix() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("fix");
checkResponseStatusOk(response);
DEFAULT_CORE_NAMES.forEach(core -> {
List<String> txToReindex = response.getResponse().body().jsonPath().get("action." + core +".txToReindex");
Assert.assertTrue(txToReindex.size() >= 0, "Expected a list of transactions (or empty list) to be reindexed,");
List<String> aclToReindex = response.getResponse().body().jsonPath().get("action." + core + ".aclChangeSetToReindex");
Assert.assertTrue(aclToReindex.size() >= 0, "Expected a list of ACLs (or empty list) to be reindexed,");
});
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
/**
* FIX for specific core.
* @throws Exception
*/
@Test(priority = 28)
public void testFixCore() throws Exception
{
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("fix");
checkResponseStatusOk(response);
List<String> txToReindex = response.getResponse().body().jsonPath().get("action." + core +".txToReindex");
Assert.assertTrue(txToReindex.size() >= 0, "Expected a list of transactions (or empty list) to be reindexed,");
List<String> aclToReindex = response.getResponse().body().jsonPath().get("action." + core + ".aclChangeSetToReindex");
Assert.assertTrue(aclToReindex.size() >= 0, "Expected a list of ACLs (or empty list) to be reindexed,");
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* REINDEX for every core.
* @throws Exception
*/
@Test(priority = 29)
public void testReindex() throws Exception
{
Integer txid = 1;
RestResponse response = restClient.withParams("txid=" + txid).withSolrAdminAPI().getAction("reindex");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
/**
* REINDEX for specific core.
* @throws Exception
*/
@Test(priority = 30)
public void testReindexCore() throws Exception
{
Integer txid = 1;
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("core=" + core, "txid=" + txid).withSolrAdminAPI().getAction("reindex");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* RETRY for every core.
* @throws Exception
*/
@Test(priority = 31)
public void testRetry() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("retry");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
DEFAULT_CORE_NAMES.forEach(core -> {
List<String> errorNodeList = response.getResponse().body().jsonPath().get("action." + core);
Assert.assertEquals(errorNodeList, Arrays.asList(), "Expected no error nodes,");
});
}
/**
* RETRY for specific core.
* @throws Exception
*/
@Test(priority = 32)
public void testRetryCore() throws Exception
{
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("core=" + core).withSolrAdminAPI().getAction("retry");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
List<String> errorNodeList = response.getResponse().body().jsonPath().get("action." + core);
Assert.assertEquals(errorNodeList, Arrays.asList(), "Expected no error nodes,");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* INDEX for every core.
* @throws Exception
*/
@Test(priority = 33)
public void testIndex() throws Exception
{
Integer txid = 1;
RestResponse response = restClient.withParams("txid=" + txid).withSolrAdminAPI().getAction("index");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
/**
* INDEX for specific core.
* @throws Exception
*/
@Test(priority = 34)
public void testIndexCore() throws Exception
{
final Integer txid = 1;
DEFAULT_CORE_NAMES.forEach(core -> {
try
{
RestResponse response = restClient.withParams("core=" + core, "txid=" + txid).withSolrAdminAPI().getAction("index");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "scheduled");
}
catch (Exception e)
{
throw new RuntimeException(e);
}
});
}
/**
* Reloads default log4j properties into memory.
* @throws Exception
*/
@Test(priority = 35)
public void testLog4J() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("log4j");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
}
/**
* This REST API call will fail as the specified resource to reload doesn't exist.
* @throws Exception
*/
@Test(priority = 36)
public void testLog4JError() throws Exception
{
RestResponse response = restClient.withParams("resource=log4j-unexisting.properties").withSolrAdminAPI().getAction("log4j");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "error");
}
/**
* This test will fail if it's executed twice
* @throws Exception
*/
@Test(priority = 37)
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");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
String actionCore = response.getResponse().body().jsonPath().get("action.core");
Assert.assertEquals(actionCore, core, "Created core name is expected in action.core,");
}
/**
* When creating a core that already exists, this action fails.
* @throws Exception
*/
@Test(priority = 38)
public void testNewCoreError() throws Exception
{
String core = "alfresco";
String template = "rerank";
RestResponse response = restClient.withParams("coreName=" + core, "template=" + template)
.withSolrAdminAPI().getAction("newCore");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "error");
}
/**
* Reloads core configuration in memory.
* @throws Exception
*/
@Test(priority = 39)
public void testUpdateCore() throws Exception
{
String core = "alfresco";
RestResponse response = restClient.withParams("coreName=" + core).withSolrAdminAPI().getAction("updateCore");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
}
/**
* When updating a core that doesn't exist, this action fails.
* @throws Exception
*/
@Test(priority = 40)
public void testUpdateCoreError() throws Exception
{
String core = "nonExistingCore";
RestResponse response = restClient.withParams("coreName=" + core).withSolrAdminAPI().getAction("updateCore");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "error");
}
/**
* This test updates "shared.properties" memory loading for every SOLR core.
* @throws Exception
*/
@Test(priority = 41)
public void testUpdateShared() throws Exception
{
RestResponse response = restClient.withSolrAdminAPI().getAction("updateShared");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
}
/**
* This test will fail if it's executed twice
* @throws Exception
*/
@Test(priority = 42)
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");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
String actionCore = response.getResponse().body().jsonPath().get("action.core");
Assert.assertEquals(actionCore, core, "Created core name is expected in action.core,");
}
/**
* When creating a core that already exists, this action fails.
* @throws Exception
*/
@Test(priority = 43)
public void testNewDefaultCoreError() throws Exception
{
String core = "alfresco";
String template = "rerank";
RestResponse response = restClient.withParams("coreName=" + core, "template=" + template)
.withSolrAdminAPI().getAction("newDefaultIndex");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
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");
checkResponseStatusOk(response);
String actionStatus = response.getResponse().body().jsonPath().get("action.status");
Assert.assertEquals(actionStatus, "success");
}
}
@@ -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>
@@ -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();
}
@@ -165,6 +165,7 @@ alfresco.metadata.ignore.datatype.1=app:configurations
alfresco.metadata.skipDescendantDocsForSpecificAspects=false
#alfresco.metadata.ignore.aspect.0=
# The number of matches from the index to include when rewriting wildcard search terms as an OR-ed list.
alfresco.topTermSpanRewriteLimit=1000
#
@@ -165,6 +165,7 @@ alfresco.metadata.ignore.datatype.1=app:configurations
alfresco.metadata.skipDescendantDocsForSpecificAspects=false
#alfresco.metadata.ignore.aspect.0=
# The number of matches from the index to include when rewriting wildcard search terms as an OR-ed list.
alfresco.topTermSpanRewriteLimit=1000
#
@@ -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;
@@ -289,23 +290,6 @@ public class AlfrescoCoreAdminHandlerIT
when(params.get(CoreAdminParams.ACTION)).thenReturn(TXREPORT);
when(params.get(CoreAdminParams.CORE)).thenReturn(CORE_NAME);
when(params.get(ARG_TXID)).thenReturn(TX_ID);
// Set up the mock ACL tracker.
when(trackerRegistry.getTrackerForCore(CORE_NAME, AclTracker.class)).thenReturn(aclTracker);
when(aclTracker.checkIndex(Long.valueOf(TX_ID), 0L, null, null)).thenReturn(indexHealthReport);
when(indexHealthReport.getDuplicatedAclTxInIndex()).thenReturn(iOpenBitSet);
when(indexHealthReport.getAclTxInIndexButNotInDb()).thenReturn(iOpenBitSet);
when(indexHealthReport.getMissingAclTxFromIndex()).thenReturn(iOpenBitSet);
when(aclTracker.getTrackerState()).thenReturn(trackerState);
// Set up the mock metadata tracker.
when(trackerRegistry.getTrackerForCore(CORE_NAME, MetadataTracker.class)).thenReturn(metadataTracker);
when(metadataTracker.checkIndex(Long.valueOf(TX_ID), 0L, null, null)).thenReturn(metaReport);
when(metaReport.getDuplicatedTxInIndex()).thenReturn(iOpenBitSet);
when(metaReport.getTxInIndexButNotInDb()).thenReturn(iOpenBitSet);
when(metaReport.getMissingTxFromIndex()).thenReturn(iOpenBitSet);
when(metaReport.getDuplicatedLeafInIndex()).thenReturn(iOpenBitSet);
when(metaReport.getDuplicatedErrorInIndex()).thenReturn(iOpenBitSet);
when(metaReport.getDuplicatedUnindexedInIndex()).thenReturn(iOpenBitSet);
when(metadataTracker.getTrackerState()).thenReturn(trackerState);
// Call the method under test.
alfrescoCoreAdminHandler.handleCustomAction(req, rsp);
@@ -314,24 +298,27 @@ public class AlfrescoCoreAdminHandlerIT
verify(rsp).add(eq("report"), any(NamedList.class));
}
/** Check that when the transaction id is missing we get an exception. */
@Test(expected = SolrException.class)
/** Check that when the transaction id is missing we get an error message. */
@Test
public void handleCustomActionTXReportMissingTXId()
{
when(params.get(CoreAdminParams.ACTION)).thenReturn(TXREPORT);
alfrescoCoreAdminHandler.handleCustomAction(req, rsp);
verify(rsp, never()).add(anyString(), any());
verify(rsp).add(eq("report"), any(NamedList.class));
}
/** Check that when the core name is missing we get an exception. */
@Test(expected = SolrException.class)
/** Check that when the core name is missing we get a report for every core. */
@Test
public void handleCustomActionTXReportMissingCoreName()
{
when(params.get(CoreAdminParams.ACTION)).thenReturn(TXREPORT);
when(params.get(CoreAdminParams.CORE)).thenReturn(null);
alfrescoCoreAdminHandler.handleCustomAction(req, rsp);
// Check that a report was generated (don't look at the contents of the report though).
verify(rsp).add(eq("report"), any(NamedList.class));
}
/** Check that when an unknown action is provided we don't generate a report. */
@@ -368,7 +355,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 +363,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 +387,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 +415,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);
}