Fix pipeline intermittent failures

This commit is contained in:
Sara Aspery
2023-01-11 11:59:37 +00:00
parent 69832bd140
commit 3dc637df12
2 changed files with 48 additions and 31 deletions

View File

@@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Search Services E2E Test * Alfresco Search Services E2E Test
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
@@ -43,6 +43,7 @@ import org.alfresco.dataprep.ContentService;
import org.alfresco.dataprep.SiteService.Visibility; import org.alfresco.dataprep.SiteService.Visibility;
import org.alfresco.rest.core.RestProperties; import org.alfresco.rest.core.RestProperties;
import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.exception.EmptyJsonResponseException;
import org.alfresco.rest.exception.EmptyRestModelCollectionException; import org.alfresco.rest.exception.EmptyRestModelCollectionException;
import org.alfresco.rest.model.RestRequestSpellcheckModel; import org.alfresco.rest.model.RestRequestSpellcheckModel;
import org.alfresco.rest.search.Pagination; import org.alfresco.rest.search.Pagination;
@@ -301,6 +302,8 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
// Repeat search until the query results are as expected or Search Retry count is hit // Repeat search until the query results are as expected or Search Retry count is hit
for (int searchCount = 0; searchCount < SEARCH_MAX_ATTEMPTS; searchCount++) for (int searchCount = 0; searchCount < SEARCH_MAX_ATTEMPTS; searchCount++)
{
try
{ {
SearchResponse response = query(searchRequest); SearchResponse response = query(searchRequest);
@@ -321,6 +324,11 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
throw new RuntimeException("API returned status code:" + restClient.getStatusCode() + " Expected: " + expectedStatusCode + "; Response body: " + response); throw new RuntimeException("API returned status code:" + restClient.getStatusCode() + " Expected: " + expectedStatusCode + "; Response body: " + response);
} }
} }
catch (EmptyJsonResponseException e)
{
// Ignore the empty JSON response and try again
}
}
return false; return false;
} }

View File

@@ -25,6 +25,7 @@ package org.alfresco.test.search.functional.searchServices.search;
import org.alfresco.rest.search.RestRequestQueryModel; import org.alfresco.rest.search.RestRequestQueryModel;
import org.alfresco.rest.search.SearchRequest; import org.alfresco.rest.search.SearchRequest;
import org.alfresco.rest.search.SearchResponse; import org.alfresco.rest.search.SearchResponse;
import org.alfresco.utility.Utility;
import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType; import org.alfresco.utility.model.FileType;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
@@ -235,10 +236,18 @@ public class SearchSimpleCasesTest extends AbstractSearchServicesE2ETest
SearchRequest searchReq = createQuery("name:'" + specialCharfileName + "'"); SearchRequest searchReq = createQuery("name:'" + specialCharfileName + "'");
SearchResponse nodes = query(searchReq); SearchResponse nodes = query(searchReq);
restClient.assertStatusCodeIs(HttpStatus.OK); restClient.assertStatusCodeIs(HttpStatus.OK);
nodes.assertThat().entriesListIsNotEmpty();
int searchCount = 0;
while (nodes.isEmpty() && searchCount < SEARCH_MAX_ATTEMPTS)
{
// Wait for the solr indexing (eventual consistency).
Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Results After Indexing. Retry Attempt: " + (searchCount + 1));
nodes = query(searchReq);
restClient.assertStatusCodeIs(HttpStatus.OK);
}
nodes.assertThat().entriesListIsNotEmpty();
restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.equalToIgnoringCase(specialCharfileName)); restClient.onResponse().assertThat().body("list.entries.entry[0].name", Matchers.equalToIgnoringCase(specialCharfileName));
} }
} }