Search-1966: cmis tests amended to wait for indexing to allow slave to sync with master

This commit is contained in:
mbhave
2020-01-23 17:32:00 +00:00
parent 35ad178466
commit 0d7f979d5f
9 changed files with 82 additions and 99 deletions
@@ -55,7 +55,7 @@ import org.testng.annotations.BeforeSuite;
public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringContextTests
{
/** The number of retries that a query will be tried before giving up. */
private static final int SEARCH_MAX_ATTEMPTS = 6;
protected static final int SEARCH_MAX_ATTEMPTS = 6;
private static final Logger LOGGER = LogFactory.getLogger();
@@ -61,7 +61,7 @@ public abstract class AbstractCmisE2ETest extends AbstractE2EFunctionalTest
protected boolean waitForIndexing(String query, long expectedCountResults)
{
for (int searchCount = 1; searchCount <= 3; searchCount++)
for (int searchCount = 1; searchCount <= SEARCH_MAX_ATTEMPTS; searchCount++)
{
try
@@ -71,7 +71,7 @@ public abstract class AbstractCmisE2ETest extends AbstractE2EFunctionalTest
}
catch (AssertionError ae)
{
LOGGER.debug(ae.toString());
LOGGER.info(String.format("WaitForIndexing in Progress: %s", ae.toString()));
}
@@ -7,6 +7,7 @@ import org.alfresco.utility.data.provider.XMLTestDataProvider;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.QueryModel;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -135,6 +136,7 @@ public class SolrSearchByAspectTests extends AbstractCmisE2ETest
.replace("NODE_REF[f1]", tasFolder1.getNodeRef())
.replace("NODE_REF[s1]", siteDoclibNodeRef);
cmisApi.authenticateUser(testUser).withQuery(currentQuery).assertResultsCount().equals(query.getResults());
cmisApi.authenticateUser(testUser);
Assert.assertTrue(waitForIndexing(currentQuery, query.getResults()), String.format("Result count not as expected for query: %s", currentQuery));
}
}
@@ -7,6 +7,7 @@ import org.alfresco.utility.data.provider.XMLTestDataProvider;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.QueryModel;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -87,7 +88,7 @@ public class SolrSearchByIdTests extends AbstractCmisE2ETest
@Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getQueriesData")
@XMLDataConfig(file = "src/test/resources/testdata/search-by-id.xml")
public void executeSearchByAspect(QueryModel query) throws Exception
public void executeSearchById(QueryModel query) throws Exception
{
String currentQuery = query.getValue()
.replace("NODE_REF[siteId]", siteDoclibNodeRef)
@@ -96,6 +97,7 @@ public class SolrSearchByIdTests extends AbstractCmisE2ETest
.replace("NODE_REF[f1]", tasFolder1.getNodeRef())
.replace("NODE_REF[f1-1]", tasSubFolder1.getNodeRef());
cmisApi.authenticateUser(testUser).withQuery(currentQuery).assertResultsCount().equals(query.getResults());
cmisApi.authenticateUser(testUser);
Assert.assertTrue(waitForIndexing(currentQuery, query.getResults()), String.format("Result count not as expected for query: %s", currentQuery));
}
}
@@ -7,6 +7,7 @@ import org.alfresco.utility.data.provider.XMLTestDataProvider;
import org.alfresco.utility.model.QueryModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -51,6 +52,8 @@ public class SolrSearchByPathTests extends AbstractCmisE2ETest
@XMLDataConfig(file = "src/test/resources/testdata/search-by-path.xml")
public void executeSearchByPathQueries(QueryModel query)
{
cmisApi.withQuery(query.getValue()).assertResultsCount().equals(query.getResults());
cmisApi.authenticateUser(testUser);
Assert.assertTrue(waitForIndexing(query.getValue(), query.getResults()), String.format("Result count not as expected for query: %s", query.getValue()));
}
}
@@ -10,6 +10,7 @@ import org.alfresco.utility.data.provider.XMLTestDataProvider;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.QueryModel;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -104,7 +105,8 @@ public class SolrSearchByPropertyTests extends AbstractCmisE2ETest
.addProperty("tas:IntPropertyC", 2223));
// wait for solr index
Utility.waitToLoopTime(getSolrWaitTimeInSeconds());
cmisApi.authenticateUser(testUser);
waitForIndexing("SELECT * FROM tas:document where cmis:name = 'testc3.txt'", 1);
}
@Test
@@ -7,6 +7,7 @@ import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.QueryModel;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -55,6 +56,7 @@ public class SolrSearchInFolderTests extends AbstractCmisE2ETest
public void executeCMISQuery(QueryModel query) throws Exception
{
String currentQuery = String.format(query.getValue(), parentFolder.getNodeRef());
cmisApi.withQuery(currentQuery).assertResultsCount().equals(query.getResults());
cmisApi.authenticateUser(testUser);
Assert.assertTrue(waitForIndexing(currentQuery, query.getResults()), String.format("Result count not as expected for query: %s", currentQuery));
}
}
@@ -7,6 +7,7 @@ import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.QueryModel;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -59,7 +60,7 @@ public class SolrSearchInTreeTests extends AbstractCmisE2ETest
public void executeCMISQuery(QueryModel query) throws Exception
{
String currentQuery = String.format(query.getValue(), parentFolder.getNodeRef());
cmisApi.withQuery(currentQuery)
.assertResultsCount().equals(query.getResults());
cmisApi.authenticateUser(testUser);
Assert.assertTrue(waitForIndexing(currentQuery, query.getResults()), String.format("Result count not as expected for query: %s", currentQuery));
}
}
@@ -9,6 +9,7 @@ import org.alfresco.utility.data.provider.XMLTestDataProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
@@ -54,8 +55,8 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest
this.testData = testData;
this.testData.createUsers(dataUser);
this.testData.createSitesStructure(dataSite, dataContent, dataUser);
cmisApi.authenticateUser(dataUser.getCurrentUser());
testUser = dataUser.getCurrentUser();
cmisApi.authenticateUser(testUser);
}
/**
@@ -70,68 +71,50 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch') "
+ "ORDER BY orderCriteria";
if (waitForIndexing(query, 3))
{
cmisApi
.withQuery(query)
.assertColumnIsOrdered().isOrderedAsc("orderCriteria");
}
else
{
throw new AssertionError("Wait for indexing has failed!");
}
Assert.assertTrue(waitForIndexing(query, 3), String.format("Result count not as expected for query: %s", query));
cmisApi.withQuery(query).assertColumnIsOrdered().isOrderedAsc("orderCriteria");
}
/**
* Verify that results are inverse ordered
* @throws Exception
*/
@Test(dependsOnMethods = "prepareDataForScoreSearch")
/**
* Verify that results are inverse ordered
*
* @throws Exception
*/
@Test(dependsOnMethods = "prepareDataForScoreSearch")
public void scoreQueryOrderedDesc() throws Exception
{
String query = "SELECT cmis:objectId, SCORE() AS orderCriteria "
String query = "SELECT cmis:objectId, SCORE() AS orderCriteria "
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch') "
+ "ORDER BY orderCriteria DESC";
if (waitForIndexing(query, 3))
{
cmisApi
.withQuery(query).assertColumnIsOrdered().isOrderedDesc("orderCriteria");
}
else
{
throw new AssertionError("Wait for indexing has failed!");
}
Assert.assertTrue(waitForIndexing(query, 3), String.format("Result count not as expected for query: %s", query));
cmisApi.withQuery(query).assertColumnIsOrdered().isOrderedDesc("orderCriteria");
}
/**
* Verify that all SCORE results are between 0 and 1
* @throws Exception
*/
@Test(groups = { TestGroup.ACS_62n }, dependsOnMethods = "prepareDataForScoreSearch")
/**
* Verify that all SCORE results are between 0 and 1
*
* @throws Exception
*/
@Test(groups = { TestGroup.ACS_62n }, dependsOnMethods = "prepareDataForScoreSearch")
public void scoreQueryInRange() throws Exception
{
String query = "SELECT cmis:objectId, SCORE() "
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch')";
if (waitForIndexing(query, 3))
{
cmisApi
.withQuery(query)
.assertColumnValuesRange().isReturningValuesInRange("SEARCH_SCORE", BigDecimal.ZERO, BigDecimal.ONE);
}
else
{
throw new AssertionError("Wait for indexing has failed!");
}
String query = "SELECT cmis:objectId, SCORE() "
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch')";
Assert.assertTrue(waitForIndexing(query, 3), String.format("Result count not as expected for query: %s", query));
cmisApi.withQuery(query).assertColumnValuesRange().isReturningValuesInRange("SEARCH_SCORE", BigDecimal.ZERO, BigDecimal.ONE);
}
/**
@@ -143,45 +126,33 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest
{
String query = "SELECT cmis:objectId, SCORE() AS orderCriteria "
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch')";
if (waitForIndexing(query, 3))
{
cmisApi
.withQuery(query)
.assertColumnValuesRange().isReturningValuesInRange("orderCriteria", BigDecimal.ZERO, BigDecimal.ONE);
}
else
{
throw new AssertionError("Wait for indexing has failed!");
}
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch')";
Assert.assertTrue(waitForIndexing(query, 3), String.format("Result count not as expected for query: %s", query));
cmisApi.withQuery(query).assertColumnValuesRange().isReturningValuesInRange("orderCriteria", BigDecimal.ZERO, BigDecimal.ONE);
}
/**
* Verify that SCORE is valid name for an alias
* Currently only supported with double quotes
* @throws Exception
*/
@Test(dependsOnMethods = "prepareDataForScoreSearch")
/**
* Verify that SCORE is valid name for an alias
* Currently only supported with double quotes
*
* @throws Exception
*/
@Test(dependsOnMethods = "prepareDataForScoreSearch")
public void scoreQueryScoreAsAlias() throws Exception
{
String query = "SELECT cmis:objectId, SCORE() AS \"score\" "
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch')";
if (waitForIndexing(query, 3))
{
cmisApi
.withQuery(query).assertResultsCount().equals(3);
}
else
{
throw new AssertionError("Wait for indexing has failed!");
}
String query = "SELECT cmis:objectId, SCORE() AS \"score\" "
+ "FROM cmis:document "
+ "WHERE CONTAINS('Quidditch')";
Assert.assertTrue(waitForIndexing(query, 3), String.format("Result count not as expected for query: %s", query));
cmisApi.withQuery(query).assertResultsCount().equals(3);
}
}