Fix AsyncSearchTaskTests#testWithFetchFailures
Fix usage of a possible invalid random range [1, 0]. Relates #55688
This commit is contained in:
parent
31d1727698
commit
c857adf603
|
@ -149,7 +149,6 @@ public class AsyncSearchTaskTests extends ESTestCase {
|
|||
newSearchResponse(numShards+numSkippedShards, numShards, numSkippedShards));
|
||||
assertCompletionListeners(task, numShards+numSkippedShards,
|
||||
numSkippedShards, numShardFailures, false);
|
||||
threadPool.shutdownNow();
|
||||
}
|
||||
|
||||
public void testWithFetchFailures() throws InterruptedException {
|
||||
|
@ -173,7 +172,7 @@ public class AsyncSearchTaskTests extends ESTestCase {
|
|||
}
|
||||
task.getSearchProgressActionListener().onFinalReduce(shards,
|
||||
new TotalHits(0, TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO), null, 0);
|
||||
int numFetchFailures = randomIntBetween(1, numShards);
|
||||
int numFetchFailures = randomIntBetween(0, numShards);
|
||||
for (int i = 0; i < numFetchFailures; i++) {
|
||||
task.getSearchProgressActionListener().onFetchFailure(i,
|
||||
new SearchShardTarget("0", new ShardId("0", "0", 1), null, OriginalIndices.NONE),
|
||||
|
@ -185,7 +184,6 @@ public class AsyncSearchTaskTests extends ESTestCase {
|
|||
newSearchResponse(numShards+numSkippedShards, numShards, numSkippedShards));
|
||||
assertCompletionListeners(task, numShards+numSkippedShards,
|
||||
numSkippedShards, numFetchFailures, false);
|
||||
threadPool.shutdownNow();
|
||||
}
|
||||
|
||||
private static SearchResponse newSearchResponse(int totalShards, int successfulShards, int skippedShards) {
|
||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.core.search.action;
|
|||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
@ -78,11 +77,7 @@ public class AsyncSearchResponse extends ActionResponse implements StatusToXCont
|
|||
|
||||
public AsyncSearchResponse(StreamInput in) throws IOException {
|
||||
this.id = in.readOptionalString();
|
||||
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
|
||||
this.error = in.readBoolean() ? in.readException() : null;
|
||||
} else {
|
||||
this.error = in.readOptionalWriteable(ElasticsearchException::new);
|
||||
}
|
||||
this.error = in.readBoolean() ? in.readException() : null;
|
||||
this.searchResponse = in.readOptionalWriteable(SearchResponse::new);
|
||||
this.isPartial = in.readBoolean();
|
||||
this.isRunning = in.readBoolean();
|
||||
|
@ -93,15 +88,11 @@ public class AsyncSearchResponse extends ActionResponse implements StatusToXCont
|
|||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeOptionalString(id);
|
||||
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
|
||||
if (error != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeException(error);
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
if (error != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeException(error);
|
||||
} else {
|
||||
out.writeOptionalWriteable(ExceptionsHelper.convertToElastic(error));
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
out.writeOptionalWriteable(searchResponse);
|
||||
out.writeBoolean(isPartial);
|
||||
|
|
Loading…
Reference in New Issue