Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types removal - fix FullClusterRestartIT warning expectations #38310

Merged
merged 2 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.rest.action.admin.indices.RestGetIndexTemplateAction;
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
import org.elasticsearch.rest.action.document.RestBulkAction;
import org.elasticsearch.rest.action.document.RestGetAction;
import org.elasticsearch.rest.action.document.RestUpdateAction;
Expand Down Expand Up @@ -925,8 +923,8 @@ public void testSnapshotRestore() throws IOException {
// We therefore use the deprecated typed APIs when running against the current version.
if (isRunningAgainstOldCluster() == false) {
createTemplateRequest.addParameter(INCLUDE_TYPE_NAME_PARAMETER, "true");
createTemplateRequest.setOptions(expectWarnings(RestPutIndexTemplateAction.TYPES_DEPRECATION_MESSAGE));
}
createTemplateRequest.setOptions(allowTypeRemovalWarnings());

client().performRequest(createTemplateRequest);

Expand Down Expand Up @@ -1135,8 +1133,8 @@ && getOldClusterVersion().onOrAfter(Version.V_6_1_0) && getOldClusterVersion().b
// We therefore use the deprecated typed APIs when running against the current version.
if (isRunningAgainstOldCluster() == false) {
getTemplateRequest.addParameter(INCLUDE_TYPE_NAME_PARAMETER, "true");
getTemplateRequest.setOptions(expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE));
}
getTemplateRequest.setOptions(allowTypeRemovalWarnings());

Map<String, Object> getTemplateResponse = entityAsMap(client().performRequest(getTemplateRequest));
Map<String, Object> expectedTemplate = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,28 @@ public static RequestOptions expectVersionSpecificWarnings(Consumer<VersionSensi
public static RequestOptions expectWarnings(String... warnings) {
return expectVersionSpecificWarnings(consumer -> consumer.current(warnings));
}

/**
* Creates RequestOptions designed to ignore [types removal] warnings but nothing else
* @deprecated this method is only required while we deprecate types and can be removed in 8.0
*/
@Deprecated
public static RequestOptions allowTypeRemovalWarnings() {
Builder builder = RequestOptions.DEFAULT.toBuilder();
builder.setWarningsHandler(new WarningsHandler() {
@Override
public boolean warningsShouldFailRequest(List<String> warnings) {
for (String warning : warnings) {
if(warning.startsWith("[types removal]") == false) {
//Something other than a types removal message - return true
return true;
}
}
return false;
}
});
return builder.build();
}

/**
* Construct an HttpHost from the given host and port
Expand Down