mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Search 1438: Improved use of waitForIndexing methods
This commit is contained in:
@@ -97,7 +97,7 @@ public class AbstractSearchTest extends RestTest
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4);
|
||||
|
||||
waitForIndexing(file4.getName(), true);
|
||||
waitForMetadataIndexing(file4.getName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,21 +183,62 @@ public class AbstractSearchTest extends RestTest
|
||||
/**
|
||||
* Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results
|
||||
*
|
||||
* @param userQuery: string to search for, unique search string will guarantee accurate results
|
||||
* @param userQuery: search query, this can include the fieldname, unique search string will guarantee accurate results
|
||||
* @param expectedInResults, true if entry is expected in the results set
|
||||
* @return true (indexing is finished) if search returns appropriate results
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean waitForIndexing(String userQuery, boolean expectedInResults) throws Exception
|
||||
{
|
||||
// Use the search query as is: fieldname(s) may or may not be specified within the userQuery
|
||||
return waitForIndexing(null, userQuery, expectedInResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* waitForIndexing method that matches / waits for filename, metadata to be indexed.
|
||||
* @param userQuery
|
||||
* @param expectedInResults
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean waitForMetadataIndexing(String userQuery, boolean expectedInResults) throws Exception
|
||||
{
|
||||
return waitForIndexing("name", userQuery, expectedInResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* waitForIndexing method that matches / waits for content to be indexed, this can take longer than metadata indexing.
|
||||
* Since Metadata is indexed first, use this method where tests, queries need content to be indexed too.
|
||||
* @param userQuery
|
||||
* @param expectedInResults
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean waitForContentIndexing(String userQuery, boolean expectedInResults) throws Exception
|
||||
{
|
||||
return waitForIndexing("cm:content", userQuery, expectedInResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for Solr to finish indexing: Indexing has caught up = true if search returns appropriate results
|
||||
*
|
||||
* @param fieldName: specific field to search for, e.g. name. When specified, the query will become: name:'userQuery'
|
||||
* @param userQuery: search string, unique search string will guarantee accurate results
|
||||
* @param expectedInResults, true if entry is expected in the results set
|
||||
* @return true (indexing is finished) if search returns appropriate results
|
||||
* @throws Exception
|
||||
*/
|
||||
private boolean waitForIndexing(String fieldName, String userQuery, boolean expectedInResults) throws Exception
|
||||
{
|
||||
boolean found = false;
|
||||
boolean resultAsExpected = false;
|
||||
String expectedStatusCode = HttpStatus.OK.toString();
|
||||
String query = (fieldName == null)? userQuery: String.format("%s:'%s'", fieldName, userQuery);
|
||||
|
||||
// Repeat search until the query results are as expected or Search Retry count is hit
|
||||
for (int searchCount = 1; searchCount <= 3; searchCount++)
|
||||
{
|
||||
SearchRequest searchRequest = createQuery(userQuery);
|
||||
SearchRequest searchRequest = createQuery(query);
|
||||
SearchResponse response = query(searchRequest);
|
||||
|
||||
if (restClient.getStatusCode().matches(expectedStatusCode))
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -35,6 +36,11 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class FacetIntervalSearchTest extends AbstractSearchTest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION,
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.testng.Assert;
|
||||
import org.testng.TestException;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -86,7 +87,13 @@ public class FacetedSearchTest extends AbstractSearchTest
|
||||
* }}
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.SEARCH,
|
||||
TestGroup.ASS_1 }, executionType = ExecutionType.REGRESSION, description = "Checks facet queries for the Search api")
|
||||
|
||||
@@ -61,7 +61,8 @@ public class FingerPrintTest extends AbstractSearchTest
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file3);
|
||||
dataContent.usingUser(userModel).usingSite(siteModel).usingResource(folder).createContent(file4);
|
||||
|
||||
waitForIndexing(file4.getName(), true);
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
waitForIndexing("FINGERPRINT:" + file3.getNodeRefWithoutVersion(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,11 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class PivotFacetedSearchTest extends AbstractSearchTest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -36,6 +37,8 @@ public class SearchHighLightTest extends AbstractSearchTest
|
||||
@Bug(id = "TAS-3220")
|
||||
public void searchWithHighLight() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file2.getContent(), true);
|
||||
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
queryReq.setQuery("cm:content:cars");
|
||||
queryReq.setUserQuery("cars");
|
||||
|
||||
@@ -67,6 +67,8 @@ public class SearchSpellCheckTest extends AbstractSearchTest
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API, TestGroup.ACS_60n}, priority=1)
|
||||
public void testSearchMissSpelled() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
|
||||
// Name
|
||||
SearchRequest searchReq = new SearchRequest();
|
||||
RestRequestQueryModel queryReq = new RestRequestQueryModel();
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -50,6 +51,12 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class SearchTest extends AbstractSearchTest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file4.getContent(), true);
|
||||
}
|
||||
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API})
|
||||
public void searchOnIndexedData() throws Exception
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,11 @@ import org.testng.annotations.Test;
|
||||
*/
|
||||
public class StatsSearchTest extends AbstractSearchTest
|
||||
{
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupEnvironment() throws Exception
|
||||
{
|
||||
waitForContentIndexing(file2.getContent(), true);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 })
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.SEARCH, TestGroup.ASS_1 },
|
||||
|
||||
Reference in New Issue
Block a user