Merge branch 'feature/RM-6821_IntermittentSearchRestApiTests' into 'master'

RM-6821 Try to fix intermittent enterprise search rest api failures by increasing the search time with 30 sec

See merge request records-management/records-management!1154
This commit is contained in:
Claudia Agache
2019-04-22 08:06:48 +01:00
6 changed files with 36 additions and 28 deletions

View File

@@ -46,6 +46,12 @@
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.26</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.alfresco.tas</groupId> <groupId>org.alfresco.tas</groupId>
<artifactId>restapi-test</artifactId> <artifactId>restapi-test</artifactId>

View File

@@ -241,7 +241,6 @@ public class SearchAPI extends BaseAPI
* Helper method to extract list of names from search result. * Helper method to extract list of names from search result.
* *
* @param searchResult * @param searchResult
* @param getProperties
* @return * @return
*/ */
private List<String> getItemNames(JSONObject searchResult) private List<String> getItemNames(JSONObject searchResult)
@@ -253,7 +252,8 @@ public class SearchAPI extends BaseAPI
* Helper method to extract list of property values from search result for the given nodeRef. * Helper method to extract list of property values from search result for the given nodeRef.
* *
* @param searchResult * @param searchResult
* @param getProperties * @param nodeRef
* @param propertyName
* @return * @return
*/ */
private String getItemProperty(JSONObject searchResult, String nodeRef, String propertyName) private String getItemProperty(JSONObject searchResult, String nodeRef, String propertyName)

View File

