Skip to content

Commit

Permalink
Replace awaitBusy with assertBusy in atLeastDocsIndexed (elastic#38190)
Browse files Browse the repository at this point in the history
Unlike assertBusy, awaitBusy does not retry if the code-block throws an
AssertionError. A refresh in atLeastDocsIndexed can fail because we call
this method while we are closing some node in FollowerFailOverIT.
  • Loading branch information
dnhatn committed Feb 1, 2019
1 parent ee57420 commit f64b203
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,15 @@ private Map<Integer, List<DocIdSeqNoAndTerm>> getDocIdAndSeqNos(InternalTestClus
return docs;
}

protected void atLeastDocsIndexed(Client client, String index, long numDocsReplicated) throws InterruptedException {
protected void atLeastDocsIndexed(Client client, String index, long numDocsReplicated) throws Exception {
logger.info("waiting for at least [{}] documents to be indexed into index [{}]", numDocsReplicated, index);
awaitBusy(() -> {
assertBusy(() -> {
refresh(client, index);
SearchRequest request = new SearchRequest(index);
request.source(new SearchSourceBuilder().size(0));
SearchResponse response = client.search(request).actionGet();
return response.getHits().getTotalHits().value >= numDocsReplicated;
assertNotNull(response.getHits().getTotalHits());
assertThat(response.getHits().getTotalHits().value, greaterThanOrEqualTo(numDocsReplicated));
}, 60, TimeUnit.SECONDS);
}

Expand Down

0 comments on commit f64b203

Please sign in to comment.