mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
This reverts commit 0cb5108942
.
This commit is contained in:
parent
4276aade73
commit
79878662c5
9 changed files with 27 additions and 102 deletions
|
@ -347,12 +347,7 @@ public class RestHighLevelClient implements Closeable {
|
|||
.flatMap(Function.identity())
|
||||
.collect(toList())
|
||||
);
|
||||
|
||||
// Compatibility mode is on by default, then env variable has precedence over builder setting
|
||||
String apiVersioningEnv = System.getenv(API_VERSIONING_ENV_VARIABLE);
|
||||
if (useAPICompatibility == null && apiVersioningEnv == null) {
|
||||
this.useAPICompatibility = true;
|
||||
} else if (useAPICompatibility == null && "true".equals(System.getenv(API_VERSIONING_ENV_VARIABLE))) {
|
||||
if (useAPICompatibility == null && "true".equals(System.getenv(API_VERSIONING_ENV_VARIABLE))) {
|
||||
this.useAPICompatibility = true;
|
||||
} else {
|
||||
this.useAPICompatibility = Boolean.TRUE.equals(useAPICompatibility);
|
||||
|
|
|
@ -147,8 +147,7 @@ public class CustomRestHighLevelClientTests extends ESTestCase {
|
|||
* Mocks the synchronous request execution like if it was executed by Elasticsearch.
|
||||
*/
|
||||
private Response mockPerformRequest(Request request) throws IOException {
|
||||
// Headers contain 'node_name' set by optionsForNodeName and 'Accept' from HLRC compatibility mode
|
||||
assertThat(request.getOptions().getHeaders(), hasSize(2));
|
||||
assertThat(request.getOptions().getHeaders(), hasSize(1));
|
||||
Header httpHeader = request.getOptions().getHeaders().get(0);
|
||||
final Response mockResponse = mock(Response.class);
|
||||
when(mockResponse.getHost()).thenReturn(new HttpHost("localhost", 9200));
|
||||
|
|
|
@ -33,8 +33,6 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.get.GetRequest;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.search.ClearScrollRequest;
|
||||
import org.elasticsearch.action.search.ClearScrollResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
|
@ -97,7 +95,6 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.core.CheckedFunction;
|
||||
import org.elasticsearch.core.Tuple;
|
||||
import org.elasticsearch.index.get.GetResult;
|
||||
import org.elasticsearch.index.rankeval.DiscountedCumulativeGain;
|
||||
import org.elasticsearch.index.rankeval.EvaluationMetric;
|
||||
import org.elasticsearch.index.rankeval.ExpectedReciprocalRank;
|
||||
|
@ -1504,30 +1501,6 @@ public class RestHighLevelClientTests extends ESTestCase {
|
|||
|
||||
}
|
||||
|
||||
public void testCompatibilityModeDefault() throws Exception {
|
||||
mockResponse(new GetResponse(new GetResult("foo", "bar", "1", 1, 1, 1, true, null, null, null)));
|
||||
restHighLevelClient.get(new GetRequest("foo", "bar"), RequestOptions.DEFAULT);
|
||||
|
||||
verify(restClient).performRequest(argThat(req -> {
|
||||
List<Header> headers = req.getOptions().getHeaders();
|
||||
Header accept = headers.stream().filter(h -> h.getName().equals("Accept")).findFirst().get();
|
||||
return accept.getValue().equals("application/vnd.elasticsearch+json; compatible-with=7");
|
||||
}));
|
||||
}
|
||||
|
||||
public void testDisableCompatibilityMode() throws Exception {
|
||||
RestHighLevelClient client = new RestHighLevelClientBuilder(restClient).setApiCompatibilityMode(false).build();
|
||||
|
||||
mockResponse(new GetResponse(new GetResult("foo", "bar", "1", 1, 1, 1, true, null, null, null)));
|
||||
client.get(new GetRequest("foo", "bar"), RequestOptions.DEFAULT);
|
||||
|
||||
verify(restClient).performRequest(argThat(req -> {
|
||||
List<Header> headers = req.getOptions().getHeaders();
|
||||
Optional<Header> accept = headers.stream().filter(h -> h.getName().equals("Accept")).findFirst();
|
||||
return accept.isPresent() == false;
|
||||
}));
|
||||
}
|
||||
|
||||
private static void assertSyncMethod(Method method, String apiName, List<String> booleanReturnMethods) {
|
||||
// A few methods return a boolean rather than a response object
|
||||
if (apiName.equals("ping") || apiName.contains("exist") || booleanReturnMethods.contains(apiName)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue