Skip to content

Commit

Permalink
No longer creating the global template as a v2 template ever
Browse files Browse the repository at this point in the history
  • Loading branch information
masseyke committed Nov 7, 2023
1 parent 2b4ba7a commit 3288a3f
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,37 +484,27 @@ public void test() throws IOException {
);

final Settings globalTemplateSettings = getGlobalTemplateSettings(testCandidate.getTestSection().getSkipSection().getFeatures());
if (globalTemplateSettings.isEmpty() == false) {
boolean useComponentTemplate = ESRestTestCase.has(ProductFeature.LEGACY_TEMPLATES) == false;
if (globalTemplateSettings.isEmpty() == false && ESRestTestCase.has(ProductFeature.LEGACY_TEMPLATES)) {

final XContentBuilder template = jsonBuilder();
template.startObject();
{
template.array("index_patterns", "*");
if (useComponentTemplate) {
template.field("priority", 4); // relatively low priority, but hopefully uncommon enough not to conflict
template.startObject("template");
}
template.startObject("settings");
globalTemplateSettings.toXContent(template, ToXContent.EMPTY_PARAMS);
template.endObject();
if (useComponentTemplate) {
template.endObject();
}
}
template.endObject();

final Request request = new Request("PUT", useComponentTemplate ? "/_index_template/global" : "/_template/global");
final Request request = new Request("PUT", "/_template/global");
request.setJsonEntity(Strings.toString(template));
// Because not all case have transitioned to a composable template, it's possible that
// this can overlap an installed composable template since this is a global (*)
// template. In order to avoid this failing the test, we override the warnings handler
// to be permissive in this case. This can be removed once all tests use composable
// templates instead of legacy templates
RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
if (useComponentTemplate == false) {
builder.setWarningsHandler(WarningsHandler.PERMISSIVE);
}
builder.setWarningsHandler(WarningsHandler.PERMISSIVE);
request.setOptions(builder.build());
adminClient().performRequest(request);
}
Expand Down

0 comments on commit 3288a3f

Please sign in to comment.