-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add test for deprecated index settings in N-2 indices #122493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cbuescher
merged 17 commits into
elastic:main
from
cbuescher:add-RollingUpgradeDeprecatedSettingsIT
Mar 4, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ef0305e
WIP
cbuescher 906a560
iter
cbuescher 36b3e12
Merge branch 'main' into add-RollingUpgradeDeprecatedSettingsIT
cbuescher 648578a
[CI] Auto commit changes from spotless
4caf15a
Mute org.elasticsearch.lucene.RollingUpgradeLuceneIndexCompatibilityT…
elasticsearchmachine a8d7689
Mute org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCo…
elasticsearchmachine 13a0528
Mute org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCo…
elasticsearchmachine ed14baa
Mute org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCo…
elasticsearchmachine 56a7693
Mute org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCo…
elasticsearchmachine 953561e
Mute org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCo…
elasticsearchmachine 48161d1
Mute org.elasticsearch.lucene.RollingUpgradeSearchableSnapshotIndexCo…
elasticsearchmachine 3c9a53f
Add missing transport versions (#122506)
gmarouli 556304e
Merge branch 'main' into add-RollingUpgradeDeprecatedSettingsIT
cbuescher 6cf016b
Merge branch 'main' into add-RollingUpgradeDeprecatedSettingsIT
cbuescher ad9cdeb
Lift some common test code to shared parent class§
cbuescher 1ffd1fb
Merge branch 'main' into add-RollingUpgradeDeprecatedSettingsIT
cbuescher 98e78c9
Merge branch 'main' into add-RollingUpgradeDeprecatedSettingsIT
cbuescher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
...ty/src/javaRestTest/java/org/elasticsearch/lucene/RollingUpgradeDeprecatedSettingsIT.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.lucene; | ||
|
|
||
| import io.netty.handler.codec.http.HttpMethod; | ||
|
|
||
| import org.apache.http.HttpHost; | ||
| import org.elasticsearch.client.Request; | ||
| import org.elasticsearch.client.RestClient; | ||
| import org.elasticsearch.client.RestClientBuilder; | ||
| import org.elasticsearch.cluster.metadata.IndexMetadata; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.index.IndexSettings; | ||
| import org.elasticsearch.index.mapper.MapperService; | ||
| import org.elasticsearch.index.store.Store; | ||
| import org.elasticsearch.test.cluster.util.Version; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
|
|
||
| import static org.hamcrest.Matchers.equalTo; | ||
|
|
||
| public class RollingUpgradeDeprecatedSettingsIT extends RollingUpgradeIndexCompatibilityTestCase { | ||
|
|
||
| static { | ||
| clusterConfig = config -> config.setting("xpack.license.self_generated.type", "trial"); | ||
| } | ||
|
|
||
| public RollingUpgradeDeprecatedSettingsIT(List<Version> nodesVersions) { | ||
| super(nodesVersions); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an index on N-2, upgrades to N -1 and marks as read-only, then remains searchable during rolling upgrades. | ||
| */ | ||
| @SuppressWarnings("deprecation") | ||
| public void testIndexUpgrade() throws Exception { | ||
| final String index = suffix("index-rolling-upgraded"); | ||
| final int numDocs = 2543; | ||
|
|
||
| // setup index with deprecated index settings on N-2 | ||
| if (isFullyUpgradedTo(VERSION_MINUS_2)) { | ||
| createIndexLenient( | ||
| client(), | ||
| index, | ||
| Settings.builder() | ||
| .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) | ||
| .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) | ||
| // add some index settings deprecated in v7 | ||
| .put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), true) | ||
| .put(IndexSettings.MAX_ADJACENCY_MATRIX_FILTERS_SETTING.getKey(), 100) | ||
| .put(Store.FORCE_RAM_TERM_DICT.getKey(), false) | ||
| .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false) | ||
| .build() | ||
| ); | ||
| indexDocs(index, numDocs); | ||
| return; | ||
| } | ||
| assertThat(indexVersion(index), equalTo(VERSION_MINUS_2)); | ||
| ensureGreen(index); | ||
|
|
||
| if (isIndexClosed(index) == false) { | ||
| assertDocCount(client(), index, numDocs); | ||
| } | ||
|
|
||
| if (isFullyUpgradedTo(VERSION_MINUS_1)) { | ||
| final var maybeClose = randomBoolean(); | ||
| if (maybeClose) { | ||
| logger.debug("--> closing index [{}] before upgrade", index); | ||
| closeIndex(index); | ||
| } | ||
|
|
||
| addAndAssertIndexBlocks(index, maybeClose); | ||
| return; | ||
| } | ||
|
|
||
| if (nodesVersions().values().stream().anyMatch(v -> v.onOrAfter(VERSION_CURRENT))) { | ||
| final var isClosed = isIndexClosed(index); | ||
| assertAndModifyIndexBlocks(index, isClosed); | ||
| ensureWriteBlock(index, isClosed); | ||
|
|
||
| if (isClosed) { | ||
| logger.debug("--> re-opening index [{}] after upgrade", index); | ||
| openIndex(index); | ||
| ensureGreen(index); | ||
| } | ||
|
|
||
| assertThat(indexVersion(index), equalTo(VERSION_MINUS_2)); | ||
| assertDocCount(client(), index, numDocs); | ||
|
|
||
| updateRandomIndexSettings(index); | ||
| updateRandomMappings(index); | ||
|
|
||
| if (randomBoolean()) { | ||
| logger.debug("--> random closing of index [{}] before upgrade", index); | ||
| closeIndex(index); | ||
| ensureGreen(index); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static void createIndexLenient(RestClient client, String name, Settings settings) throws IOException { | ||
| final Request request = newXContentRequest(HttpMethod.PUT, "/" + name, (builder, params) -> { | ||
| builder.startObject("settings"); | ||
| settings.toXContent(builder, params); | ||
| builder.endObject(); | ||
| return builder; | ||
| }); | ||
| client.performRequest(request); | ||
| } | ||
|
|
||
| /** | ||
| * Builds a REST client that will tolerate warnings in the response headers. The default | ||
| * is to throw an exception. | ||
| */ | ||
| @Override | ||
| protected RestClient buildClient(Settings settings, HttpHost[] hosts) throws IOException { | ||
| RestClientBuilder builder = RestClient.builder(hosts); | ||
| configureClient(builder, settings); | ||
| builder.setStrictDeprecationMode(false); | ||
| return builder.build(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth checking the behavior of each deprecated setting? For example, to verify that a new field is added to the mapping when
index. mapper.dynamic: true, etc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, any of these settings shouldn't be used any longer and most of the times we're not even evaluating their setting in production code anywhere (e.g. "index.mapper.dynamic" hasn't been used since #109160 but having the setting in the mapping has created issues in the past). This test merely should assure that we tolerate any of these settings when moving to 9 but not necessarily that any legacy functionality attached to them is still working (which most of the time isn't)