Skip to content

Commit 8787f0d

Browse files
authored
Removing code that rarely adds a legacy global template to yaml rest tests (#115799)
1 parent 023c856 commit 8787f0d

File tree

1 file changed

+4
-55
lines changed

1 file changed

+4
-55
lines changed

test/yaml-rest-runner/src/main/java/org/elasticsearch/test/rest/yaml/ESClientYamlSuiteTestCase.java

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818
import org.apache.lucene.tests.util.TimeUnits;
1919
import org.elasticsearch.client.Node;
2020
import org.elasticsearch.client.Request;
21-
import org.elasticsearch.client.RequestOptions;
2221
import org.elasticsearch.client.Response;
2322
import org.elasticsearch.client.RestClient;
2423
import org.elasticsearch.client.RestClientBuilder;
25-
import org.elasticsearch.client.WarningsHandler;
2624
import org.elasticsearch.client.sniff.ElasticsearchNodesSniffer;
27-
import org.elasticsearch.cluster.metadata.IndexMetadata;
2825
import org.elasticsearch.common.Strings;
2926
import org.elasticsearch.common.settings.Settings;
3027
import org.elasticsearch.common.xcontent.support.XContentMapValues;
@@ -41,11 +38,8 @@
4138
import org.elasticsearch.test.rest.yaml.section.ExecutableSection;
4239
import org.elasticsearch.xcontent.NamedXContentRegistry;
4340
import org.elasticsearch.xcontent.ParseField;
44-
import org.elasticsearch.xcontent.ToXContent;
45-
import org.elasticsearch.xcontent.XContentBuilder;
4641
import org.junit.AfterClass;
4742
import org.junit.Before;
48-
import org.junit.BeforeClass;
4943

5044
import java.io.IOException;
5145
import java.nio.file.Files;
@@ -67,8 +61,6 @@
6761
import java.util.stream.Collectors;
6862
import java.util.stream.Stream;
6963

70-
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
71-
7264
/**
7365
* Runs a suite of yaml tests shared with all the official Elasticsearch
7466
* clients against an elasticsearch cluster.
@@ -125,15 +117,6 @@ protected ESClientYamlSuiteTestCase(ClientYamlTestCandidate testCandidate) {
125117
this.testCandidate = testCandidate;
126118
}
127119

128-
private static Settings globalTemplateIndexSettings;
129-
130-
@BeforeClass
131-
public static void initializeGlobalTemplateIndexSettings() {
132-
globalTemplateIndexSettings = usually()
133-
? Settings.EMPTY
134-
: Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2).build();
135-
}
136-
137120
@Before
138121
public void initAndResetContext() throws Exception {
139122
if (restTestExecutionContext == null) {
@@ -511,34 +494,6 @@ public void test() throws IOException {
511494
inFipsJvm() && testCandidate.getTestSection().getPrerequisiteSection().hasYamlRunnerFeature("fips_140")
512495
);
513496

514-
final Settings globalTemplateSettings = getGlobalTemplateSettings(
515-
testCandidate.getTestSection().getPrerequisiteSection().hasYamlRunnerFeature("default_shards")
516-
);
517-
if (globalTemplateSettings.isEmpty() == false && ESRestTestCase.has(ProductFeature.LEGACY_TEMPLATES)) {
518-
519-
final XContentBuilder template = jsonBuilder();
520-
template.startObject();
521-
{
522-
template.array("index_patterns", "*");
523-
template.startObject("settings");
524-
globalTemplateSettings.toXContent(template, ToXContent.EMPTY_PARAMS);
525-
template.endObject();
526-
}
527-
template.endObject();
528-
529-
final Request request = new Request("PUT", "/_template/global");
530-
request.setJsonEntity(Strings.toString(template));
531-
// Because not all case have transitioned to a composable template, it's possible that
532-
// this can overlap an installed composable template since this is a global (*)
533-
// template. In order to avoid this failing the test, we override the warnings handler
534-
// to be permissive in this case. This can be removed once all tests use composable
535-
// templates instead of legacy templates
536-
RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
537-
builder.setWarningsHandler(WarningsHandler.PERMISSIVE);
538-
request.setOptions(builder.build());
539-
adminClient().performRequest(request);
540-
}
541-
542497
if (skipSetupSections() == false && testCandidate.getSetupSection().isEmpty() == false) {
543498
logger.debug("start setup test [{}]", testCandidate.getTestPath());
544499
for (ExecutableSection executableSection : testCandidate.getSetupSection().getExecutableSections()) {
@@ -564,19 +519,13 @@ public void test() throws IOException {
564519

565520
@Deprecated
566521
protected Settings getGlobalTemplateSettings(List<String> features) {
567-
if (features.contains("default_shards")) {
568-
return Settings.EMPTY;
569-
} else {
570-
return globalTemplateIndexSettings;
571-
}
522+
// This method will be deleted once its uses in serverless are deleted
523+
return Settings.EMPTY;
572524
}
573525

574526
protected Settings getGlobalTemplateSettings(boolean defaultShardsFeature) {
575-
if (defaultShardsFeature) {
576-
return Settings.EMPTY;
577-
} else {
578-
return globalTemplateIndexSettings;
579-
}
527+
// This method will be deleted once its uses in serverless are deleted
528+
return Settings.EMPTY;
580529
}
581530

582531
protected boolean skipSetupSections() {

0 commit comments

Comments
 (0)