Skip to content

Commit

Permalink
Handle deprecation warnings in a permissive manner.
Browse files Browse the repository at this point in the history
Closes #37920
  • Loading branch information
martijnvg committed Jan 28, 2019
1 parent 0d10939 commit e401ab1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
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;
Expand Down Expand Up @@ -85,7 +87,6 @@ public void setIndex() throws IOException {
index = getTestName().toLowerCase(Locale.ROOT);
}

@AwaitsFix(bugUrl = "https:/elastic/elasticsearch/issues/37920")
public void testSearch() throws Exception {
int count;
if (isRunningAgainstOldCluster()) {
Expand Down Expand Up @@ -124,6 +125,9 @@ public void testSearch() throws Exception {
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);
Expand Down Expand Up @@ -153,7 +157,6 @@ public void testSearch() throws Exception {
assertStoredBinaryFields(count);
}

@AwaitsFix(bugUrl = "https:/elastic/elasticsearch/issues/37920")
public void testNewReplicasWork() throws Exception {
if (isRunningAgainstOldCluster()) {
XContentBuilder mappingsAndSettings = jsonBuilder();
Expand All @@ -180,6 +183,9 @@ public void testNewReplicasWork() throws Exception {
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);
Expand Down Expand Up @@ -332,7 +338,6 @@ public void testClusterState() throws Exception {

}

@AwaitsFix(bugUrl = "https:/elastic/elasticsearch/issues/37920")
public void testShrink() throws IOException {
String shrunkenIndex = index + "_shrunk";
int numDocs;
Expand All @@ -355,6 +360,9 @@ public void testShrink() throws IOException {
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);
Expand Down Expand Up @@ -401,7 +409,6 @@ public void testShrink() throws IOException {
assertEquals(numDocs, totalHits);
}

@AwaitsFix(bugUrl = "https:/elastic/elasticsearch/issues/37920")
public void testShrinkAfterUpgrade() throws IOException {
String shrunkenIndex = index + "_shrunk";
int numDocs;
Expand All @@ -424,6 +431,9 @@ public void testShrinkAfterUpgrade() throws IOException {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

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;
Expand Down Expand Up @@ -142,7 +144,6 @@ private static void addCandidate(String querySource, QueryBuilder expectedQb) {
CANDIDATES.add(new Object[]{"{\"query\": {" + querySource + "}}", expectedQb});
}

@AwaitsFix(bugUrl = "https:/elastic/elasticsearch/issues/37920")
public void testQueryBuilderBWC() throws Exception {
String index = "queries";
if (isRunningAgainstOldCluster()) {
Expand Down Expand Up @@ -179,6 +180,9 @@ public void testQueryBuilderBWC() throws Exception {
}
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());
Expand Down

0 comments on commit e401ab1

Please sign in to comment.