Revert "Enable HLRC compatibility mode by default (#86517)" (#86873)

This reverts commit 0cb5108942.
This commit is contained in:
Seth Michael Larson 2022-05-17 18:06:52 -05:00 committed by GitHub
parent 4276aade73
commit 79878662c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 102 deletions

View file

@ -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);

View file

@ -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));

View file

@ -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)) {