@@ -141,7 +141,7 @@ public class BaseRMRestTest extends RestTest
/** Valid root containers where electronic and non-electronic records can be created */ /** Valid root containers where electronic and non-electronic records can be created */
@DataProvider(name = "validRootContainers") @DataProvider(name = "validRootContainers")
public String[][] getValidRootContainers() throws Exception public Object[][] getValidRootContainers() throws Exception
{ {
return new String[][] return new String[][]
{ {
@@ -647,27 +647,25 @@ public class BaseRMRestTest extends RestTest
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
// wait for solr indexing // wait for solr indexing
int counter = 0; int counter = 0;
int waitInMilliSeconds = 6000; int waitInMilliSeconds = 7000;
while (counter < 3) while (counter < 4)
{ {
synchronized (this) synchronized (this)
{ {
try try
{ {
this.wait(waitInMilliSeconds); this.wait(waitInMilliSeconds);
} catch (InterruptedException e) }
catch (InterruptedException e)
{ {
} }
} }
List<SearchNodeModel> searchResults = getRestAPIFactory().getRmRestWrapper().withSearchAPI().search(query) List<SearchNodeModel> searchResults = getRestAPIFactory().getRmRestWrapper().withSearchAPI().search(query)
.getEntries(); .getEntries();
if ((searchResults != null && !searchResults.isEmpty())) if (searchResults != null && !searchResults.isEmpty())
{ {
searchResults.forEach(childNode -> searchResults.forEach(childNode -> names.add(childNode.onModel().getName()));
{
names.add(childNode.onModel().getName());
});
break; break;
} }
else else
@@ -675,7 +673,7 @@ public class BaseRMRestTest extends RestTest
counter++; counter++;
} }
// double wait time to not overdo solr search // double wait time to not overdo solr search
waitInMilliSeconds = (waitInMilliSeconds * 2); waitInMilliSeconds = waitInMilliSeconds * 2;
} }
return names; return names;
} }
@@ -697,8 +695,8 @@ public class BaseRMRestTest extends RestTest
List<String> results = new ArrayList<>(); List<String> results = new ArrayList<>();
// wait for solr indexing // wait for solr indexing
int counter = 0; int counter = 0;
int waitInMilliSeconds = 6000; int waitInMilliSeconds = 7000;
while (counter < 3) while (counter < 4)
{ {
synchronized (this) synchronized (this)
{ {
@@ -722,7 +720,7 @@ public class BaseRMRestTest extends RestTest
counter++; counter++;
} }
// double wait time to not overdo solr search // double wait time to not overdo solr search
waitInMilliSeconds = (waitInMilliSeconds * 2); waitInMilliSeconds = waitInMilliSeconds * 2;
} }
return results; return results;
} }
@@ -746,8 +744,8 @@ public class BaseRMRestTest extends RestTest
String result = ""; String result = "";
// wait for solr indexing // wait for solr indexing
int counter = 0; int counter = 0;
int waitInMilliSeconds = 6000; int waitInMilliSeconds = 5000;
while (counter < 3) while (counter < 4)
{ {
synchronized (this) synchronized (this)
{ {

View File

@@ -71,7 +71,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
/** Invalid parent containers where electronic records can't be created */ /** Invalid parent containers where electronic records can't be created */
@DataProvider(name = "invalidParentContainers") @DataProvider(name = "invalidParentContainers")
public Object[][] invalidParentContainers() throws Exception public Object[][] invalidParentContainers()
{ {
return new String[][] return new String[][]
{ {
@@ -99,7 +99,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
dataProvider = "invalidParentContainers", dataProvider = "invalidParentContainers",
description = "Electronic records can't be created in invalid parent containers" description = "Electronic records can't be created in invalid parent containers"
) )
public void cantCreateElectronicRecordsInInvalidContainers(String container) throws Exception public void cantCreateElectronicRecordsInInvalidContainers(String container)
{ {
// Create an electronic record in the given container, this should throw an IllegalArgumentException // Create an electronic record in the given container, this should throw an IllegalArgumentException
getRestAPIFactory().getRecordFolderAPI().createRecord(createElectronicRecordModel(), container, getFile(IMAGE_FILE)); getRestAPIFactory().getRecordFolderAPI().createRecord(createElectronicRecordModel(), container, getFile(IMAGE_FILE));
@@ -158,7 +158,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
* Then nothing happens * Then nothing happens
* And an error is reported * And an error is reported
* </pre> * </pre>
* @param folderid The folder, which the record will be created in * @param folderId The folder, which the record will be created in
* @param type The type of the record folder, which the record will be created in * @param type The type of the record folder, which the record will be created in
* @throws Exception if record can't be created * @throws Exception if record can't be created
*/ */
@@ -405,7 +405,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
*/ */
@Test(description = "Electronic records can be created in record folder with duplicate name") @Test(description = "Electronic records can be created in record folder with duplicate name")
@Bug(id ="RM-5116, RM-5012") @Bug(id ="RM-5116, RM-5012")
public void canCreateElectronicRecordsWithDuplicateName() throws Exception public void canCreateElectronicRecordsWithDuplicateName()
{ {
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();

View File

@@ -29,8 +29,7 @@ package org.alfresco.rest.rm.community.unfiledcontainers;
import static java.time.LocalDateTime.now; import static java.time.LocalDateTime.now;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
@@ -67,7 +66,6 @@ import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
import org.alfresco.utility.report.Bug; import org.alfresco.utility.report.Bug;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -464,9 +462,8 @@ public class UnfiledContainerTests extends BaseRMRestTest
assertEquals(child.getName(), recordName + " (" + customIdentifier + ")"); assertEquals(child.getName(), recordName + " (" + customIdentifier + ")");
} }
@AfterMethod
@AfterClass (alwaysRun = true) @AfterClass (alwaysRun = true)
public void tearDown() throws Exception public void tearDown()
{ {
UnfiledContainerChildCollection listedChildren = getRestAPIFactory().getUnfiledContainersAPI() UnfiledContainerChildCollection listedChildren = getRestAPIFactory().getUnfiledContainersAPI()
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS); .getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS);

View File

@@ -0,0 +1,7 @@
log4j.rootLogger=info, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
log4j.logger.com.example=debug