|
@@ -1358,10 +1358,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|
|
assertBusy(() -> assertThat(getStepKeyForIndex(originalIndex), equalTo(PhaseCompleteStep.finalStep("hot").getKey())));
|
|
|
}
|
|
|
|
|
|
- @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50353")
|
|
|
public void testHistoryIsWrittenWithSuccess() throws Exception {
|
|
|
- String index = "success-index";
|
|
|
-
|
|
|
createNewSingletonPolicy("hot", new RolloverAction(null, null, 1L));
|
|
|
Request createIndexTemplate = new Request("PUT", "_template/rolling_indexes");
|
|
|
createIndexTemplate.setJsonEntity("{" +
|
|
@@ -1375,10 +1372,7 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|
|
"}");
|
|
|
client().performRequest(createIndexTemplate);
|
|
|
|
|
|
- createIndexWithSettings(index + "-1",
|
|
|
- Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0),
|
|
|
- true);
|
|
|
+ createIndexWithSettings(index + "-1", Settings.builder(), true);
|
|
|
|
|
|
// Index a document
|
|
|
index(client(), index + "-1", "1", "foo", "bar");
|
|
@@ -1396,69 +1390,34 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|
|
assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", true, "wait-for-yellow-step"), 30, TimeUnit.SECONDS);
|
|
|
assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", true, "check-rollover-ready"), 30, TimeUnit.SECONDS);
|
|
|
assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", true, "attempt-rollover"), 30, TimeUnit.SECONDS);
|
|
|
- assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", true, "update-rollover-lifecycle-date"), 30, TimeUnit.SECONDS);
|
|
|
assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", true, "set-indexing-complete"), 30, TimeUnit.SECONDS);
|
|
|
- assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", true, "completed"), 30, TimeUnit.SECONDS);
|
|
|
+ assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", true, "complete"), 30, TimeUnit.SECONDS);
|
|
|
|
|
|
assertBusy(() -> assertHistoryIsPresent(policy, index + "-000002", true, "check-rollover-ready"), 30, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
- @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50353")
|
|
|
public void testHistoryIsWrittenWithFailure() throws Exception {
|
|
|
- String index = "failure-index";
|
|
|
-
|
|
|
+ createIndexWithSettings(index + "-1", Settings.builder(), false);
|
|
|
createNewSingletonPolicy("hot", new RolloverAction(null, null, 1L));
|
|
|
- Request createIndexTemplate = new Request("PUT", "_template/rolling_indexes");
|
|
|
- createIndexTemplate.setJsonEntity("{" +
|
|
|
- "\"index_patterns\": [\""+ index + "-*\"], \n" +
|
|
|
- " \"settings\": {\n" +
|
|
|
- " \"number_of_shards\": 1,\n" +
|
|
|
- " \"number_of_replicas\": 0,\n" +
|
|
|
- " \"index.lifecycle.name\": \"" + policy+ "\"\n" +
|
|
|
- " }\n" +
|
|
|
- "}");
|
|
|
- client().performRequest(createIndexTemplate);
|
|
|
-
|
|
|
- createIndexWithSettings(index + "-1",
|
|
|
- Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0),
|
|
|
- false);
|
|
|
+ updatePolicy(index + "-1", policy);
|
|
|
|
|
|
// Index a document
|
|
|
index(client(), index + "-1", "1", "foo", "bar");
|
|
|
Request refreshIndex = new Request("POST", "/" + index + "-1/_refresh");
|
|
|
client().performRequest(refreshIndex);
|
|
|
|
|
|
- assertBusy(() -> assertThat(getStepKeyForIndex(index + "-1").getName(), equalTo(ErrorStep.NAME)));
|
|
|
+ assertBusy(() -> assertThat(getStepKeyForIndex(index + "-1").getName(), equalTo(ErrorStep.NAME)), 30, TimeUnit.SECONDS);
|
|
|
|
|
|
assertBusy(() -> assertHistoryIsPresent(policy, index + "-1", false, "ERROR"), 30, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
- @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50353")
|
|
|
public void testHistoryIsWrittenWithDeletion() throws Exception {
|
|
|
- String index = "delete-index";
|
|
|
-
|
|
|
- createNewSingletonPolicy("delete", new DeleteAction());
|
|
|
- Request createIndexTemplate = new Request("PUT", "_template/delete_indexes");
|
|
|
- createIndexTemplate.setJsonEntity("{" +
|
|
|
- "\"index_patterns\": [\""+ index + "\"], \n" +
|
|
|
- " \"settings\": {\n" +
|
|
|
- " \"number_of_shards\": 1,\n" +
|
|
|
- " \"number_of_replicas\": 0,\n" +
|
|
|
- " \"index.lifecycle.name\": \"" + policy+ "\"\n" +
|
|
|
- " }\n" +
|
|
|
- "}");
|
|
|
- client().performRequest(createIndexTemplate);
|
|
|
-
|
|
|
// Index should be created and then deleted by ILM
|
|
|
createIndexWithSettings(index, Settings.builder(), false);
|
|
|
+ createNewSingletonPolicy("delete", new DeleteAction());
|
|
|
+ updatePolicy(index, policy);
|
|
|
|
|
|
- assertBusy(() -> {
|
|
|
- logger.info("--> checking for index deletion...");
|
|
|
- Request existCheck = new Request("HEAD", "/" + index);
|
|
|
- Response resp = client().performRequest(existCheck);
|
|
|
- assertThat(resp.getStatusLine().getStatusCode(), equalTo(404));
|
|
|
- });
|
|
|
+ assertBusy(() -> assertFalse(indexExists(index)));
|
|
|
|
|
|
assertBusy(() -> {
|
|
|
assertHistoryIsPresent(policy, index, true, "delete", "delete", "wait-for-shard-history-leases");
|
|
@@ -1593,7 +1552,6 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|
|
// This method should be called inside an assertBusy, it has no retry logic of its own
|
|
|
private void assertHistoryIsPresent(String policyName, String indexName, boolean success,
|
|
|
@Nullable String phase, @Nullable String action, String stepName) throws IOException {
|
|
|
- assertOK(client().performRequest(new Request("POST", indexName + "/_refresh")));
|
|
|
logger.info("--> checking for history item [{}], [{}], success: [{}], phase: [{}], action: [{}], step: [{}]",
|
|
|
policyName, indexName, success, phase, action, stepName);
|
|
|
final Request historySearchRequest = new Request("GET", "ilm-history*/_search?expand_wildcards=all");
|