|
@@ -7,39 +7,61 @@
|
|
|
|
|
|
|
|
package org.elasticsearch.xpack.ilm;
|
|
package org.elasticsearch.xpack.ilm;
|
|
|
|
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.cluster.ClusterName;
|
|
import org.elasticsearch.cluster.ClusterName;
|
|
|
import org.elasticsearch.cluster.ClusterState;
|
|
import org.elasticsearch.cluster.ClusterState;
|
|
|
|
|
+import org.elasticsearch.cluster.metadata.IndexMetadata;
|
|
|
import org.elasticsearch.cluster.metadata.Metadata;
|
|
import org.elasticsearch.cluster.metadata.Metadata;
|
|
|
import org.elasticsearch.cluster.service.ClusterService;
|
|
import org.elasticsearch.cluster.service.ClusterService;
|
|
|
|
|
+import org.elasticsearch.common.bytes.BytesReference;
|
|
|
|
|
+import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
|
|
|
|
+import org.elasticsearch.health.Diagnosis;
|
|
|
import org.elasticsearch.health.HealthIndicatorImpact;
|
|
import org.elasticsearch.health.HealthIndicatorImpact;
|
|
|
import org.elasticsearch.health.HealthIndicatorResult;
|
|
import org.elasticsearch.health.HealthIndicatorResult;
|
|
|
import org.elasticsearch.health.ImpactArea;
|
|
import org.elasticsearch.health.ImpactArea;
|
|
|
import org.elasticsearch.health.SimpleHealthIndicatorDetails;
|
|
import org.elasticsearch.health.SimpleHealthIndicatorDetails;
|
|
|
import org.elasticsearch.health.node.HealthInfo;
|
|
import org.elasticsearch.health.node.HealthInfo;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
|
|
+import org.elasticsearch.xcontent.ToXContent;
|
|
|
|
|
+import org.elasticsearch.xcontent.XContentBuilder;
|
|
|
|
|
+import org.elasticsearch.xcontent.XContentFactory;
|
|
|
|
|
+import org.elasticsearch.xcontent.XContentParser;
|
|
|
|
|
+import org.elasticsearch.xcontent.XContentType;
|
|
|
import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
|
|
import org.elasticsearch.xpack.core.ilm.IndexLifecycleMetadata;
|
|
|
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
|
|
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
|
|
|
import org.elasticsearch.xpack.core.ilm.LifecyclePolicyMetadata;
|
|
import org.elasticsearch.xpack.core.ilm.LifecyclePolicyMetadata;
|
|
|
|
|
+import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
+import static org.elasticsearch.cluster.metadata.LifecycleExecutionState.ILM_CUSTOM_METADATA_KEY;
|
|
|
import static org.elasticsearch.health.HealthStatus.GREEN;
|
|
import static org.elasticsearch.health.HealthStatus.GREEN;
|
|
|
import static org.elasticsearch.health.HealthStatus.YELLOW;
|
|
import static org.elasticsearch.health.HealthStatus.YELLOW;
|
|
|
import static org.elasticsearch.xpack.core.ilm.OperationMode.RUNNING;
|
|
import static org.elasticsearch.xpack.core.ilm.OperationMode.RUNNING;
|
|
|
import static org.elasticsearch.xpack.core.ilm.OperationMode.STOPPED;
|
|
import static org.elasticsearch.xpack.core.ilm.OperationMode.STOPPED;
|
|
|
import static org.elasticsearch.xpack.core.ilm.OperationMode.STOPPING;
|
|
import static org.elasticsearch.xpack.core.ilm.OperationMode.STOPPING;
|
|
|
import static org.elasticsearch.xpack.ilm.IlmHealthIndicatorService.NAME;
|
|
import static org.elasticsearch.xpack.ilm.IlmHealthIndicatorService.NAME;
|
|
|
|
|
+import static org.elasticsearch.xpack.ilm.IlmHealthIndicatorService.RULES_BY_ACTION_CONFIG;
|
|
|
|
|
+import static org.elasticsearch.xpack.ilm.IlmHealthIndicatorService.STAGNATING_ACTION_DEFINITIONS;
|
|
|
|
|
+import static org.hamcrest.Matchers.containsInAnyOrder;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
|
|
+import static org.hamcrest.Matchers.hasSize;
|
|
|
import static org.mockito.Mockito.mock;
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
+import static org.mockito.Mockito.times;
|
|
|
|
|
+import static org.mockito.Mockito.verify;
|
|
|
|
|
+import static org.mockito.Mockito.verifyNoInteractions;
|
|
|
import static org.mockito.Mockito.when;
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
|
|
|
|
|
- public void testIsGreenWhenRunningAndPoliciesConfigured() {
|
|
|
|
|
|
|
+ public void testIsGreenWhenRunningAndPoliciesConfiguredAndNoStagnatingIndices() {
|
|
|
var clusterState = createClusterStateWith(new IndexLifecycleMetadata(createIlmPolicy(), RUNNING));
|
|
var clusterState = createClusterStateWith(new IndexLifecycleMetadata(createIlmPolicy(), RUNNING));
|
|
|
- var service = createIlmHealthIndicatorService(clusterState);
|
|
|
|
|
|
|
+ var stagnatingIndicesFinder = mockedStagnatingIndicesFinder(List.of());
|
|
|
|
|
+ var service = createIlmHealthIndicatorService(clusterState, stagnatingIndicesFinder);
|
|
|
|
|
|
|
|
assertThat(
|
|
assertThat(
|
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
@@ -48,18 +70,143 @@ public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
NAME,
|
|
NAME,
|
|
|
GREEN,
|
|
GREEN,
|
|
|
"Index Lifecycle Management is running",
|
|
"Index Lifecycle Management is running",
|
|
|
- new SimpleHealthIndicatorDetails(Map.of("ilm_status", RUNNING, "policies", 1)),
|
|
|
|
|
- Collections.emptyList(),
|
|
|
|
|
- Collections.emptyList()
|
|
|
|
|
|
|
+ new SimpleHealthIndicatorDetails(Map.of("ilm_status", RUNNING, "policies", 1, "stagnating_indices", 0)),
|
|
|
|
|
+ List.of(),
|
|
|
|
|
+ List.of()
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
|
|
+ verify(stagnatingIndicesFinder, times(1)).find();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void testIsYellowIfThereIsOneStagnatingIndicesAndDetailsEmptyIfNoVerbose() throws IOException {
|
|
|
|
|
+ var clusterState = createClusterStateWith(new IndexLifecycleMetadata(createIlmPolicy(), RUNNING));
|
|
|
|
|
+ var action = randomAction();
|
|
|
|
|
+ var policyName = randomAlphaOfLength(10);
|
|
|
|
|
+ var indexName = randomAlphaOfLength(10);
|
|
|
|
|
+ var stagnatingIndicesFinder = mockedStagnatingIndicesFinder(List.of(indexMetadata(indexName, policyName, action)));
|
|
|
|
|
+ var service = createIlmHealthIndicatorService(clusterState, stagnatingIndicesFinder);
|
|
|
|
|
+
|
|
|
|
|
+ var indicatorResult = service.calculate(false, HealthInfo.EMPTY_HEALTH_INFO);
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(indicatorResult.name(), NAME);
|
|
|
|
|
+ assertEquals(indicatorResult.status(), YELLOW);
|
|
|
|
|
+ assertEquals(indicatorResult.symptom(), "An index has stayed on the same action longer than expected.");
|
|
|
|
|
+ assertEquals(xContentToMap(indicatorResult.details()), Map.of());
|
|
|
|
|
+ assertThat(indicatorResult.impacts(), hasSize(1));
|
|
|
|
|
+ assertThat(
|
|
|
|
|
+ indicatorResult.impacts().get(0),
|
|
|
|
|
+ equalTo(
|
|
|
|
|
+ new HealthIndicatorImpact(
|
|
|
|
|
+ NAME,
|
|
|
|
|
+ IlmHealthIndicatorService.STAGNATING_INDEX_IMPACT_ID,
|
|
|
|
|
+ 3,
|
|
|
|
|
+ "Automatic index lifecycle and data retention management cannot make progress on one or more indices. "
|
|
|
|
|
+ + "The performance and stability of the indices and/or the cluster could be impacted.",
|
|
|
|
|
+ List.of(ImpactArea.DEPLOYMENT_MANAGEMENT)
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ assertThat(indicatorResult.diagnosisList(), hasSize(1));
|
|
|
|
|
+ assertEquals(indicatorResult.diagnosisList().get(0).definition(), STAGNATING_ACTION_DEFINITIONS.get(action));
|
|
|
|
|
+
|
|
|
|
|
+ var affectedResources = indicatorResult.diagnosisList().get(0).affectedResources();
|
|
|
|
|
+ assertThat(affectedResources, hasSize(2));
|
|
|
|
|
+ assertEquals(affectedResources.get(0).getType(), Diagnosis.Resource.Type.ILM_POLICY);
|
|
|
|
|
+ assertThat(affectedResources.get(0).getValues(), hasSize(1));
|
|
|
|
|
+ assertThat(affectedResources.get(0).getValues(), containsInAnyOrder(policyName));
|
|
|
|
|
+ assertThat(affectedResources.get(1).getValues(), hasSize(1));
|
|
|
|
|
+ assertEquals(affectedResources.get(1).getType(), Diagnosis.Resource.Type.INDEX);
|
|
|
|
|
+ assertThat(affectedResources.get(1).getValues(), containsInAnyOrder(indexName));
|
|
|
|
|
+
|
|
|
|
|
+ verify(stagnatingIndicesFinder, times(1)).find();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void testIsYellowIfThereIsOneStagnatingIndices() throws IOException {
|
|
|
|
|
+ var clusterState = createClusterStateWith(new IndexLifecycleMetadata(createIlmPolicy(), RUNNING));
|
|
|
|
|
+ var action = randomAction();
|
|
|
|
|
+ var policyName = randomAlphaOfLength(10);
|
|
|
|
|
+ var indexName = randomAlphaOfLength(10);
|
|
|
|
|
+ var stagnatingIndicesFinder = mockedStagnatingIndicesFinder(List.of(indexMetadata(indexName, policyName, action)));
|
|
|
|
|
+ var service = createIlmHealthIndicatorService(clusterState, stagnatingIndicesFinder);
|
|
|
|
|
+
|
|
|
|
|
+ var indicatorResult = service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO);
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(indicatorResult.name(), NAME);
|
|
|
|
|
+ assertEquals(indicatorResult.status(), YELLOW);
|
|
|
|
|
+ assertEquals(indicatorResult.symptom(), "An index has stayed on the same action longer than expected.");
|
|
|
|
|
+ var expectedILMSummary = new HashMap<>();
|
|
|
|
|
+ // Uncomment next line after https://github.com/elastic/elasticsearch/issues/96705 is fixed
|
|
|
|
|
+ // expectedILMSummary.put("downsample", 0);
|
|
|
|
|
+ expectedILMSummary.put("allocate", 0);
|
|
|
|
|
+ expectedILMSummary.put("shrink", 0);
|
|
|
|
|
+ expectedILMSummary.put("searchable_snapshot", 0);
|
|
|
|
|
+ expectedILMSummary.put("rollover", 0);
|
|
|
|
|
+ expectedILMSummary.put("forcemerge", 0);
|
|
|
|
|
+ expectedILMSummary.put("delete", 0);
|
|
|
|
|
+ expectedILMSummary.put("migrate", 0);
|
|
|
|
|
+ expectedILMSummary.put(action, 1);
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(
|
|
|
|
|
+ xContentToMap(indicatorResult.details()),
|
|
|
|
|
+ Map.of(
|
|
|
|
|
+ "policies",
|
|
|
|
|
+ 1,
|
|
|
|
|
+ "ilm_status",
|
|
|
|
|
+ RUNNING.toString(),
|
|
|
|
|
+ "stagnating_indices",
|
|
|
|
|
+ 1,
|
|
|
|
|
+ "stagnating_indices_per_action",
|
|
|
|
|
+ expectedILMSummary
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ assertThat(indicatorResult.impacts(), hasSize(1));
|
|
|
|
|
+ assertThat(
|
|
|
|
|
+ indicatorResult.impacts().get(0),
|
|
|
|
|
+ equalTo(
|
|
|
|
|
+ new HealthIndicatorImpact(
|
|
|
|
|
+ NAME,
|
|
|
|
|
+ IlmHealthIndicatorService.STAGNATING_INDEX_IMPACT_ID,
|
|
|
|
|
+ 3,
|
|
|
|
|
+ "Automatic index lifecycle and data retention management cannot make progress on one or more indices. "
|
|
|
|
|
+ + "The performance and stability of the indices and/or the cluster could be impacted.",
|
|
|
|
|
+ List.of(ImpactArea.DEPLOYMENT_MANAGEMENT)
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
+ assertThat(indicatorResult.diagnosisList(), hasSize(1));
|
|
|
|
|
+ assertEquals(indicatorResult.diagnosisList().get(0).definition(), STAGNATING_ACTION_DEFINITIONS.get(action));
|
|
|
|
|
+
|
|
|
|
|
+ var affectedResources = indicatorResult.diagnosisList().get(0).affectedResources();
|
|
|
|
|
+ assertThat(affectedResources, hasSize(2));
|
|
|
|
|
+ assertEquals(affectedResources.get(0).getType(), Diagnosis.Resource.Type.ILM_POLICY);
|
|
|
|
|
+ assertThat(affectedResources.get(0).getValues(), hasSize(1));
|
|
|
|
|
+ assertThat(affectedResources.get(0).getValues(), containsInAnyOrder(policyName));
|
|
|
|
|
+ assertThat(affectedResources.get(1).getValues(), hasSize(1));
|
|
|
|
|
+ assertEquals(affectedResources.get(1).getType(), Diagnosis.Resource.Type.INDEX);
|
|
|
|
|
+ assertThat(affectedResources.get(1).getValues(), containsInAnyOrder(indexName));
|
|
|
|
|
+
|
|
|
|
|
+ verify(stagnatingIndicesFinder, times(1)).find();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String randomAction() {
|
|
|
|
|
+ return randomFrom(RULES_BY_ACTION_CONFIG.keySet());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static IndexMetadata indexMetadata(String indexName, String policyName, String action) {
|
|
|
|
|
+ return IndexMetadata.builder(indexName)
|
|
|
|
|
+ .settings(settings(Version.CURRENT).put(LifecycleSettings.LIFECYCLE_NAME, policyName))
|
|
|
|
|
+ .putCustom(ILM_CUSTOM_METADATA_KEY, Map.of("action", action))
|
|
|
|
|
+ .numberOfShards(randomIntBetween(1, 5))
|
|
|
|
|
+ .numberOfReplicas(randomIntBetween(0, 5))
|
|
|
|
|
+ .build();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void testIsYellowWhenNotRunningAndPoliciesConfigured() {
|
|
public void testIsYellowWhenNotRunningAndPoliciesConfigured() {
|
|
|
var status = randomFrom(STOPPED, STOPPING);
|
|
var status = randomFrom(STOPPED, STOPPING);
|
|
|
var clusterState = createClusterStateWith(new IndexLifecycleMetadata(createIlmPolicy(), status));
|
|
var clusterState = createClusterStateWith(new IndexLifecycleMetadata(createIlmPolicy(), status));
|
|
|
- var service = createIlmHealthIndicatorService(clusterState);
|
|
|
|
|
|
|
+ var stagnatingIndicesFinder = mockedStagnatingIndicesFinder(List.of());
|
|
|
|
|
+ var service = createIlmHealthIndicatorService(clusterState, stagnatingIndicesFinder);
|
|
|
|
|
|
|
|
assertThat(
|
|
assertThat(
|
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
@@ -68,7 +215,7 @@ public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
NAME,
|
|
NAME,
|
|
|
YELLOW,
|
|
YELLOW,
|
|
|
"Index Lifecycle Management is not running",
|
|
"Index Lifecycle Management is not running",
|
|
|
- new SimpleHealthIndicatorDetails(Map.of("ilm_status", status, "policies", 1)),
|
|
|
|
|
|
|
+ new SimpleHealthIndicatorDetails(Map.of("ilm_status", status, "policies", 1, "stagnating_indices", 0)),
|
|
|
Collections.singletonList(
|
|
Collections.singletonList(
|
|
|
new HealthIndicatorImpact(
|
|
new HealthIndicatorImpact(
|
|
|
NAME,
|
|
NAME,
|
|
@@ -83,12 +230,14 @@ public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
|
|
+ verifyNoInteractions(stagnatingIndicesFinder);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void testIsGreenWhenNotRunningAndNoPolicies() {
|
|
public void testIsGreenWhenNotRunningAndNoPolicies() {
|
|
|
var status = randomFrom(STOPPED, STOPPING);
|
|
var status = randomFrom(STOPPED, STOPPING);
|
|
|
var clusterState = createClusterStateWith(new IndexLifecycleMetadata(Map.of(), status));
|
|
var clusterState = createClusterStateWith(new IndexLifecycleMetadata(Map.of(), status));
|
|
|
- var service = createIlmHealthIndicatorService(clusterState);
|
|
|
|
|
|
|
+ var stagnatingIndicesFinder = mockedStagnatingIndicesFinder(List.of());
|
|
|
|
|
+ var service = createIlmHealthIndicatorService(clusterState, stagnatingIndicesFinder);
|
|
|
|
|
|
|
|
assertThat(
|
|
assertThat(
|
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
@@ -97,17 +246,19 @@ public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
NAME,
|
|
NAME,
|
|
|
GREEN,
|
|
GREEN,
|
|
|
"No Index Lifecycle Management policies configured",
|
|
"No Index Lifecycle Management policies configured",
|
|
|
- new SimpleHealthIndicatorDetails(Map.of("ilm_status", status, "policies", 0)),
|
|
|
|
|
- Collections.emptyList(),
|
|
|
|
|
- Collections.emptyList()
|
|
|
|
|
|
|
+ new SimpleHealthIndicatorDetails(Map.of("ilm_status", status, "policies", 0, "stagnating_indices", 0)),
|
|
|
|
|
+ List.of(),
|
|
|
|
|
+ List.of()
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
|
|
+ verifyNoInteractions(stagnatingIndicesFinder);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void testIsGreenWhenNoMetadata() {
|
|
public void testIsGreenWhenNoMetadata() {
|
|
|
var clusterState = createClusterStateWith(null);
|
|
var clusterState = createClusterStateWith(null);
|
|
|
- var service = createIlmHealthIndicatorService(clusterState);
|
|
|
|
|
|
|
+ var stagnatingIndicesFinder = mockedStagnatingIndicesFinder(List.of());
|
|
|
|
|
+ var service = createIlmHealthIndicatorService(clusterState, stagnatingIndicesFinder);
|
|
|
|
|
|
|
|
assertThat(
|
|
assertThat(
|
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
service.calculate(true, HealthInfo.EMPTY_HEALTH_INFO),
|
|
@@ -116,12 +267,13 @@ public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
NAME,
|
|
NAME,
|
|
|
GREEN,
|
|
GREEN,
|
|
|
"No Index Lifecycle Management policies configured",
|
|
"No Index Lifecycle Management policies configured",
|
|
|
- new SimpleHealthIndicatorDetails(Map.of("ilm_status", RUNNING, "policies", 0)),
|
|
|
|
|
- Collections.emptyList(),
|
|
|
|
|
- Collections.emptyList()
|
|
|
|
|
|
|
+ new SimpleHealthIndicatorDetails(Map.of("ilm_status", RUNNING, "policies", 0, "stagnating_indices", 0)),
|
|
|
|
|
+ List.of(),
|
|
|
|
|
+ List.of()
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
|
|
+ verifyNoInteractions(stagnatingIndicesFinder);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// We expose the indicator name and the diagnoses in the x-pack usage API. In order to index them properly in a telemetry index
|
|
// We expose the indicator name and the diagnoses in the x-pack usage API. In order to index them properly in a telemetry index
|
|
@@ -132,6 +284,21 @@ public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
IlmHealthIndicatorService.ILM_NOT_RUNNING.definition().getUniqueId(),
|
|
IlmHealthIndicatorService.ILM_NOT_RUNNING.definition().getUniqueId(),
|
|
|
equalTo("elasticsearch:health:ilm:diagnosis:ilm_disabled")
|
|
equalTo("elasticsearch:health:ilm:diagnosis:ilm_disabled")
|
|
|
);
|
|
);
|
|
|
|
|
+ var definitionIds = STAGNATING_ACTION_DEFINITIONS.values().stream().map(Diagnosis.Definition::getUniqueId).toList();
|
|
|
|
|
+
|
|
|
|
|
+ assertThat(
|
|
|
|
|
+ definitionIds,
|
|
|
|
|
+ containsInAnyOrder(
|
|
|
|
|
+ "elasticsearch:health:ilm:diagnosis:stagnating_action:rollover",
|
|
|
|
|
+ "elasticsearch:health:ilm:diagnosis:stagnating_action:migrate",
|
|
|
|
|
+ "elasticsearch:health:ilm:diagnosis:stagnating_action:searchable_snapshot",
|
|
|
|
|
+ "elasticsearch:health:ilm:diagnosis:stagnating_action:delete",
|
|
|
|
|
+ "elasticsearch:health:ilm:diagnosis:stagnating_action:shrink",
|
|
|
|
|
+ "elasticsearch:health:ilm:diagnosis:stagnating_action:forcemerge",
|
|
|
|
|
+ "elasticsearch:health:ilm:diagnosis:stagnating_action:allocate"
|
|
|
|
|
+ // "elasticsearch:health:ilm:diagnosis:stagnating_action:downsample"
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private static ClusterState createClusterStateWith(IndexLifecycleMetadata metadata) {
|
|
private static ClusterState createClusterStateWith(IndexLifecycleMetadata metadata) {
|
|
@@ -149,9 +316,27 @@ public class IlmHealthIndicatorServiceTests extends ESTestCase {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private static IlmHealthIndicatorService createIlmHealthIndicatorService(ClusterState clusterState) {
|
|
|
|
|
|
|
+ private static IlmHealthIndicatorService createIlmHealthIndicatorService(
|
|
|
|
|
+ ClusterState clusterState,
|
|
|
|
|
+ IlmHealthIndicatorService.StagnatingIndicesFinder stagnatingIndicesFinder
|
|
|
|
|
+ ) {
|
|
|
var clusterService = mock(ClusterService.class);
|
|
var clusterService = mock(ClusterService.class);
|
|
|
when(clusterService.state()).thenReturn(clusterState);
|
|
when(clusterService.state()).thenReturn(clusterState);
|
|
|
- return new IlmHealthIndicatorService(clusterService);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return new IlmHealthIndicatorService(clusterService, stagnatingIndicesFinder);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static IlmHealthIndicatorService.StagnatingIndicesFinder mockedStagnatingIndicesFinder(List<IndexMetadata> states) {
|
|
|
|
|
+ var finder = mock(IlmHealthIndicatorService.StagnatingIndicesFinder.class);
|
|
|
|
|
+ when(finder.find()).thenReturn(states);
|
|
|
|
|
+ return finder;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Map<String, Object> xContentToMap(ToXContent xcontent) throws IOException {
|
|
|
|
|
+ XContentBuilder builder = XContentFactory.jsonBuilder();
|
|
|
|
|
+ xcontent.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
|
|
|
|
+ XContentParser parser = XContentType.JSON.xContent()
|
|
|
|
|
+ .createParser(xContentRegistry(), LoggingDeprecationHandler.INSTANCE, BytesReference.bytes(builder).streamInput());
|
|
|
|
|
+ return parser.map();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|