Handle deprecation warnings in a permissive manner.

Closes #37920
This commit is contained in:
Martijn van Groningen 2019-01-28 15:02:50 +01:00
parent 0d109396fa
commit e401ab1724
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
2 changed files with 19 additions and 5 deletions

View File

@ -22,9 +22,11 @@ package org.elasticsearch.upgrades;
import org.apache.http.util.EntityUtils;
import org.elasticsearch.Version;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.WarningsHandler;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.CheckedFunction;
@ -85,7 +87,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
index = getTestName().toLowerCase(Locale.ROOT);
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37920")
public void testSearch() throws Exception {
int count;
if (isRunningAgainstOldCluster()) {
@ -124,6 +125,9 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
mappingsAndSettings.endObject();
Request createIndex = new Request("PUT", "/" + index);
createIndex.setJsonEntity(Strings.toString(mappingsAndSettings));
RequestOptions.Builder options = createIndex.getOptions().toBuilder();
options.setWarningsHandler(WarningsHandler.PERMISSIVE);
createIndex.setOptions(options);
client().performRequest(createIndex);
count = randomIntBetween(2000, 3000);
@ -153,7 +157,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
assertStoredBinaryFields(count);
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37920")
public void testNewReplicasWork() throws Exception {
if (isRunningAgainstOldCluster()) {
XContentBuilder mappingsAndSettings = jsonBuilder();
@ -180,6 +183,9 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
mappingsAndSettings.endObject();
Request createIndex = new Request("PUT", "/" + index);
createIndex.setJsonEntity(Strings.toString(mappingsAndSettings));
RequestOptions.Builder options = createIndex.getOptions().toBuilder();
options.setWarningsHandler(WarningsHandler.PERMISSIVE);
createIndex.setOptions(options);
client().performRequest(createIndex);
int numDocs = randomIntBetween(2000, 3000);
@ -332,7 +338,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37920")
public void testShrink() throws IOException {
String shrunkenIndex = index + "_shrunk";
int numDocs;
@ -355,6 +360,9 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
mappingsAndSettings.endObject();
Request createIndex = new Request("PUT", "/" + index);
createIndex.setJsonEntity(Strings.toString(mappingsAndSettings));
RequestOptions.Builder options = createIndex.getOptions().toBuilder();
options.setWarningsHandler(WarningsHandler.PERMISSIVE);
createIndex.setOptions(options);
client().performRequest(createIndex);
numDocs = randomIntBetween(512, 1024);
@ -401,7 +409,6 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
assertEquals(numDocs, totalHits);
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37920")
public void testShrinkAfterUpgrade() throws IOException {
String shrunkenIndex = index + "_shrunk";
int numDocs;
@ -424,6 +431,9 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
mappingsAndSettings.endObject();
Request createIndex = new Request("PUT", "/" + index);
createIndex.setJsonEntity(Strings.toString(mappingsAndSettings));
RequestOptions.Builder options = createIndex.getOptions().toBuilder();
options.setWarningsHandler(WarningsHandler.PERMISSIVE);
createIndex.setOptions(options);
client().performRequest(createIndex);
numDocs = randomIntBetween(512, 1024);

View File

@ -21,7 +21,9 @@ package org.elasticsearch.upgrades;
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.WarningsHandler;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.InputStreamStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
@ -142,7 +144,6 @@ public class QueryBuilderBWCIT extends AbstractFullClusterRestartTestCase {
CANDIDATES.add(new Object[]{"{\"query\": {" + querySource + "}}", expectedQb});
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37920")
public void testQueryBuilderBWC() throws Exception {
String index = "queries";
if (isRunningAgainstOldCluster()) {
@ -179,6 +180,9 @@ public class QueryBuilderBWCIT extends AbstractFullClusterRestartTestCase {
}
mappingsAndSettings.endObject();
Request request = new Request("PUT", "/" + index);
RequestOptions.Builder options = request.getOptions().toBuilder();
options.setWarningsHandler(WarningsHandler.PERMISSIVE);
request.setOptions(options);
request.setJsonEntity(Strings.toString(mappingsAndSettings));
Response rsp = client().performRequest(request);
assertEquals(200, rsp.getStatusLine().getStatusCode());