Skip to content

Commit

Permalink
Exclude synthetic source test for TSDB from mixedClusterTests (#100592)
Browse files Browse the repository at this point in the history
* Don't print synthetic source in mapping for bwc tests

* Move comment.

* Don't print synthetic source in mapping for bwc tests #2

* Don't print synthetic source in mapping for bwc tests #2

* Revert "Don't print synthetic source in mapping for bwc tests #2"

This reverts commit 034262c.

* Revert "Don't print synthetic source in mapping for bwc tests #2"

This reverts commit 44e8156.

* Revert "Don't print synthetic source in mapping for bwc tests (#100572)"

This reverts commit 9322ab9.

* Exclude synthetic source test from mixedClusterTests

* Update comment.
  • Loading branch information
kkrik-es committed Oct 11, 2023
1 parent 5dc7ccc commit 24037d6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
6 changes: 6 additions & 0 deletions qa/mixed-cluster/build.gradle
Expand Up @@ -41,6 +41,12 @@ excludeList.add('aggregations/filter/Standard queries get cached')
excludeList.add('aggregations/filter/Terms lookup gets cached')
excludeList.add('aggregations/filters_bucket/cache hits')

// The test checks that tsdb mappings report source as synthetic.
// It is supposed to be skipped (not needed) for versions before
// 8.10 but mixed cluster tests may not respect that - see the
// comment above.
excludeList.add('tsdb/20_mapping/Synthetic source')

BuildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->

if (bwcVersion != VersionProperties.getElasticsearchVersion()) {
Expand Down
Expand Up @@ -101,7 +101,20 @@ public static class Builder extends MetadataFieldMapper.Builder {
(previous, current, conflicts) -> (previous.value() == current.value()) || (previous.value() && current.value() == false)
);

private final Parameter<Mode> mode;
/*
* The default mode for TimeSeries is left empty on purpose, so that mapping printings include the synthetic
* source mode.
*/
private final Parameter<Mode> mode = new Parameter<>(
"mode",
true,
() -> null,
(n, c, o) -> Mode.valueOf(o.toString().toUpperCase(Locale.ROOT)),
m -> toType(m).enabled.explicit() ? null : toType(m).mode,
(b, n, v) -> b.field(n, v.toString().toLowerCase(Locale.ROOT)),
v -> v.toString().toLowerCase(Locale.ROOT)
).setMergeValidator((previous, current, conflicts) -> (previous == current) || current != Mode.STORED)
.setSerializerCheck((includeDefaults, isConfigured, value) -> value != null); // don't emit if `enabled` is configured
private final Parameter<List<String>> includes = Parameter.stringArrayParam(
"includes",
false,
Expand All @@ -115,22 +128,9 @@ public static class Builder extends MetadataFieldMapper.Builder {

private final IndexMode indexMode;

public Builder(IndexMode indexMode, IndexVersion indexVersion) {
public Builder(IndexMode indexMode) {
super(Defaults.NAME);
this.indexMode = indexMode;
this.mode = new Parameter<>(
"mode",
true,
// The default mode for TimeSeries is left empty on purpose, so that mapping printings include the synthetic source mode.
() -> getIndexMode() == IndexMode.TIME_SERIES && indexVersion.between(IndexVersion.V_8_7_0, IndexVersion.V_8_10_0)
? Mode.SYNTHETIC
: null,
(n, c, o) -> Mode.valueOf(o.toString().toUpperCase(Locale.ROOT)),
m -> toType(m).enabled.explicit() ? null : toType(m).mode,
(b, n, v) -> b.field(n, v.toString().toLowerCase(Locale.ROOT)),
v -> v.toString().toLowerCase(Locale.ROOT)
).setMergeValidator((previous, current, conflicts) -> (previous == current) || current != Mode.STORED)
.setSerializerCheck((includeDefaults, isConfigured, value) -> value != null); // don't emit if `enabled` is configured
}

public Builder setSynthetic() {
Expand Down Expand Up @@ -188,7 +188,7 @@ private IndexMode getIndexMode() {
c -> c.getIndexSettings().getMode() == IndexMode.TIME_SERIES
? c.getIndexSettings().getIndexVersionCreated().onOrAfter(IndexVersion.V_8_7_0) ? TSDB_DEFAULT : TSDB_LEGACY_DEFAULT
: DEFAULT,
c -> new Builder(c.getIndexSettings().getMode(), c.getIndexSettings().getIndexVersionCreated())
c -> new Builder(c.getIndexSettings().getMode())
);

static final class SourceFieldType extends MappedFieldType {
Expand Down Expand Up @@ -313,7 +313,7 @@ protected String contentType() {

@Override
public FieldMapper.Builder getMergeBuilder() {
return new Builder(indexMode, IndexVersion.current()).init(this);
return new Builder(indexMode).init(this);
}

/**
Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentParser;
Expand Down Expand Up @@ -240,10 +238,4 @@ public void testSyntheticSourceInTimeSeries() throws IOException {
assertTrue(mapper.sourceMapper().isSynthetic());
assertEquals("{\"_source\":{\"mode\":\"synthetic\"}}", mapper.sourceMapper().toString());
}

public void testSyntheticSourceInTimeSeriesBwc() throws IOException {
SourceFieldMapper sourceMapper = new SourceFieldMapper.Builder(IndexMode.TIME_SERIES, IndexVersion.V_8_8_0).build();
assertTrue(sourceMapper.isSynthetic());
assertEquals("{\"_source\":{\"mode\":\"synthetic\"}}", sourceMapper.toString());
}
}
Expand Up @@ -381,7 +381,7 @@ public void testSearchRequestRuntimeFieldsAndMultifieldDetection() {

public void testSyntheticSourceSearchLookup() throws IOException {
// Build a mapping using synthetic source
SourceFieldMapper sourceMapper = new SourceFieldMapper.Builder(null, IndexVersion.current()).setSynthetic().build();
SourceFieldMapper sourceMapper = new SourceFieldMapper.Builder(null).setSynthetic().build();
RootObjectMapper root = new RootObjectMapper.Builder("_doc", Explicit.IMPLICIT_TRUE).add(
new KeywordFieldMapper.Builder("cat", IndexVersion.current()).ignoreAbove(100)
).build(MapperBuilderContext.root(true, false));
Expand Down

0 comments on commit 24037d6

Please sign in to comment.