Skip to content

Commit 1f2f49b

Browse files
authored
[TEST] Core tests with runtime fields minor fix (#62009)
Two dynamic templates get add per runtime type, while one is enough. Also one of the two for the keyword field was incorrect.
1 parent d52668d commit 1f2f49b

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

x-pack/plugin/runtime-fields/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/runtimefields/rest/CoreTestsWithRuntimeFieldsIT.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import com.carrotsearch.randomizedtesting.annotations.Name;
1010
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
11-
1211
import org.elasticsearch.common.xcontent.XContentLocation;
1312
import org.elasticsearch.index.mapper.BooleanFieldMapper;
1413
import org.elasticsearch.index.mapper.DateFieldMapper;
@@ -58,7 +57,7 @@ public static Iterable<Object[]> parameters() throws Exception {
5857
// The setup section contains an unsupported option
5958
continue;
6059
}
61-
if (false == modifySection(candidate.getTestPath(), candidate.getTestSection().getExecutableSections())) {
60+
if (false == modifySection(candidate.getTestSection().getExecutableSections())) {
6261
// The test section contains an unsupported option
6362
continue;
6463
}
@@ -80,7 +79,7 @@ public static Iterable<Object[]> parameters() throws Exception {
8079
* with scripts that load from source.
8180
*/
8281
private static ClientYamlTestSuite modifiedSuite(ClientYamlTestCandidate candidate) {
83-
if (false == modifySection(candidate.getSuitePath() + "/setup", candidate.getSetupSection().getExecutableSections())) {
82+
if (false == modifySection(candidate.getSetupSection().getExecutableSections())) {
8483
return null;
8584
}
8685
List<ExecutableSection> setup = new ArrayList<>(candidate.getSetupSection().getExecutableSections().size() + 1);
@@ -99,7 +98,7 @@ private static ClientYamlTestSuite modifiedSuite(ClientYamlTestCandidate candida
9998
* Replace field configuration in {@code indices.create} with scripts
10099
* that load from the source.
101100
*/
102-
private static boolean modifySection(String sectionName, List<ExecutableSection> executables) {
101+
private static boolean modifySection(List<ExecutableSection> executables) {
103102
for (ExecutableSection section : executables) {
104103
if (false == (section instanceof DoSection)) {
105104
continue;
@@ -232,10 +231,6 @@ public void execute(ClientYamlTestExecutionContext executionContext) throws IOEx
232231
Map.entry("runtime_type", type),
233232
Map.entry("script", painlessToLoadFromSource("{name}", type))
234233
);
235-
Map<String, Object> body = Map.ofEntries(
236-
Map.entry("match_mapping_type", type.equals("keyword") ? "string" : type),
237-
Map.entry("mapping", mapping)
238-
);
239234
if (type.contentEquals("keyword")) {
240235
/*
241236
* For "string"-type dynamic mappings emulate our default
@@ -248,7 +243,6 @@ public void execute(ClientYamlTestExecutionContext executionContext) throws IOEx
248243
} else {
249244
dynamicTemplates.add(Map.of(type, Map.of("match_mapping_type", type, "mapping", mapping)));
250245
}
251-
dynamicTemplates.add(Map.of(type, body));
252246
}
253247
List<Map<String, Object>> bodies = List.of(
254248
Map.ofEntries(

0 commit comments

Comments
 (0)