Skip to content

Commit

Permalink
Fix constand_keyword test run and properly test recent behavior change (
Browse files Browse the repository at this point in the history
  • Loading branch information
lkts authored Nov 22, 2024
1 parent f325c15 commit dae59da
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public Set<NodeFeature> getFeatures() {
);
}

public static final NodeFeature CONSTANT_KEYWORD_SYNTHETIC_SOURCE_WRITE_FIX = new NodeFeature(
"mapper.constant_keyword.synthetic_source_write_fix"
);

@Override
public Set<NodeFeature> getTestFeatures() {
return Set.of(
Expand All @@ -66,7 +70,8 @@ public Set<NodeFeature> getTestFeatures() {
SourceFieldMapper.SOURCE_MODE_FROM_INDEX_SETTING,
IgnoredSourceFieldMapper.IGNORED_SOURCE_AS_TOP_LEVEL_METADATA_ARRAY_FIELD,
IgnoredSourceFieldMapper.ALWAYS_STORE_OBJECT_ARRAYS_IN_NESTED_OBJECTS,
MapperService.LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT
MapperService.LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT,
CONSTANT_KEYWORD_SYNTHETIC_SOURCE_WRITE_FIX
);
}
}
2 changes: 1 addition & 1 deletion x-pack/plugin/mapper-constant-keyword/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

apply plugin: 'elasticsearch.internal-es-plugin'
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'

esplugin {
name 'constant-keyword'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;

/** Runs yaml rest tests */
public class ConstantKeywordClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
Expand All @@ -24,4 +26,12 @@ public ConstantKeywordClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidat
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters();
}

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("constant-keyword").build();

@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
constant_keyword:
- requires:
cluster_features: [ "mapper.source.mode_from_index_setting" ]
reason: "Source mode configured through index setting"
cluster_features: [ "mapper.constant_keyword.synthetic_source_write_fix" ]
reason: "Behavior fix"

- do:
indices.create:
Expand All @@ -26,13 +26,35 @@ constant_keyword:
body:
kwd: foo

- do:
index:
index: test
id: 2
refresh: true
body:
kwd: foo
const_kwd: bar

- do:
search:
index: test
body:
query:
ids:
values: [1]

- match:
hits.hits.0._source:
kwd: foo

- do:
search:
index: test
body:
query:
ids:
values: [2]

- match:
hits.hits.0._source:
kwd: foo
Expand Down

0 comments on commit dae59da

Please sign in to comment.