Busily assert in testCreateSearchContextFailure (#64243)
If a background refresh is running, then the refCount assertion will fail as Engine#refreshIsNeeded can increase the refCount by 2. Closes #64052
This commit is contained in:
parent
9546d0d532
commit
207e4b00f9
|
@ -880,7 +880,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
* While we have no NPE in DefaultContext constructor anymore, we still want to guard against it (or other failures) in the future to
|
* 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.
|
* avoid leaking searchers.
|
||||||
*/
|
*/
|
||||||
public void testCreateSearchContextFailure() throws IOException {
|
public void testCreateSearchContextFailure() throws Exception {
|
||||||
final String index = randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT);
|
final String index = randomAlphaOfLengthBetween(5, 10).toLowerCase(Locale.ROOT);
|
||||||
final IndexService indexService = createIndex(index);
|
final IndexService indexService = createIndex(index);
|
||||||
final SearchService service = getInstanceFromNode(SearchService.class);
|
final SearchService service = getInstanceFromNode(SearchService.class);
|
||||||
|
@ -897,7 +897,9 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
() -> service.createContext(reader, request, null, randomBoolean()));
|
() -> service.createContext(reader, request, null, randomBoolean()));
|
||||||
assertEquals("expected", e.getMessage());
|
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 {
|
public void testMatchNoDocsEmptyResponse() throws InterruptedException {
|
||||||
|
|
Loading…
Reference in New Issue