Skip to content

Commit 4220d0b

Browse files
authored
Fix constand_keyword test run and properly test recent behavior change (#117284) (#117371)
1 parent 7062a48 commit 4220d0b

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

server/src/main/java/org/elasticsearch/index/mapper/MapperFeatures.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public Set<NodeFeature> getFeatures() {
5151
);
5252
}
5353

54+
public static final NodeFeature CONSTANT_KEYWORD_SYNTHETIC_SOURCE_WRITE_FIX = new NodeFeature(
55+
"mapper.constant_keyword.synthetic_source_write_fix"
56+
);
57+
5458
@Override
5559
public Set<NodeFeature> getTestFeatures() {
5660
return Set.of(
@@ -59,7 +63,8 @@ public Set<NodeFeature> getTestFeatures() {
5963
SourceFieldMapper.REMOVE_SYNTHETIC_SOURCE_ONLY_VALIDATION,
6064
SourceFieldMapper.SOURCE_MODE_FROM_INDEX_SETTING,
6165
IgnoredSourceFieldMapper.ALWAYS_STORE_OBJECT_ARRAYS_IN_NESTED_OBJECTS,
62-
MapperService.LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT
66+
MapperService.LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT,
67+
CONSTANT_KEYWORD_SYNTHETIC_SOURCE_WRITE_FIX
6368
);
6469
}
6570
}

x-pack/plugin/mapper-constant-keyword/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.elasticsearch.gradle.internal.info.BuildParams
22

33
apply plugin: 'elasticsearch.internal-es-plugin'
4-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
4+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
55

66
esplugin {
77
name 'constant-keyword'

x-pack/plugin/mapper-constant-keyword/src/yamlRestTest/java/org/elasticsearch/xpack/constantkeyword/ConstantKeywordClientYamlTestSuiteIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import com.carrotsearch.randomizedtesting.annotations.Name;
1111
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1212

13+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1314
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1415
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
16+
import org.junit.ClassRule;
1517

1618
/** Runs yaml rest tests */
1719
public class ConstantKeywordClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@@ -24,4 +26,12 @@ public ConstantKeywordClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidat
2426
public static Iterable<Object[]> parameters() throws Exception {
2527
return ESClientYamlSuiteTestCase.createParameters();
2628
}
29+
30+
@ClassRule
31+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("constant-keyword").build();
32+
33+
@Override
34+
protected String getTestRestCluster() {
35+
return cluster.getHttpAddresses();
36+
}
2737
}

x-pack/plugin/mapper-constant-keyword/src/yamlRestTest/resources/rest-api-spec/test/20_synthetic_source.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
constant_keyword:
22
- requires:
3-
cluster_features: [ "mapper.source.mode_from_index_setting" ]
4-
reason: "Source mode configured through index setting"
3+
cluster_features: [ "mapper.constant_keyword.synthetic_source_write_fix" ]
4+
reason: "Behavior fix"
55

66
- do:
77
indices.create:
@@ -26,13 +26,35 @@ constant_keyword:
2626
body:
2727
kwd: foo
2828

29+
- do:
30+
index:
31+
index: test
32+
id: 2
33+
refresh: true
34+
body:
35+
kwd: foo
36+
const_kwd: bar
37+
2938
- do:
3039
search:
3140
index: test
3241
body:
3342
query:
3443
ids:
3544
values: [1]
45+
46+
- match:
47+
hits.hits.0._source:
48+
kwd: foo
49+
50+
- do:
51+
search:
52+
index: test
53+
body:
54+
query:
55+
ids:
56+
values: [2]
57+
3658
- match:
3759
hits.hits.0._source:
3860
kwd: foo

0 commit comments

Comments
 (0)