Skip to content

Fix TimeSeriesLifecycleActionsIT.testRolloverAlreadyExists #48747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<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"));
});
}

Expand Down Expand Up @@ -1071,15 +1074,20 @@ private Map<String, Object> getOnlyIndexSettings(String index) throws IOExceptio
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);
}

Expand All @@ -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<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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public void testRunPolicyErrorStepOnRetryableFailedStep() {
RolloverAction action = RolloverActionTests.randomInstance();
actions.put(RolloverAction.NAME, action);
Phase phase = new Phase(phaseName, after, actions);
Map<String, Phase> phases = Map.of(phaseName, phase);
PhaseExecutionInfo phaseExecutionInfo = new PhaseExecutionInfo(policyName, phase, 1, randomNonNegativeLong());
String phaseJson = Strings.toString(phaseExecutionInfo);
NoOpClient client = new NoOpClient(threadPool);
Expand Down