Skip to content

Commit

Permalink
Broaden index versions tested in some mappings tests (elastic#119026)
Browse files Browse the repository at this point in the history
MINIMUM_READONLY_COMPATIBLE is used as a lower bound (N-2) as opposed to
MINIMUM_COMPATIBLE (N-1).
  • Loading branch information
javanna authored Dec 19, 2024
1 parent 93aee0f commit d103036
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ public void testBlankFieldName() throws Exception {
}

public void testBlankFieldNameBefore8_6_0() throws Exception {
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.MINIMUM_COMPATIBLE, IndexVersions.V_8_5_0);
IndexVersion version = IndexVersionUtils.randomVersionBetween(
random(),
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersions.V_8_5_0
);
TransportVersion transportVersion = TransportVersionUtils.randomVersionBetween(
random(),
TransportVersions.MINIMUM_COMPATIBLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.indices;

import org.elasticsearch.core.UpdateForV9;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.mapper.DataStreamTimestampFieldMapper;
Expand Down Expand Up @@ -98,8 +97,6 @@ public Map<String, MetadataFieldMapper.TypeParser> getMetadataMappers() {
DataStreamTimestampFieldMapper.NAME,
FieldNamesFieldMapper.NAME };

@UpdateForV9(owner = UpdateForV9.Owner.SEARCH_FOUNDATIONS)
@AwaitsFix(bugUrl = "test is referencing 7.x index versions so needs to be updated for 9.0 bump")
public void testBuiltinMappers() {
IndicesModule module = new IndicesModule(Collections.emptyList());
{
Expand Down Expand Up @@ -239,14 +236,14 @@ public Map<String, MetadataFieldMapper.TypeParser> getMetadataMappers() {

public void testFieldNamesIsLast() {
IndicesModule module = new IndicesModule(Collections.emptyList());
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current());
IndexVersion version = IndexVersionUtils.randomVersion();
List<String> fieldNames = new ArrayList<>(module.getMapperRegistry().getMetadataMapperParsers(version).keySet());
assertEquals(FieldNamesFieldMapper.NAME, fieldNames.get(fieldNames.size() - 1));
}

public void testFieldNamesIsLastWithPlugins() {
IndicesModule module = new IndicesModule(fakePlugins);
IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.MINIMUM_COMPATIBLE, IndexVersion.current());
IndexVersion version = IndexVersionUtils.randomVersion();
List<String> fieldNames = new ArrayList<>(module.getMapperRegistry().getMetadataMapperParsers(version).keySet());
assertEquals(FieldNamesFieldMapper.NAME, fieldNames.get(fieldNames.size() - 1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ public void testDefaultConfiguration() throws IOException {
}

public void testDefaultDocValueConfigurationOnPre8_4() throws IOException {
// TODO verify which version this test is actually valid for (when PR is actually merged)
IndexVersion oldVersion = IndexVersionUtils.randomVersionBetween(random(), IndexVersions.MINIMUM_COMPATIBLE, IndexVersions.V_8_3_0);
IndexVersion oldVersion = IndexVersionUtils.randomVersionBetween(
random(),
IndexVersions.MINIMUM_READONLY_COMPATIBLE,
IndexVersions.V_8_3_0
);
DocumentMapper defaultMapper = createDocumentMapper(oldVersion, fieldMapping(this::minimalMapping));
Mapper fieldMapper = defaultMapper.mappers().getMapper(FIELD_NAME);
assertThat(fieldMapper, instanceOf(fieldMapperClass()));
Expand Down

0 comments on commit d103036

Please sign in to comment.