Search-2142: Fixed the solr api tests to work based on the Sharding Method

This commit is contained in:
mbhave
2020-03-31 08:21:26 +01:00
parent 58aee193ef
commit 1cc0f18579
7 changed files with 81 additions and 55 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
<name>Search Analytics E2E Tests</name>
<description>Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share</description>
<properties>
<tas.rest.api.version>1.35</tas.rest.api.version>
<tas.rest.api.version>1.36</tas.rest.api.version>
<tas.cmis.api.version>1.13</tas.cmis.api.version>
<tas.utility.version>3.0.20</tas.utility.version>
<rm.version>3.3.0.1</rm.version>
@@ -27,14 +27,12 @@ public class TestGroup
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 CONFIG_MASTER_SLAVE = "CONFIG_Master_Slave"; // Alfresco Search Services using master slave configurations
public static final String CONFIG_MASTER ="CONFIG_Master"; // Alfresco search services using master/stand alone mode
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 CONFIG_SHARDING ="CONFIG_Sharding"; // Alfresco search services using sharded environment
public static final String CONFIG_SHARDING_EXPLICIT ="CONFIG_SHARDING_EXPLICIT"; // Alfresco search services using sharded environment and explicit routing
public static final String CONFIG_SHARDING_DB_ID_RANGE = "CONFIG_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
@@ -21,10 +21,14 @@ import org.alfresco.dataprep.ContentService;
import org.alfresco.dataprep.SiteService.Visibility;
import org.alfresco.rest.core.RestProperties;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
import org.alfresco.rest.model.RestRequestSpellcheckModel;
import org.alfresco.rest.search.Pagination;
import org.alfresco.rest.search.RestRequestHighlightModel;
import org.alfresco.rest.search.RestRequestQueryModel;
import org.alfresco.rest.search.RestShardInfoModel;
import org.alfresco.rest.search.RestShardInfoModelCollection;
import org.alfresco.rest.search.RestShardModel;
import org.alfresco.rest.search.SearchRequest;
import org.alfresco.rest.search.SearchResponse;
import org.alfresco.utility.LogFactory;
@@ -49,6 +53,8 @@ import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import com.fasterxml.jackson.core.JsonProcessingException;
/**
* @author meenal bhave
*/
@@ -93,6 +99,9 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
protected SiteModel testSite, testSite2;
protected static String unique_searchString;
protected static String shardingMethod = "DB_ID";
protected int shardCount = 0;
protected static final String SEARCH_LANGUAGE_CMIS = "cmis";
@@ -595,4 +604,39 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
response.getContext().getSpellCheck().assertThat().field("suggestions").contains(spellCheckSuggestion);
}
}
/**
* Method returns the sharding method used for the core by the 1st shard instance registered with ACS
* @return String sharding Method
* @throws JsonProcessingException
* @throws EmptyRestModelCollectionException
*/
public String getShardMethod() throws JsonProcessingException, EmptyRestModelCollectionException
{
RestShardInfoModelCollection info = getShardInfo();
shardingMethod = info.getEntryByIndex(0).getShardMethod();
return shardingMethod;
}
/**
* Method returns the shardCount for the 1st core (of the shard instance) that registers with ACS
* @return shard Count
* @throws JsonProcessingException
* @throws EmptyRestModelCollectionException
*/
public int getShardCount() throws JsonProcessingException, EmptyRestModelCollectionException
{
RestShardInfoModelCollection info = getShardInfo();
shardCount = info.getEntryByIndex(0).getNumberOfShards();
return shardCount;
}
public RestShardInfoModelCollection getShardInfo() throws JsonProcessingException, EmptyRestModelCollectionException
{
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo();
return info;
}
}
@@ -20,7 +20,7 @@ public class ExplicitRoutingTest extends AbstractE2EFunctionalTest {
* Checks indexing still works after sharding model used for explicit routing has been disabled
* @throws Exception
*/
@Test(priority = 1, groups = {TestGroup.NOT_BAMBOO, TestGroup.EXPLICIT_SHARDING, TestGroup.ACS_62n})
@Test(priority = 1, groups = {TestGroup.NOT_BAMBOO, TestGroup.CONFIG_SHARDING_EXPLICIT, TestGroup.ACS_62n})
public void testIndexingStillWorkingAfterShardModelIsDeactivated() throws Exception
{
@@ -44,7 +44,7 @@ import org.springframework.http.HttpStatus;
public class ShardInfoTest extends AbstractE2EFunctionalTest
{
/* The test that will be excluded when running master slave setup, excluding the ASS_MASTER test group. */
@Test(groups = { TestGroup.ACS_60n, TestGroup.ASS_MASTER })
@Test(groups = { TestGroup.ACS_60n, TestGroup.CONFIG_MASTER })
public void getShardInfoWithAdminAuthority() throws JsonProcessingException
{
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI()
@@ -89,7 +89,7 @@ public class ShardInfoTest extends AbstractE2EFunctionalTest
}
/* The test that will be run when in master slave setup by including the ASS_MASTER_SLAVE test group. */
@Test(groups = {TestGroup.ACS_60n, TestGroup.ASS_MASTER_SLAVE })
@Test(groups = {TestGroup.ACS_60n, TestGroup.CONFIG_MASTER_SLAVE })
public void getShardInfoWithAdminAuthorityMasterSlaveConfig() throws JsonProcessingException
{
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI()
@@ -139,7 +139,7 @@ public class ShardInfoTest extends AbstractE2EFunctionalTest
* @throws JsonProcessingException
*/
@Test(groups = { TestGroup.ACS_60n, TestGroup.SHARDING })
@Test(groups = { TestGroup.ACS_60n, TestGroup.CONFIG_SHARDING })
public void getShardInfoWith2OrMoreShards() throws JsonProcessingException
{
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo();
@@ -187,7 +187,7 @@ public class CascadingIntegrationTest extends AbstractE2EFunctionalTest
* Check that, after parent renaming, both the children are searchable in the new path
* (computed accordingly with the new parent folder name)
*/
@Test(priority = 3, groups = {TestGroup.NOT_BAMBOO, TestGroup.EXPLICIT_SHARDING })
@Test(priority = 3, groups = {TestGroup.NOT_BAMBOO, TestGroup.CONFIG_SHARDING_EXPLICIT })
public void testChildrenPathOnParentRenamedWithChildrenInDifferentShards() throws Exception
{
@@ -31,6 +31,7 @@ import org.testng.annotations.Test;
* http://<server>:<port>/solr/admin/cores?action=(actionName)
*
* @author aborroy
* @author mbhave
*
*/
@Configuration
@@ -465,7 +466,7 @@ public class SolrE2eAdminTest extends AbstractE2EFunctionalTest
* This test verifies expected result when using another deployment
* @throws Exception
*/
@Test(priority = 20)
@Test(priority = 20, groups = {TestGroup.CONFIG_SHARDING})
public void testRangeCheck() throws Exception
{
String coreName = "alfresco";
@@ -475,24 +476,17 @@ public class SolrE2eAdminTest extends AbstractE2EFunctionalTest
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,");
// RangeCheck action only applies to DB_ID_RANGE Sharding method, so expect error in other sharding methods and success for DB_ID_RANGE
if ("DB_ID_RANGE".equalsIgnoreCase(getShardMethod()))
{
// This assertion replicates: testRangeCheckSharding, priority = 21, hence deleting that test as duplicate
Assert.assertNotEquals(expand, Integer.valueOf(-1), "Expansion is not successful when not using Shard DB_ID_RANGE method,");
}
else
{
Assert.assertEquals(expand, Integer.valueOf(-1), "Expansion should not have been allowed when not using Shard DB_ID_RANGE method,");
}
}
/**
@@ -500,7 +494,7 @@ public class SolrE2eAdminTest extends AbstractE2EFunctionalTest
* This test verifies expected result when using another deployment
* @throws Exception
*/
@Test(priority = 22)
@Test(priority = 22, groups = { TestGroup.CONFIG_SHARDING})
public void testExpand() throws Exception
{
String coreName = "alfresco";
@@ -509,29 +503,19 @@ public class SolrE2eAdminTest extends AbstractE2EFunctionalTest
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,");
// Expand action only applies to DB_ID_RANGE Sharding method, so expect error in other sharding methods and success for DB_ID_RANGE
if ("DB_ID_RANGE".equalsIgnoreCase(getShardMethod()))
{
// This assertion replicates: testExpandSharding, priority = 23, hence deleting that test as duplicate
Assert.assertNotEquals(expand, Integer.valueOf(-1), "Expansion is not successful when not using Shard DB_ID_RANGE method,");
}
else
{
Assert.assertEquals(expand, Integer.valueOf(-1), "Expansion should not have been allowed when not using Shard DB_ID_RANGE method,");
}
}
/**