-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opensearch should returns partial results after the timeout in coordi…
…nate node when allow_partial_search_results is true
- Loading branch information
Showing
7 changed files
with
157 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
server/src/test/java/org/opensearch/action/search/SearchTransportServiceTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.search; | ||
|
||
import org.opensearch.core.tasks.TaskCancelledException; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
import org.opensearch.transport.TransportRequestOptions; | ||
|
||
public class SearchTransportServiceTests extends OpenSearchTestCase { | ||
public void testGetTransportRequestOptions() { | ||
SearchTask searchTask = new SearchTask(1, null, null, null, null, null, null, System.currentTimeMillis(), 1000, 0.8f); | ||
TransportRequestOptions transportRequestOptions = SearchTransportService.getTransportRequestOptions(searchTask, e -> {}, true); | ||
assertTrue(transportRequestOptions.timeout().millis() > 0); | ||
|
||
TransportRequestOptions transportRequestOptions1 = SearchTransportService.getTransportRequestOptions(searchTask, e -> {}, false); | ||
assertTrue(transportRequestOptions.timeout().millis() < transportRequestOptions1.timeout().millis()); | ||
|
||
SearchTask searchTask1 = new SearchTask(1, null, null, null, null, null, null, System.currentTimeMillis(), 1, 0.8f); | ||
|
||
transportRequestOptions = SearchTransportService.getTransportRequestOptions(searchTask1, exception -> { | ||
assertEquals(TaskCancelledException.class, exception.getClass()); | ||
assertTrue(exception.getMessage().contains("failed to execute fetch phase, timeout exceeded")); | ||
}, true); | ||
assertNull(transportRequestOptions); | ||
|
||
searchTask = new SearchTask(1, null, null, null, null, null, null, System.currentTimeMillis(), 0, 0.8f); | ||
transportRequestOptions = SearchTransportService.getTransportRequestOptions(searchTask, e -> {}, false); | ||
assertEquals(TransportRequestOptions.EMPTY, transportRequestOptions); | ||
} | ||
} |