Skip to content

Commit

Permalink
Add test for index settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarouli committed Jan 17, 2025
1 parent 741d07b commit f72357e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.function.BiFunction;
import java.util.function.Function;

import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_PREFIX;

/**
* Index-specific deprecation checks
*/
Expand Down Expand Up @@ -132,7 +134,7 @@ static DeprecationIssue frozenIndexSettingCheck(IndexMetadata indexMetadata, Clu
}

static DeprecationIssue legacyTierRoutingCheck(IndexMetadata indexMetadata, ClusterState clusterState) {
String nodeAttrDataValue = indexMetadata.getSettings().get("index.routing.allocation.require.data");
String nodeAttrDataValue = indexMetadata.getSettings().get(INDEX_ROUTING_INCLUDE_GROUP_PREFIX + ".data");
if (nodeAttrDataValue == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_PREFIX;
import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING;
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.INDEX_SETTINGS_CHECKS;
import static org.hamcrest.Matchers.empty;
Expand Down Expand Up @@ -234,6 +235,33 @@ public void testFrozenIndex() {
);
}

public void testLegacyTierRouting() {
Settings.Builder settings = settings(IndexVersion.current());
String dataValue = randomAlphanumericOfLength(10);
settings.put(INDEX_ROUTING_INCLUDE_GROUP_PREFIX + ".data", dataValue);
IndexMetadata indexMetadata = IndexMetadata.builder("test").settings(settings).numberOfShards(1).numberOfReplicas(0).build();
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(
INDEX_SETTINGS_CHECKS,
c -> c.apply(indexMetadata, ClusterState.EMPTY_STATE)
);
assertThat(
issues,
contains(
new DeprecationIssue(
DeprecationIssue.Level.WARNING,
"index [test] has configured 'index.routing.allocation.require.data: "
+ dataValue
+ "'. This setting is not recommended to be used for setting tiers.",
"https://ela.st/es-deprecation-7-node-attr-data-setting",
"One or more of your indices is configured with index.routing.allocation.require.data settings. This is"
+ " typically used to create a hot/warm or tiered architecture, based on legacy guidelines. Data tiers are a recommended replacement for tiered architecture clusters.",
false,
null
)
)
);
}

public void testCamelCaseDeprecation() throws IOException {
String simpleMapping = "{\n\"_doc\": {"
+ "\"properties\" : {\n"
Expand Down

0 comments on commit f72357e

Please sign in to comment.