Skip to content

Commit dae59da

Browse files
authored
Fix constand_keyword test run and properly test recent behavior change (#117284)
1 parent f325c15 commit dae59da

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
@@ -57,6 +57,10 @@ public Set<NodeFeature> getFeatures() {
5757
);
5858
}
5959

60+
public static final NodeFeature CONSTANT_KEYWORD_SYNTHETIC_SOURCE_WRITE_FIX = new NodeFeature(
61+
"mapper.constant_keyword.synthetic_source_write_fix"
62+
);
63+
6064
@Override
6165
public Set<NodeFeature> getTestFeatures() {
6266
return Set.of(
@@ -66,7 +70,8 @@ public Set<NodeFeature> getTestFeatures() {
6670
SourceFieldMapper.SOURCE_MODE_FROM_INDEX_SETTING,
6771
IgnoredSourceFieldMapper.IGNORED_SOURCE_AS_TOP_LEVEL_METADATA_ARRAY_FIELD,
6872
IgnoredSourceFieldMapper.ALWAYS_STORE_OBJECT_ARRAYS_IN_NESTED_OBJECTS,
69-
MapperService.LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT
73+
MapperService.LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT,
74+
CONSTANT_KEYWORD_SYNTHETIC_SOURCE_WRITE_FIX
7075
);
7176
}
7277
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
apply plugin: 'elasticsearch.internal-es-plugin'
9-
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
9+
apply plugin: 'elasticsearch.internal-yaml-rest-test'
1010

1111
esplugin {
1212
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)