mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'feature/SEARCH-1681_ShardingOnTheCITests' into 'master'
Feature/search 1681 sharding on the ci tests See merge request search_discovery/insightengine!362
This commit is contained in:
@@ -30,6 +30,9 @@ public class TestGroup
|
||||
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 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
|
||||
|
||||
|
||||
+1
@@ -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)
|
||||
|
||||
+80
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user