From 105a357aa63cae856660335a8d2f39488d38f0f4 Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Thu, 24 Oct 2024 14:11:25 -0500 Subject: [PATCH] Removing the legacy global template from yaml rest tests --- .../rest/yaml/ESClientYamlSuiteTestCase.java | 63 ------------------- 1 file changed, 63 deletions(-) diff --git a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java index 823e9e1fe9a7c..54602090050ab 100644 --- a/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java +++ b/test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java @@ -18,15 +18,11 @@ import org.apache.lucene.tests.util.TimeUnits; import org.elasticsearch.client.Node; import org.elasticsearch.client.Request; -import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; -import org.elasticsearch.client.WarningsHandler; import org.elasticsearch.client.sniff.ElasticsearchNodesSniffer; -import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.core.IOUtils; import org.elasticsearch.core.UpdateForV9; @@ -41,11 +37,8 @@ import org.elasticsearch.test.rest.yaml.section.ExecutableSection; import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.ParseField; -import org.elasticsearch.xcontent.ToXContent; -import org.elasticsearch.xcontent.XContentBuilder; import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import java.io.IOException; import java.nio.file.Files; @@ -67,8 +60,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder; - /** * Runs a suite of yaml tests shared with all the official Elasticsearch * clients against an elasticsearch cluster. @@ -125,15 +116,6 @@ protected ESClientYamlSuiteTestCase(ClientYamlTestCandidate testCandidate) { this.testCandidate = testCandidate; } - private static Settings globalTemplateIndexSettings; - - @BeforeClass - public static void initializeGlobalTemplateIndexSettings() { - globalTemplateIndexSettings = usually() - ? Settings.EMPTY - : Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2).build(); - } - @Before public void initAndResetContext() throws Exception { if (restTestExecutionContext == null) { @@ -511,34 +493,6 @@ public void test() throws IOException { inFipsJvm() && testCandidate.getTestSection().getPrerequisiteSection().hasYamlRunnerFeature("fips_140") ); - final Settings globalTemplateSettings = getGlobalTemplateSettings( - testCandidate.getTestSection().getPrerequisiteSection().hasYamlRunnerFeature("default_shards") - ); - if (globalTemplateSettings.isEmpty() == false && ESRestTestCase.has(ProductFeature.LEGACY_TEMPLATES)) { - - final XContentBuilder template = jsonBuilder(); - template.startObject(); - { - template.array("index_patterns", "*"); - template.startObject("settings"); - globalTemplateSettings.toXContent(template, ToXContent.EMPTY_PARAMS); - template.endObject(); - } - template.endObject(); - - 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(); - builder.setWarningsHandler(WarningsHandler.PERMISSIVE); - request.setOptions(builder.build()); - adminClient().performRequest(request); - } - if (skipSetupSections() == false && testCandidate.getSetupSection().isEmpty() == false) { logger.debug("start setup test [{}]", testCandidate.getTestPath()); for (ExecutableSection executableSection : testCandidate.getSetupSection().getExecutableSections()) { @@ -562,23 +516,6 @@ public void test() throws IOException { } } - @Deprecated - protected Settings getGlobalTemplateSettings(List features) { - if (features.contains("default_shards")) { - return Settings.EMPTY; - } else { - return globalTemplateIndexSettings; - } - } - - protected Settings getGlobalTemplateSettings(boolean defaultShardsFeature) { - if (defaultShardsFeature) { - return Settings.EMPTY; - } else { - return globalTemplateIndexSettings; - } - } - protected boolean skipSetupSections() { return false; }