Skip to content

Commit 98a9227

Browse files
authored
Fix TimeSeriesLifecycleActionsIT.testRolloverAlreadyExists (#48747) (#48795)
* 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 44c74bb) Signed-off-by: Andrei Dan <[email protected]>
1 parent 1f662e0 commit 98a9227

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,14 @@ public void testRolloverAlreadyExists() throws Exception {
312312
// index another doc to trigger the policy
313313
index(client(), originalIndex, "_id", "foo", "bar");
314314
assertBusy(() -> {
315-
logger.info(originalIndex + ": " + getStepKeyForIndex(originalIndex));
315+
Map<String, Object> explainIndexResponse = explainIndex(originalIndex);
316+
logger.info(originalIndex + ": " + getStepKey(explainIndexResponse));
316317
logger.info(secondIndex + ": " + getStepKeyForIndex(secondIndex));
317-
assertThat(getStepKeyForIndex(originalIndex), equalTo(new StepKey("hot", RolloverAction.NAME, ErrorStep.NAME)));
318-
assertThat(getFailedStepForIndex(originalIndex), equalTo(WaitForRolloverReadyStep.NAME));
319-
assertThat(getReasonForIndex(originalIndex), containsString("already exists"));
318+
assertThat(getStepKey(explainIndexResponse), equalTo(new StepKey("hot", RolloverAction.NAME, ErrorStep.NAME)));
319+
assertThat(explainIndexResponse.get("failed_step"), equalTo(WaitForRolloverReadyStep.NAME));
320+
@SuppressWarnings("unchecked")
321+
String reason = ((Map<String, String>) explainIndexResponse.get("step_info")).get("reason");
322+
assertThat(reason, containsString("already exists"));
320323
});
321324
}
322325

@@ -1097,15 +1100,20 @@ private Map<String, Object> getOnlyIndexSettings(String index) throws IOExceptio
10971100
return (Map<String, Object>) response.get("settings");
10981101
}
10991102

1103+
11001104
public static StepKey getStepKeyForIndex(String indexName) throws IOException {
11011105
Map<String, Object> indexResponse = explainIndex(indexName);
11021106
if (indexResponse == null) {
11031107
return new StepKey(null, null, null);
11041108
}
11051109

1106-
String phase = (String) indexResponse.get("phase");
1107-
String action = (String) indexResponse.get("action");
1108-
String step = (String) indexResponse.get("step");
1110+
return getStepKey(indexResponse);
1111+
}
1112+
1113+
private static StepKey getStepKey(Map<String, Object> explainIndexResponse) {
1114+
String phase = (String) explainIndexResponse.get("phase");
1115+
String action = (String) explainIndexResponse.get("action");
1116+
String step = (String) explainIndexResponse.get("step");
11091117
return new StepKey(phase, action, step);
11101118
}
11111119

@@ -1116,14 +1124,6 @@ private String getFailedStepForIndex(String indexName) throws IOException {
11161124
return (String) indexResponse.get("failed_step");
11171125
}
11181126

1119-
@SuppressWarnings("unchecked")
1120-
private String getReasonForIndex(String indexName) throws IOException {
1121-
Map<String, Object> indexResponse = explainIndex(indexName);
1122-
if (indexResponse == null) return null;
1123-
1124-
return ((Map<String, String>) indexResponse.get("step_info")).get("reason");
1125-
}
1126-
11271127
private static Map<String, Object> explainIndex(String indexName) throws IOException {
11281128
return explain(indexName, false, false).get(indexName);
11291129
}

0 commit comments

Comments
 (0)