diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java index 41fa16e9f4624..653608b731d38 100644 --- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java +++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java @@ -154,7 +154,6 @@ public void testScaleFromEmptyLegacy() { putAutoscalingPolicy("hot", DataTier.DATA_HOT); putAutoscalingPolicy("warm", DataTier.DATA_WARM); putAutoscalingPolicy("cold", DataTier.DATA_COLD); - putAutoscalingPolicy("content", DataTier.DATA_CONTENT); // add an index using `_id` allocation to check that it does not trigger spinning up the tier. assertAcked( @@ -181,6 +180,10 @@ public void testScaleFromEmptyLegacy() { .build() ) ); + + // the tier preference will have defaulted to data_content, set it back to null + updateIndexSettings(indexName, Settings.builder().putNull(DataTier.TIER_PREFERENCE)); + refresh(indexName); assertThat(capacity().results().get("warm").requiredCapacity().total().storage().getBytes(), Matchers.equalTo(0L)); assertThat(capacity().results().get("cold").requiredCapacity().total().storage().getBytes(), Matchers.equalTo(0L)); @@ -196,12 +199,9 @@ public void testScaleFromEmptyLegacy() { .actionGet() ); - // since we always enforce a default tier preference, this index wants to be on data_content, regardless of `data_tier: warm` above - assertThat(capacity().results().get("content").requiredCapacity().total().storage().getBytes(), Matchers.greaterThan(0L)); - - // and doesn't care about warm or cold - assertThat(capacity().results().get("warm").requiredCapacity().total().storage().getBytes(), Matchers.equalTo(0L)); - assertThat(capacity().results().get("cold").requiredCapacity().total().storage().getBytes(), Matchers.equalTo(0L)); + assertThat(capacity().results().get("warm").requiredCapacity().total().storage().getBytes(), Matchers.greaterThan(0L)); + // this is not desirable, but one of the caveats of not using data tiers in the ILM policy. + assertThat(capacity().results().get("cold").requiredCapacity().total().storage().getBytes(), Matchers.greaterThan(0L)); } /** diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java index 1dd3c643c508a..d9f3f5ac996ff 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java @@ -137,12 +137,16 @@ public void testMigrateToDataTiersAction() throws Exception { for (int i = 1; i <= 2; i++) { // assign the rollover-only policy to a few other indices - these indices will end up getting caught by the catch-all // tier preference migration - createIndexWithSettings(client(), rolloverIndexPrefix + "-00000" + i, alias + i, Settings.builder() + String rolloverIndex = rolloverIndexPrefix + "-00000" + i; + createIndexWithSettings(client(), rolloverIndex, alias + i, Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .putNull(DataTier.TIER_PREFERENCE) // since we always enforce a tier preference, this will be ignored (i.e. data_content) .put(RolloverAction.LIFECYCLE_ROLLOVER_ALIAS, alias + i) ); + + // the tier preference will have defaulted to data_content, set it back to null + updateIndexSettings(rolloverIndex, Settings.builder().putNull(DataTier.TIER_PREFERENCE)); } // let's stop ILM so we can perform the migration @@ -159,6 +163,9 @@ public void testMigrateToDataTiersAction() throws Exception { .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "data", "warm"); createIndex(indexWithDataWarmRouting, settings.build()); + // the tier preference will have defaulted to data_content, set it back to null + updateIndexSettings(indexWithDataWarmRouting, Settings.builder().putNull(DataTier.TIER_PREFERENCE)); + Request migrateRequest = new Request("POST", "_ilm/migrate_to_data_tiers"); migrateRequest.setJsonEntity( "{\"legacy_template_to_delete\": \"" + templateName + "\", \"node_attribute\": \"data\"}" @@ -170,7 +177,7 @@ public void testMigrateToDataTiersAction() throws Exception { assertThat((List) migrateResponseAsMap.get(MigrateToDataTiersResponse.MIGRATED_ILM_POLICIES.getPreferredName()), contains(policy)); assertThat((List) migrateResponseAsMap.get(MigrateToDataTiersResponse.MIGRATED_INDICES.getPreferredName()), - containsInAnyOrder(index, indexWithDataWarmRouting)); + containsInAnyOrder(index, indexWithDataWarmRouting, rolloverIndexPrefix + "-000001", rolloverIndexPrefix + "-000002")); assertThat(migrateResponseAsMap.get(MigrateToDataTiersResponse.REMOVED_LEGACY_TEMPLATE.getPreferredName()), is(templateName)); @@ -178,10 +185,10 @@ public void testMigrateToDataTiersAction() throws Exception { Request getTemplateRequest = new Request("HEAD", "_template/" + templateName); assertThat(client().performRequest(getTemplateRequest).getStatusLine().getStatusCode(), is(RestStatus.NOT_FOUND.getStatus())); - // regardless of require.data:warm configuration the "indexWithDataWarmRouting", we enforced a default tier preference, - // so this is data_content + // let's assert the require.data:warm configuration the "indexWithDataWarmRouting" had was migrated to + // _tier_preference:data_warm,data_hot Map indexSettings = getOnlyIndexSettings(client(), indexWithDataWarmRouting); - assertThat(indexSettings.get(DataTier.TIER_PREFERENCE), is(DataTier.DATA_CONTENT)); + assertThat(indexSettings.get(DataTier.TIER_PREFERENCE), is("data_warm,data_hot")); // let's retrieve the migrated policy and check it was migrated correctly - namely the warm phase should not contain any allocate // action anymore and the cold phase should contain an allocate action that only configures the number of replicas @@ -271,6 +278,9 @@ public void testMigrationDryRun() throws Exception { .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "data", "warm"); createIndex(indexWithDataWarmRouting, settings.build()); + // the tier preference will have defaulted to data_content, set it back to null + updateIndexSettings(indexWithDataWarmRouting, Settings.builder().putNull(DataTier.TIER_PREFERENCE)); + Request migrateRequest = new Request("POST", "_ilm/migrate_to_data_tiers"); migrateRequest.addParameter("dry_run", "true"); migrateRequest.setJsonEntity( @@ -293,10 +303,9 @@ public void testMigrationDryRun() throws Exception { Request getTemplateRequest = new Request("HEAD", "_template/" + templateName); assertThat(client().performRequest(getTemplateRequest).getStatusLine().getStatusCode(), is(RestStatus.OK.getStatus())); - // the index settings will contain a tier preference, regardless of this being a dry run, - // because we always enforce a tier preference being set (so the null above is overridden when the index is created) + // the index settings should not contain the _tier_preference Map indexSettings = getOnlyIndexSettings(client(), indexWithDataWarmRouting); - assertThat(indexSettings.get(DataTier.TIER_PREFERENCE), is(DataTier.DATA_CONTENT)); + assertThat(indexSettings.get(DataTier.TIER_PREFERENCE), nullValue()); // let's check the ILM policy was not migrated - ie. the warm phase still contains the allocate action Request getPolicy = new Request("GET", "/_ilm/policy/" + policy);