* 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(client(), originalIndex, "_id", "foo", "bar");
|
||||
assertBusy(() -> {
|
||||
logger.info(originalIndex + ": " + getStepKeyForIndex(originalIndex));
|
||||
Map<String, Object> 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<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");
|
||||
}
|
||||
|
||||
|
||||
public static StepKey getStepKeyForIndex(String indexName) throws IOException {
|
||||
Map<String, Object> 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<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);
|
||||
}
|
||||
|
||||
|
@ -1116,14 +1124,6 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|||
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 {
|
||||
return explain(indexName, false, false).get(indexName);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue