diff --git a/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java b/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java index 4f6c450ed99d5..4d9a535e498fe 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java @@ -312,11 +312,14 @@ public void testRolloverAlreadyExists() throws Exception { // index another doc to trigger the policy index(client(), originalIndex, "_id", "foo", "bar"); assertBusy(() -> { - logger.info(originalIndex + ": " + getStepKeyForIndex(originalIndex)); + Map explainIndexResponse = explainIndex(originalIndex); + logger.info(originalIndex + ": " + getStepKey(explainIndexResponse)); logger.info(secondIndex + ": " + getStepKeyForIndex(secondIndex)); - assertThat(getStepKeyForIndex(originalIndex), equalTo(new StepKey("hot", RolloverAction.NAME, ErrorStep.NAME))); - assertThat(getFailedStepForIndex(originalIndex), equalTo(WaitForRolloverReadyStep.NAME)); - assertThat(getReasonForIndex(originalIndex), containsString("already exists")); + assertThat(getStepKey(explainIndexResponse), equalTo(new StepKey("hot", RolloverAction.NAME, ErrorStep.NAME))); + assertThat(explainIndexResponse.get("failed_step"), equalTo(WaitForRolloverReadyStep.NAME)); + @SuppressWarnings("unchecked") + String reason = ((Map) explainIndexResponse.get("step_info")).get("reason"); + assertThat(reason, containsString("already exists")); }); } @@ -1071,15 +1074,20 @@ private Map getOnlyIndexSettings(String index) throws IOExceptio return (Map) response.get("settings"); } + public static StepKey getStepKeyForIndex(String indexName) throws IOException { Map indexResponse = explainIndex(indexName); if (indexResponse == null) { return new StepKey(null, null, null); } - String phase = (String) indexResponse.get("phase"); - String action = (String) indexResponse.get("action"); - String step = (String) indexResponse.get("step"); + return getStepKey(indexResponse); + } + + private static StepKey getStepKey(Map explainIndexResponse) { + String phase = (String) explainIndexResponse.get("phase"); + String action = (String) explainIndexResponse.get("action"); + String step = (String) explainIndexResponse.get("step"); return new StepKey(phase, action, step); } @@ -1090,14 +1098,6 @@ private String getFailedStepForIndex(String indexName) throws IOException { return (String) indexResponse.get("failed_step"); } - @SuppressWarnings("unchecked") - private String getReasonForIndex(String indexName) throws IOException { - Map indexResponse = explainIndex(indexName); - if (indexResponse == null) return null; - - return ((Map) indexResponse.get("step_info")).get("reason"); - } - private static Map explainIndex(String indexName) throws IOException { return explain(indexName, false, false).get(indexName); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunnerTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunnerTests.java index 7d5f00f589013..26adcb65a773a 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunnerTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleRunnerTests.java @@ -214,7 +214,6 @@ public void testRunPolicyErrorStepOnRetryableFailedStep() { RolloverAction action = RolloverActionTests.randomInstance(); actions.put(RolloverAction.NAME, action); Phase phase = new Phase(phaseName, after, actions); - Map phases = Map.of(phaseName, phase); PhaseExecutionInfo phaseExecutionInfo = new PhaseExecutionInfo(policyName, phase, 1, randomNonNegativeLong()); String phaseJson = Strings.toString(phaseExecutionInfo); NoOpClient client = new NoOpClient(threadPool);