Skip to content

Commit

Permalink
Busily assert in testCreateSearchContextFailure (#64243)
Browse files Browse the repository at this point in the history
If a background refresh is running, then the refCount assertion will 
fail as Engine#refreshIsNeeded can increase the refCount by 2.

Closes #64052
  • Loading branch information
dnhatn committed Nov 10, 2020
1 parent 9546d0d commit 207e4b0
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ public void testCreateSearchContext() throws IOException {
* While we have no NPE in DefaultContext constructor anymore, we still want to guard against it (or other failures) in the future to
* avoid leaking searchers.
*/
public void testCreateSearchContextFailure() throws IOException {
public void testCreateSearchContextFailure() throws Exception {
final String index = randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT);
final IndexService indexService = createIndex(index);
final SearchService service = getInstanceFromNode(SearchService.class);
Expand All @@ -897,7 +897,9 @@ public SearchType searchType() {
() -> service.createContext(reader, request, null, randomBoolean()));
assertEquals("expected", e.getMessage());
}
assertEquals("should have 2 store refs (IndexService + InternalEngine)", 2, indexService.getShard(0).store().refCount());
// Needs to busily assert because Engine#refreshNeeded can increase the refCount.
assertBusy(() ->
assertEquals("should have 2 store refs (IndexService + InternalEngine)", 2, indexService.getShard(0).store().refCount()));
}

public void testMatchNoDocsEmptyResponse() throws InterruptedException {
Expand Down

0 comments on commit 207e4b0

Please sign in to comment.