Skip to content

Commit

Permalink
ACS-5734 Fix Elasticsearch TAS tests failure (#2539)
Browse files Browse the repository at this point in the history
(cherry picked from commit dd7ead1)
  • Loading branch information
viepovsky authored and tiagosalvado10 committed Oct 11, 2023
1 parent f4de6d2 commit 6464af0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,29 @@
*/
public class RetryAnalyzer implements IRetryAnalyzer
{
private static Logger LOGGER = LoggerFactory.getLogger(RetryAnalyzer.class);
private static int RETRY_LIMIT = 3;
private static final Logger LOGGER = LoggerFactory.getLogger(RetryAnalyzer.class);
private static final int RETRY_LIMIT = 3;
private int retryNumber = 0;

@Override
public boolean retry(ITestResult testResult) {
retryNumber++;
Throwable throwable = testResult.getThrowable();
if (retryNumber == RETRY_LIMIT)
{
LOGGER.info("Retry limit reached: {}, shouldRetry: {}", retryNumber, false, throwable);
return false;
}
Throwable throwable = testResult.getThrowable();
boolean shouldRetry = throwable != null
&& (throwable instanceof IllegalStateException
&& throwable.getMessage().contains("connection still allocated"))
|| (throwable instanceof ConcurrentModificationException);
LOGGER.info("Retry: {}, shouldRetry: {}", retryNumber, shouldRetry, throwable);
return shouldRetry;
else
{
boolean shouldRetry = throwable != null
&& (throwable instanceof IllegalStateException
&& throwable.getMessage().contains("connection still allocated"))
|| (throwable instanceof ConcurrentModificationException)
|| (throwable instanceof AssertionError
&& throwable.getMessage().contains("Maximum retry period reached"));
LOGGER.info("Retry: {}, shouldRetry: {}", retryNumber, shouldRetry, throwable);
return shouldRetry;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.dataprep.CMISUtil;
Expand Down Expand Up @@ -77,6 +79,13 @@ public class ElasticsearchSiteIndexingTests extends AbstractTestNGSpringContextT
private UserModel testUser;
private UserModel siteCreator;
private FolderModel testFolder;
private SiteModel testSite1;
private SiteModel testSite2;
private FileModel fileNotInSite;
private FileModel file1;
private FileModel file2;
private FileModel file3;
private FileModel file4;

@BeforeClass (alwaysRun = true)
public void dataPreparation()
Expand All @@ -103,14 +112,23 @@ public void testSiteUseCasesForCreateModifyDeleteSite()
// Remove the automatically created Sample Site
deleteSite(SAMPLE_SITE_ID);

//Sometimes this test may fail, so if previous data exists it must be deleted before the next run
Stream.of(fileNotInSite, file1, file2, file3, file4)
.filter(Objects::nonNull)
.forEach(this::deleteFile);
Stream.of(testSite1, testSite2)
.filter(Objects::nonNull)
.map(SiteModel::getId)
.forEach(this::deleteSite);

Step.STEP("Site creation use cases");

// Check there are no files within or without a site, that have the given filename prefix
assertSiteQueryResult(ALL_SITES, List.of());
assertSiteQueryResult(EVERYTHING, "AND", FILE_CONTENT_CONDITION, List.of());

// Create a file with the given filename prefix, outside any site
FileModel fileNotInSite = new FileModel(unique(FILENAME_PREFIX) + ".txt", FileType.TEXT_PLAIN, "Content for fileNotInSite");
fileNotInSite = new FileModel(unique(FILENAME_PREFIX) + ".txt", FileType.TEXT_PLAIN, "Content for fileNotInSite");
fileNotInSite = dataContent
.usingAdmin()
.usingResource(testFolder)
Expand All @@ -125,39 +143,39 @@ public void testSiteUseCasesForCreateModifyDeleteSite()
assertSiteQueryResult(unique("NoSuchSite"), List.of());

// Create one empty public site - expect no results other than document library
SiteModel testSite1 = createPublicSite();
testSite1 = createPublicSite();
assertSiteQueryResult(testSite1.getId(), List.of(DOCUMENT_LIBRARY));
assertSiteQueryResult(ALL_SITES, List.of(DOCUMENT_LIBRARY));
assertSiteQueryResult(EVERYTHING, "AND", FILE_CONTENT_CONDITION, List.of(fileNotInSite));

// Create a file in public site - expect one file plus the document library.
FileModel file1 = createContentInSite(testSite1, FILENAME_PREFIX + "test1");
file1 = createContentInSite(testSite1, FILENAME_PREFIX + "test1");
assertSiteQueryResult(testSite1.getId(), List.of(DOCUMENT_LIBRARY, file1));
assertSiteQueryResult(ALL_SITES, List.of(DOCUMENT_LIBRARY, file1));
assertSiteQueryResult(EVERYTHING, "AND", FILE_CONTENT_CONDITION, List.of(fileNotInSite, file1));

// Create another file in public site - expect two files plus the document library.
FileModel file2 = createContentInSite(testSite1, FILENAME_PREFIX + "test2");
file2 = createContentInSite(testSite1, FILENAME_PREFIX + "test2");
assertSiteQueryResult(testSite1.getId(), List.of(DOCUMENT_LIBRARY, file1, file2));
assertSiteQueryResult(ALL_SITES, List.of(DOCUMENT_LIBRARY, file1, file2));
assertSiteQueryResult(EVERYTHING, "AND", FILE_CONTENT_CONDITION, List.of(fileNotInSite, file1, file2));

// Create a second public site, empty - expect no results other than document library
SiteModel testSite2 = createPublicSite();
testSite2 = createPublicSite();
assertSiteQueryResult(testSite2.getId(), List.of(DOCUMENT_LIBRARY));
assertSiteQueryResult(testSite1.getId(), List.of(DOCUMENT_LIBRARY, file1, file2));
assertSiteQueryResult(ALL_SITES, List.of(DOCUMENT_LIBRARY, file1, file2));
assertSiteQueryResult(EVERYTHING, "AND", FILE_CONTENT_CONDITION, List.of(fileNotInSite, file1, file2));

// Create a file in second public site - expect one file plus the document library.
FileModel file3 = createContentInSite(testSite2, FILENAME_PREFIX + "test3");
file3 = createContentInSite(testSite2, FILENAME_PREFIX + "test3");
assertSiteQueryResult(testSite2.getId(), List.of(DOCUMENT_LIBRARY, file3));
assertSiteQueryResult(testSite1.getId(), List.of(DOCUMENT_LIBRARY, file1, file2));
assertSiteQueryResult(ALL_SITES, List.of(DOCUMENT_LIBRARY, file1, file2, file3));
assertSiteQueryResult(EVERYTHING, "AND", FILE_CONTENT_CONDITION, List.of(fileNotInSite, file1, file2, file3));

// Create another file in second public site - expect two files plus the document library.
FileModel file4 = createContentInSite(testSite2, FILENAME_PREFIX + "test4");
file4 = createContentInSite(testSite2, FILENAME_PREFIX + "test4");
assertSiteQueryResult(testSite2.getId(), List.of(DOCUMENT_LIBRARY, file3, file4));
assertSiteQueryResult(testSite1.getId(), List.of(DOCUMENT_LIBRARY, file1, file2));
assertSiteQueryResult(ALL_SITES, List.of(DOCUMENT_LIBRARY, file1, file2, file3, file4));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private GenericContainer createTransformCoreContainer()
return new GenericContainer(getImagesConfig().getTransformCoreAIOImage())
.withNetwork(network)
.withNetworkAliases("transform-core-aio")
.withEnv("JAVA_OPTS", "-Xms512m -Xmx512m")
.withEnv("JAVA_OPTS", "-Xms512m -Xmx1024m")
.withEnv("ACTIVEMQ_URL", "nio://activemq:61616")
.withEnv("FILE_STORE_URL", "http://shared-file-store:8099/alfresco/api/-default-/private/sfs/versions/1/file")
.withExposedPorts(8090)
Expand All @@ -359,7 +359,7 @@ private GenericContainer createTransformRouterContainer()
return new GenericContainer(getImagesConfig().getTransformRouterImage())
.withNetwork(network)
.withNetworkAliases("transform-router")
.withEnv("JAVA_OPTS", "-Xms256m -Xmx256m")
.withEnv("JAVA_OPTS", "-Xms256m -Xmx512m")
.withEnv("ACTIVEMQ_URL", "nio://activemq:61616")
.withEnv("CORE_AIO_URL", "http://transform-core-aio:8090")
.withEnv("FILE_STORE_URL", "http://shared-file-store:8099/alfresco/api/-default-/private/sfs/versions/1/file")
Expand Down

0 comments on commit 6464af0

Please sign in to comment.