* ILM Test asserts on the same ilm/_explain output With the introduction of retryable steps subsequent ilm/_explain calls can see the state of an ilm cycle move out of the error step. This test made several assertions assuming that the cycle remains in the error step so this commit changes the test to make one _explain call and have all the asserts work on the same ilm state (so subsequent assumptions to the cycle being in the error step are valid). * Drop unused field in test. (cherry picked from commit 44c74bb487151c886a08b27f32b13f7a72056997) Signed-off-by: Andrei Dan <andrei.dan@elastic.co>
This commit is contained in:
parent
1f662e0b12
commit
98a9227588
|
@ -312,11 +312,14 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
||||||
// index another doc to trigger the policy
|
// index another doc to trigger the policy
|
||||||
index(client(), originalIndex, "_id", "foo", "bar");
|
index(client(), originalIndex, "_id", "foo", "bar");
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
logger.info(originalIndex + ": " + getStepKeyForIndex(originalIndex));
|
Map<String, Object> explainIndexResponse = explainIndex(originalIndex);
|
||||||
|
logger.info(originalIndex + ": " + getStepKey(explainIndexResponse));
|
||||||
logger.info(secondIndex + ": " + getStepKeyForIndex(secondIndex));
|
logger.info(secondIndex + ": " + getStepKeyForIndex(secondIndex));
|
||||||
assertThat(getStepKeyForIndex(originalIndex), equalTo(new StepKey("hot", RolloverAction.NAME, ErrorStep.NAME)));
|
assertThat(getStepKey(explainIndexResponse), equalTo(new StepKey("hot", RolloverAction.NAME, ErrorStep.NAME)));
|
||||||
assertThat(getFailedStepForIndex(originalIndex), equalTo(WaitForRolloverReadyStep.NAME));
|
assertThat(explainIndexResponse.get("failed_step"), equalTo(WaitForRolloverReadyStep.NAME));
|
||||||
assertThat(getReasonForIndex(originalIndex), containsString("already exists"));
|
@SuppressWarnings("unchecked")
|
||||||
|
String reason = ((Map<String, String>) explainIndexResponse.get("step_info")).get("reason");
|
||||||
|
assertThat(reason, containsString("already exists"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1097,15 +1100,20 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
||||||
return (Map<String, Object>) response.get("settings");
|
return (Map<String, Object>) response.get("settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static StepKey getStepKeyForIndex(String indexName) throws IOException {
|
public static StepKey getStepKeyForIndex(String indexName) throws IOException {
|
||||||
Map<String, Object> indexResponse = explainIndex(indexName);
|
Map<String, Object> indexResponse = explainIndex(indexName);
|
||||||
if (indexResponse == null) {
|
if (indexResponse == null) {
|
||||||
return new StepKey(null, null, null);
|
return new StepKey(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
String phase = (String) indexResponse.get("phase");
|
return getStepKey(indexResponse);
|
||||||
String action = (String) indexResponse.get("action");
|
}
|
||||||
String step = (String) indexResponse.get("step");
|
|
||||||
|
private static StepKey getStepKey(Map<String, Object> 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);
|
return new StepKey(phase, action, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,14 +1124,6 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
||||||
return (String) indexResponse.get("failed_step");
|
return (String) indexResponse.get("failed_step");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private String getReasonForIndex(String indexName) throws IOException {
|
|
||||||
Map<String, Object> indexResponse = explainIndex(indexName);
|
|
||||||
if (indexResponse == null) return null;
|
|
||||||
|
|
||||||
return ((Map<String, String>) indexResponse.get("step_info")).get("reason");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<String, Object> explainIndex(String indexName) throws IOException {
|
private static Map<String, Object> explainIndex(String indexName) throws IOException {
|
||||||
return explain(indexName, false, false).get(indexName);
|
return explain(indexName, false, false).get(indexName);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue