From a899dd4bb9230259dcc8e40fb863034d17300c90 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Fri, 4 Sep 2020 21:54:22 +0200 Subject: [PATCH] [TEST] Core tests with runtime fields minor fix Two dynamic templates get add per runtime type, while one is enough. Also one of the two for the keyword field was incorrect. --- .../rest/CoreTestsWithRuntimeFieldsIT.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java b/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java index 8d679ded47261..4cd078f72b95a 100644 --- a/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java +++ b/x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java @@ -8,7 +8,6 @@ import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; - import org.elasticsearch.common.xcontent.XContentLocation; import org.elasticsearch.index.mapper.BooleanFieldMapper; import org.elasticsearch.index.mapper.DateFieldMapper; @@ -58,7 +57,7 @@ public static Iterable parameters() throws Exception { // The setup section contains an unsupported option continue; } - if (false == modifySection(candidate.getTestPath(), candidate.getTestSection().getExecutableSections())) { + if (false == modifySection(candidate.getTestSection().getExecutableSections())) { // The test section contains an unsupported option continue; } @@ -80,7 +79,7 @@ public static Iterable parameters() throws Exception { * with scripts that load from source. */ private static ClientYamlTestSuite modifiedSuite(ClientYamlTestCandidate candidate) { - if (false == modifySection(candidate.getSuitePath() + "/setup", candidate.getSetupSection().getExecutableSections())) { + if (false == modifySection(candidate.getSetupSection().getExecutableSections())) { return null; } List setup = new ArrayList<>(candidate.getSetupSection().getExecutableSections().size() + 1); @@ -99,7 +98,7 @@ private static ClientYamlTestSuite modifiedSuite(ClientYamlTestCandidate candida * Replace field configuration in {@code indices.create} with scripts * that load from the source. */ - private static boolean modifySection(String sectionName, List executables) { + private static boolean modifySection(List executables) { for (ExecutableSection section : executables) { if (false == (section instanceof DoSection)) { continue; @@ -232,10 +231,6 @@ public void execute(ClientYamlTestExecutionContext executionContext) throws IOEx Map.entry("runtime_type", type), Map.entry("script", painlessToLoadFromSource("{name}", type)) ); - Map body = Map.ofEntries( - Map.entry("match_mapping_type", type.equals("keyword") ? "string" : type), - Map.entry("mapping", mapping) - ); if (type.contentEquals("keyword")) { /* * For "string"-type dynamic mappings emulate our default @@ -248,7 +243,6 @@ public void execute(ClientYamlTestExecutionContext executionContext) throws IOEx } else { dynamicTemplates.add(Map.of(type, Map.of("match_mapping_type", type, "mapping", mapping))); } - dynamicTemplates.add(Map.of(type, body)); } List> bodies = List.of( Map.ofEntries(