Skip to content

Commit

Permalink
Fix sporadic failures in AsyncSearchActionTests (take 2)
Browse files Browse the repository at this point in the history
This change removes the need to always get a new version when iterating
on an async search. This is needed since we cannot guarantee that shards will
be queried exactly in order.

Relates #53360
  • Loading branch information
jimczi committed Mar 16, 2020
1 parent e1eebea commit dc2edc9
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ protected SearchResponseIterator assertBlockingIterator(String indexName,

return new SearchResponseIterator() {
private AsyncSearchResponse response = initial;
private int lastVersion = initial.getVersion();
private int shardIndex = 0;
private boolean isFirst = true;
private int shardFailures = 0;
Expand Down Expand Up @@ -219,15 +218,9 @@ private AsyncSearchResponse doNext() throws Exception {
}
shardLatchArray[shardIndex++].countDown();
}
assertBusy(() -> {
AsyncSearchResponse newResp = client().execute(GetAsyncSearchAction.INSTANCE,
new GetAsyncSearchAction.Request(response.getId())
.setWaitForCompletion(TimeValue.timeValueMillis(10))).get();
atomic.set(newResp);
assertNotEquals(lastVersion, newResp.getVersion());
});
AsyncSearchResponse newResponse = atomic.get();
lastVersion = newResponse.getVersion();
AsyncSearchResponse newResponse = client().execute(GetAsyncSearchAction.INSTANCE,
new GetAsyncSearchAction.Request(response.getId())
.setWaitForCompletion(TimeValue.timeValueMillis(10))).get();

if (newResponse.isRunning()) {
assertThat(newResponse.status(), equalTo(RestStatus.OK));
Expand Down

0 comments on commit dc2edc9

Please sign in to comment.