From 74921e1c9e5a546cd775603b90b0cff8c2c1e51f Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Wed, 20 Feb 2019 10:49:51 +0000 Subject: [PATCH 1/7] Search-1493 refactoring, new waitForContent and waitForIndexing methods, alignment with TAS Rest API project --- .../search/AbstractSearchServiceE2E.java | 157 +++++++++++++++--- .../CascadingTrackerIntegrationTest.java | 144 ++++++++-------- 2 files changed, 205 insertions(+), 96 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java index 2c9399c0c..8035b775b 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java @@ -1,7 +1,7 @@ package org.alfresco.service.search; /* - * Copyright 2018 Alfresco Software, Ltd. All rights reserved. + * Copyright 2019 Alfresco Software, Ltd. All rights reserved. * License rights for this program may be obtained from Alfresco Software, Ltd. * pursuant to a written agreement and any use of this program without such an * agreement is prohibited. @@ -13,6 +13,7 @@ import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.search.RestRequestQueryModel; +import org.alfresco.rest.search.SearchNodeModel; import org.alfresco.rest.search.SearchRequest; import org.alfresco.rest.search.SearchResponse; import org.alfresco.utility.LogFactory; @@ -39,6 +40,8 @@ import org.testng.annotations.BeforeSuite; import lombok.Getter; import static lombok.AccessLevel.PROTECTED; +import java.util.List; + /** * @author meenal bhave */ @@ -102,8 +105,10 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte } @BeforeClass(alwaysRun = true) - public void beforeClass() throws Exception - { + public void dataPreparation() throws Exception + { + serverHealth.assertServerIsOnline(); + adminUserModel = dataUser.getAdminUser(); testUser = dataUser.createRandomTestUser("UserSearch"); @@ -223,42 +228,150 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte return customModel; } + protected SearchRequest createQuery(String term) + { + SearchRequest query = new SearchRequest(); + RestRequestQueryModel queryReq = new RestRequestQueryModel(); + queryReq.setQuery(term); + query.setQuery(queryReq); + return query; + } + + /** + * + * Helper method which create an http post request to Search API end point. + * Executes the given search request without throwing checked exceptions (a {@link RuntimeException} will be thrown in case). + * @param query the search request. + * @return {@link SearchResponse} response. + * + */ + protected SearchResponse query(SearchRequest query) throws Exception + { + try + { + return restClient.authenticateUser(testUser).withSearchAPI().search(query); + } + catch (final Exception exception) + { + throw new RuntimeException(exception); + } + } + + /** + * Wait for Solr to finish indexing and search to return appropriate results + * + * @param userQuery: Search Query + * @param contentName that's expected to be included / excluded from the results + * @param expectedInResults + * @return true if search returns expected results, i.e. is given content is found or excluded from the results + * @throws Exception + */ + public boolean waitForContent(String userQuery, String contentName, boolean expectedInResults) throws Exception + { + boolean resultAsExpected = false; + boolean found = !expectedInResults; + String expectedStatusCode = HttpStatus.OK.toString(); + + // 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); + SearchResponse response = query(searchRequest); + + if (restClient.getStatusCode().matches(expectedStatusCode)) + { + List entries = response.getEntries(); + if (!entries.isEmpty()) + { + for (SearchNodeModel entry : entries) + { + found = (contentName.equalsIgnoreCase(entry.getModel().getName())); + } + // Loop again if result is not as expected: To cater for solr lag: eventual consistency + resultAsExpected = (expectedInResults == found); + if (resultAsExpected) + { + break; + } + else + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + } + } + } + else + { + throw new RuntimeException("API returned status code:" + restClient.getStatusCode() + " Expected: " + expectedStatusCode); + } + } + + return resultAsExpected; + } + /** * 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 { - boolean found = false; + // 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 resultAsExpected = false; String expectedStatusCode = HttpStatus.OK.toString(); - Integer retryCount = 3; - - SearchRequest query = new SearchRequest(); - RestRequestQueryModel queryReq = new RestRequestQueryModel(); - queryReq.setQuery(userQuery); - query.setQuery(queryReq); + 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 <= retryCount; searchCount++) + for (int searchCount = 1; searchCount <= 3; searchCount++) { - // Using adminUser just to confirm that the content is indexed - SearchResponse response = restClient.authenticateUser(dataUser.getAdminUser()).withSearchAPI().search(query); + SearchRequest searchRequest = createQuery(query); + SearchResponse response = query(searchRequest); if (restClient.getStatusCode().matches(expectedStatusCode)) { - if (response.getEntries().size() >= 1) - { - found = true; - } - else - { - found = false; - } + boolean found = !response.getEntries().isEmpty(); // Loop again if result is not as expected: To cater for solr lag: eventual consistency resultAsExpected = (expectedInResults == found); diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java index 53e0b4b58..be7a197a6 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Alfresco Software, Ltd. All rights reserved. + * Copyright 2019 Alfresco Software, Ltd. All rights reserved. * License rights for this program may be obtained from Alfresco Software, Ltd. * pursuant to a written agreement and any use of this program without such an * agreement is prohibited. @@ -10,119 +10,115 @@ import java.util.HashMap; import java.util.Map; import org.alfresco.service.search.AbstractSearchServiceE2E; -import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataContent; -import org.alfresco.utility.data.DataSite; import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; import org.apache.chemistry.opencmis.commons.PropertyIds; import org.apache.chemistry.opencmis.commons.enums.VersioningState; import org.springframework.beans.factory.annotation.Autowired; import org.testng.Assert; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +/** + * Test class tests cascading updates for a child node when parent node is updated + * + * @author Alessandro Benedetti + * @author Meenal Bhave + */ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E { - @Autowired - protected DataSite dataSite; - @Autowired protected DataContent dataContent; - - private SiteModel testSite; - - private UserModel testUser; - private FolderModel testFolder; - - @BeforeClass(alwaysRun = true) - public void setupEnvironment() throws Exception - { - serverHealth.assertServerIsOnline(); - - testSite = dataSite.createPublicRandomSite(); - testUser = dataUser.createRandomTestUser(); - dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor); - } + private FolderModel parentFolder, grandParentFolder, childFolder; + private FileModel childFile, grandChildFile; - @Test(groups = { TestGroup.ASS_13 }) - public void testCascadingTracking_parentFolderRenaming_shouldReIndexChildren() throws Exception + @Test(priority = 1, groups = { TestGroup.ASS_13 }) + public void testChildrenWhenParentRenamed() throws Exception { - testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); + // Create PArent folder + parentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); + + // Create a file in the parent folder + childFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content"); - FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content"); Map properties = new HashMap<>(); - properties.put(PropertyIds.NAME, customFile.getName()); - - cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder) - .createFile(customFile, properties, VersioningState.MAJOR).assertThat().existsInRepo(); - - waitForIndexing(customFile.getName(), true); - - String parentQuery = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + testFolder.getName() + "\""; - int initialDescendantCount = query(parentQuery).getPagination().getCount(); + properties.put(PropertyIds.NAME, childFile.getName()); + properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); + + cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(parentFolder) + .createFile(childFile, properties, VersioningState.MAJOR).assertThat().existsInRepo(); + // Query to find nodes where Path with original folder name matches + String parentQuery = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + parentFolder.getName() + "\""; + + // Rename parent folder String parentNewName = "parentRenamed"; + parentFolder.setName(parentNewName); + ContentModel parentNewNameModel = new ContentModel(parentNewName); + dataContent.usingUser(testUser).usingResource(parentFolder).renameContent(parentNewNameModel); - this.dataContent.usingUser(testUser).usingResource(testFolder).renameContent(parentNewNameModel); - - testFolder.setName(parentNewName); - waitForIndexing(testFolder.getName(), true); + waitForMetadataIndexing(parentNewName, true); + // Find nodes where Path with new folder name matches String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + parentNewName + "\""; - int descendantCountOfDismissedName = query(parentQuery).getPagination().getCount(); + waitForContent(parentQueryAfterRename, childFile.getName(), true); + + // Query using new parent name int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount(); - - Assert.assertEquals(initialDescendantCount, descendantCountOfNewName); - //Assert.assertThat("New renamed path has not the same descendants as before renaming: " + parentQueryAfterRename,descendantCountOfNewName,is(initialDescendantCount)); - - Assert.assertEquals(descendantCountOfDismissedName, 0); - //Assert.assertThat("Old path still has descendants: " + parentQuery,descendantCountOfDismissedName,is(0)); + Assert.assertEquals(descendantCountOfNewName, 2, "New renamed path has not the same descendants as before renaming: " + parentQueryAfterRename); + + // Query using old parent name + int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount(); + Assert.assertEquals(descendantCountOfOriginalName, 0, "Old path still has descendants: " + parentQuery); } - @Test(groups = { TestGroup.ASS_13 }) - public void testCascadingTracking_granParentFolderRenaming_shouldReIndexChildren() throws Exception + @Test(priority = 2, groups = { TestGroup.ASS_13 }) + public void testChildrenWhenGrandParentRenamed() throws Exception { - testFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); + // Create grand-parent folder + grandParentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); // Create child folder - FolderModel childFolder = dataContent.usingUser(testUser).usingResource(testFolder).createFolder(); + childFolder = dataContent.usingUser(testUser).usingResource(grandParentFolder).createFolder(); - // Create grandchild file - FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content"); + // Create grand-child file + grandChildFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content"); Map properties = new HashMap<>(); - properties.put(PropertyIds.NAME, customFile.getName()); - + properties.put(PropertyIds.NAME, grandChildFile.getName()); + properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); + cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(childFolder) - .createFile(customFile, properties, VersioningState.MAJOR).assertThat().existsInRepo(); - waitForIndexing(customFile.getName(), true); - - String parentQuery = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + testFolder.getName() + "\""; - int initialDescendantCount = query(parentQuery).getPagination().getCount(); + .createFile(grandChildFile, properties, VersioningState.MAJOR).assertThat().existsInRepo(); - // Edit grand parent folder name - String granParentNewName = "granParentRenamed"; - ContentModel granParentNewNameModel = new ContentModel(granParentNewName); - this.dataContent.usingUser(testUser).usingResource(testFolder).renameContent(granParentNewNameModel); - - waitForIndexing(granParentNewName, true); + // Wait for file to be indexed + waitForMetadataIndexing(grandChildFile.getName(), true); - String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + granParentNewName + "\""; - int descendantCountOfDismissedName = query(parentQuery).getPagination().getCount(); + // Query to find nodes where Path with original folder name matches + String parentQuery = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + grandParentFolder.getName() + "\""; + + // Rename grand parent folder + String grandParentNewName = "grandParentRenamed"; + grandParentFolder.setName(grandParentNewName); + + ContentModel granParentNewNameModel = new ContentModel(grandParentNewName); + this.dataContent.usingUser(testUser).usingResource(grandParentFolder).renameContent(granParentNewNameModel); + + // Find nodes where Path with new folder name matches + String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + grandParentNewName + "\""; + waitForContent(parentQueryAfterRename, grandChildFile.getName(), true); + + // Query using new parent name int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount(); + Assert.assertEquals(descendantCountOfNewName, 3, "New renamed path has not the same descendants as before renaming: " + parentQueryAfterRename); - Assert.assertEquals(descendantCountOfNewName, initialDescendantCount); - //Assert.assertThat("New renamed path has not the same descendants as before renaming: " + parentQueryAfterRename,descendantCountOfNewName,is(initialDescendantCount)); - - Assert.assertEquals(descendantCountOfDismissedName, 0); - //Assert.assertThat("Old path still has descendants: " + parentQuery,descendantCountOfDismissedName,is(0)); + // Query using old parent name + int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount(); + Assert.assertEquals(descendantCountOfOriginalName, 0, "Old path still has descendants: " + parentQuery); } } From 21fe2442568a372e96c8b21c4cb9eabe2f59cef0 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Wed, 20 Feb 2019 11:51:51 +0000 Subject: [PATCH 2/7] Search-1439: Added assert for indexing so that it fails with the message Indexing in progress --- .../tracker/CascadingTrackerIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java index be7a197a6..52b52b5b4 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java @@ -66,7 +66,7 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E // Find nodes where Path with new folder name matches String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + parentNewName + "\""; - waitForContent(parentQueryAfterRename, childFile.getName(), true); + Assert.assertEquals(waitForContent(parentQueryAfterRename, childFile.getName(), true), true, "Indexing is still in Progress"); // Query using new parent name int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount(); @@ -110,7 +110,7 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E // Find nodes where Path with new folder name matches String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + grandParentNewName + "\""; - waitForContent(parentQueryAfterRename, grandChildFile.getName(), true); + Assert.assertEquals(waitForContent(parentQueryAfterRename, grandChildFile.getName(), true), true, "Indexing is still in Progress"); // Query using new parent name int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount(); From 49bedadf16db3fe82952aab2f516659e7f33bd2d Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Thu, 21 Feb 2019 14:38:55 +0000 Subject: [PATCH 3/7] Search-1493: Fixed waitForContent method --- .../search/AbstractSearchServiceE2E.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java index 8035b775b..8cb451c3f 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java @@ -287,17 +287,17 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte { found = (contentName.equalsIgnoreCase(entry.getModel().getName())); } - // Loop again if result is not as expected: To cater for solr lag: eventual consistency - resultAsExpected = (expectedInResults == found); - if (resultAsExpected) - { - break; - } - else - { - // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); - } + } + // Loop again if result is not as expected: To cater for solr lag: eventual consistency + resultAsExpected = (expectedInResults == found); + if (resultAsExpected) + { + break; + } + else + { + // Wait for the solr indexing. + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); } } else From 7ea4bc6431b05392d76085c4800f576f0240d25f Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Thu, 21 Feb 2019 14:47:29 +0000 Subject: [PATCH 4/7] Search-1493: tests renamed --- .../tracker/CascadingTrackerIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java index 52b52b5b4..8742034bf 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java @@ -37,7 +37,7 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E private FileModel childFile, grandChildFile; @Test(priority = 1, groups = { TestGroup.ASS_13 }) - public void testChildrenWhenParentRenamed() throws Exception + public void testChildPathWhenParentRenamed() throws Exception { // Create PArent folder parentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); @@ -78,7 +78,7 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E } @Test(priority = 2, groups = { TestGroup.ASS_13 }) - public void testChildrenWhenGrandParentRenamed() throws Exception + public void testGrandChildPathWhenGrandParentRenamed() throws Exception { // Create grand-parent folder grandParentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); From 79298eceaea440e9a26845b250fa2c99166fdcc6 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Thu, 21 Feb 2019 15:19:55 +0000 Subject: [PATCH 5/7] Search-1493: Allowing more time for indexing, upto 6 tries instead of 3, this does not make other tests slower --- .../org/alfresco/service/search/AbstractSearchServiceE2E.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java index 8cb451c3f..32270a00e 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java @@ -273,7 +273,7 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte String expectedStatusCode = HttpStatus.OK.toString(); // Repeat search until the query results are as expected or Search Retry count is hit - for (int searchCount = 1; searchCount <= 3; searchCount++) + for (int searchCount = 1; searchCount <= 5; searchCount++) { SearchRequest searchRequest = createQuery(userQuery); SearchResponse response = query(searchRequest); From d44726978e94fbbcf7565668134eece9dc7a63b8 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Thu, 21 Feb 2019 15:20:10 +0000 Subject: [PATCH 6/7] Search-1493: Allowing more time for indexing, upto 6 tries instead of 3, this does not make other tests slower --- .../org/alfresco/service/search/AbstractSearchServiceE2E.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java index 32270a00e..c022c54aa 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java @@ -273,7 +273,7 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte String expectedStatusCode = HttpStatus.OK.toString(); // Repeat search until the query results are as expected or Search Retry count is hit - for (int searchCount = 1; searchCount <= 5; searchCount++) + for (int searchCount = 1; searchCount <= 6; searchCount++) { SearchRequest searchRequest = createQuery(userQuery); SearchResponse response = query(searchRequest); From dc16790994d2be345ab457aeee2e1f962caacc08 Mon Sep 17 00:00:00 2001 From: "meenal.bhave@alfresco.com" Date: Mon, 25 Feb 2019 09:11:32 +0000 Subject: [PATCH 7/7] Search-1493: Improved error logging on test failure and minor changes to var names and comments --- .../search/AbstractSearchServiceE2E.java | 4 +-- .../CascadingTrackerIntegrationTest.java | 26 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java index c022c54aa..f0279faf8 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/AbstractSearchServiceE2E.java @@ -297,7 +297,7 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte else { // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing. Retry Attempt: " + searchCount); } } else @@ -382,7 +382,7 @@ public abstract class AbstractSearchServiceE2E extends AbstractTestNGSpringConte else { // Wait for the solr indexing. - Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing. Retry Attempt: " + searchCount); } } else diff --git a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java index 8742034bf..59e9b8b78 100644 --- a/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java +++ b/e2e-test/src/test/java/org/alfresco/service/search/e2e/searchservices/tracker/CascadingTrackerIntegrationTest.java @@ -39,7 +39,7 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E @Test(priority = 1, groups = { TestGroup.ASS_13 }) public void testChildPathWhenParentRenamed() throws Exception { - // Create PArent folder + // Create Parent folder parentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); // Create a file in the parent folder @@ -66,13 +66,13 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E // Find nodes where Path with new folder name matches String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + parentNewName + "\""; - Assert.assertEquals(waitForContent(parentQueryAfterRename, childFile.getName(), true), true, "Indexing is still in Progress"); + Boolean indexingInProgress = !waitForContent(parentQueryAfterRename, childFile.getName(), true); - // Query using new parent name + // Query using new parent name: Expect parent folder and child file int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount(); - Assert.assertEquals(descendantCountOfNewName, 2, "New renamed path has not the same descendants as before renaming: " + parentQueryAfterRename); + Assert.assertEquals(descendantCountOfNewName, 2, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress.toString(), parentQueryAfterRename)); - // Query using old parent name + // Query using old parent name: Expect no descendant after rename int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount(); Assert.assertEquals(descendantCountOfOriginalName, 0, "Old path still has descendants: " + parentQuery); } @@ -80,13 +80,13 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E @Test(priority = 2, groups = { TestGroup.ASS_13 }) public void testGrandChildPathWhenGrandParentRenamed() throws Exception { - // Create grand-parent folder + // Create grand parent folder grandParentFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); // Create child folder childFolder = dataContent.usingUser(testUser).usingResource(grandParentFolder).createFolder(); - // Create grand-child file + // Create grand child file grandChildFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content"); Map properties = new HashMap<>(); properties.put(PropertyIds.NAME, grandChildFile.getName()); @@ -105,18 +105,18 @@ public class CascadingTrackerIntegrationTest extends AbstractSearchServiceE2E String grandParentNewName = "grandParentRenamed"; grandParentFolder.setName(grandParentNewName); - ContentModel granParentNewNameModel = new ContentModel(grandParentNewName); - this.dataContent.usingUser(testUser).usingResource(grandParentFolder).renameContent(granParentNewNameModel); + ContentModel grandParentFolderRenamed = new ContentModel(grandParentNewName); + dataContent.usingUser(testUser).usingResource(grandParentFolder).renameContent(grandParentFolderRenamed); // Find nodes where Path with new folder name matches String parentQueryAfterRename = "NPATH:\"4/Company Home/Sites/" + testSite.getTitle() + "/documentLibrary/" + grandParentNewName + "\""; - Assert.assertEquals(waitForContent(parentQueryAfterRename, grandChildFile.getName(), true), true, "Indexing is still in Progress"); + Boolean indexingInProgress = !waitForContent(parentQueryAfterRename, grandChildFile.getName(), true); - // Query using new parent name + // Query using new parent name: Expect grand parent, child folder, grand child file int descendantCountOfNewName = query(parentQueryAfterRename).getPagination().getCount(); - Assert.assertEquals(descendantCountOfNewName, 3, "New renamed path has not the same descendants as before renaming: " + parentQueryAfterRename); + Assert.assertEquals(descendantCountOfNewName, 3, String.format("Indexing in progress: %s New renamed path has not the same descendants as before renaming: %s", indexingInProgress.toString(), parentQueryAfterRename)); - // Query using old parent name + // Query using old parent name: Expect no descendant after rename int descendantCountOfOriginalName = query(parentQuery).getPagination().getCount(); Assert.assertEquals(descendantCountOfOriginalName, 0, "Old path still has descendants: " + parentQuery); }