mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-28 02:48:38 +00:00
Types removal - fix FullClusterRestartIT warning expectations (#38310)
Relax test warning message checking to pre-empt PR 38022 landing in 6.7 with new warning messages. The relaxed test now just assumes any warning message starting with “[types removal]” is tolerated rather than the precise phrasing used in the 6.7 branch.
This commit is contained in:
parent
24db053465
commit
578fd14257
qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades
test/framework/src/main/java/org/elasticsearch/test/rest
@ -36,8 +36,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||
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;
|
||||
@ -925,8 +923,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||
// 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);
|
||||
|
||||
@ -1135,8 +1133,8 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||
// 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<>();
|
||||
|
@ -257,6 +257,28 @@ public abstract class ESRestTestCase extends ESTestCase {
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user