Skip to content

remove old doc placeholder and migrate ilm docs to top-level #34615

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 17 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
@@ -1,3 +1,4 @@
[role="xpack"]
[[get-index-lifecycle-information]]
== Get index lifecycle information

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[role="xpack"]
[[getting-started-index-lifecycle-management]]
== Getting started with {ilm}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[role="xpack"]
[testenv="basic"]
[[index-lifecycle-management]]
= Managing Indices

Expand Down Expand Up @@ -66,4 +68,4 @@ include::get-index-lifecycle-information.asciidoc[]
include::pause-resume-ilm.asciidoc[]

:edit_url: https://github.com/elastic/elasticsearch/edit/{branch}/x-pack/docs/en/ilm/apis/ilm-api.asciidoc
include::{xes-repo-dir}/ilm/apis/ilm-api.asciidoc[]
include::{es-repo-dir}/ilm/apis/ilm-api.asciidoc[]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[role="xpack"]
[testenv="basic"]
[[pause-resume-ilm]]
== Pause and resume {ilm}
ILM can be skipped on a per-index basis
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[role="xpack"]
[testenv="basic"]
[[set-up-lifecycle-policy]]
== Set up {ilm} policy

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[role="xpack"]
[testenv="basic"]
[[update-lifecycle-policy]]
== Update lifecycle policy

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[role="xpack"]
[testenv="basic"]
[[using-policies-rollover]]
== Using policies to manage index rollover

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ include::index-modules.asciidoc[]

include::ingest.asciidoc[]

include::{xes-repo-dir}/ilm/index.asciidoc[]
include::ilm/index.asciidoc[]

include::sql/index.asciidoc[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ protected static RestClient adminClient() {
/**
* Returns whether to preserve the state of the cluster upon completion of this test. Defaults to false. If true, overrides the value of
* {@link #preserveIndicesUponCompletion()}, {@link #preserveTemplatesUponCompletion()}, {@link #preserveReposUponCompletion()},
* {@link #preserveSnapshotsUponCompletion()}, and {@link #preserveRollupJobsUponCompletion()}.
* {@link #preserveSnapshotsUponCompletion()},{@link #preserveRollupJobsUponCompletion()},
* and {@link #preserveILMPoliciesUponCompletion()}.
*
* @return true if the state of the cluster should be preserved
*/
Expand Down Expand Up @@ -275,6 +276,15 @@ protected boolean preserveRollupJobsUponCompletion() {
return false;
}

/**
* Returns whether to preserve ILM Policies of this test. Defaults to not
* preserviing them. Only runs at all if xpack is installed on the cluster
* being tested.
*/
protected boolean preserveILMPoliciesUponCompletion() {
return false;
}

private void wipeCluster() throws Exception {
boolean hasXPack = hasXPack();

Expand Down Expand Up @@ -329,6 +339,11 @@ private void wipeCluster() throws Exception {
wipeRollupJobs();
waitForPendingRollupTasks();
}

if (hasXPack && false == preserveILMPoliciesUponCompletion()) {
removePoliciesFromAllIndexes();
deleteAllPolicies();
}
}

/**
Expand Down Expand Up @@ -441,6 +456,46 @@ private void waitForPendingRollupTasks() throws Exception {
});
}

private static void removePoliciesFromAllIndexes() throws IOException {
Response response = adminClient().performRequest(new Request("GET", "/_all"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll usually have wiped the indices already. Do we need to do this in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you're right. this is unnecessary

Map<String, Object> indexes = ESRestTestCase.entityAsMap(response);

if (indexes == null || indexes.isEmpty()) {
return;
}

for (String indexName : indexes.keySet()) {
try {
adminClient().performRequest(new Request("DELETE", indexName + "/_ilm/"));
} catch (Exception e) {
// ok
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK because we're racing? Maybe we should add the ignore parameter to the request in that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're really only ok with 404s here, right?

}
}
}

private static void deleteAllPolicies() throws Exception {
Map<String, Object> policies;

try {
Response response = adminClient().performRequest(new Request("GET", "/_ilm"));
policies = ESRestTestCase.entityAsMap(response);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are already in ESRestTestCase so you don't need the to reference the class.

} catch (Exception e) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit broad.

}

if (policies == null || policies.isEmpty()) {
return;
}

for (String policyName : policies.keySet()) {
try {
adminClient().performRequest(new Request("DELETE", "/_ilm/" + policyName));
} catch (Exception e) {
// ok
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as before about why this is ok.

}
}
}

/**
* Logs a message if there are still running tasks. The reasoning is that any tasks still running are state the is trying to bleed into
* other tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ protected boolean preserveClusterSettings() {
protected boolean preserveRollupJobsUponCompletion() {
return true;
}

@Override
protected boolean preserveILMPoliciesUponCompletion() {
return true;
}
}
Empty file.
Empty file.
Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.elasticsearch.test.rest.yaml.ObjectPath;
import org.elasticsearch.xpack.core.indexlifecycle.ILMRestTestStateCleaner;
import org.elasticsearch.xpack.core.ml.MlMetaIndex;
import org.elasticsearch.xpack.core.ml.integration.MlRestTestStateCleaner;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
Expand Down Expand Up @@ -245,7 +244,6 @@ private void disableMonitoring() throws Exception {
public void cleanup() throws Exception {
disableMonitoring();
clearMlState();
clearILMState();
if (isWaitForPendingTasks()) {
// This waits for pending tasks to complete, so must go last (otherwise
// it could be waiting for pending tasks while monitoring is still running).
Expand All @@ -265,20 +263,6 @@ private void clearMlState() throws Exception {
}
}

private void clearILMState() throws Exception {
if (isILMTest()) {
ILMRestTestStateCleaner.clearILMMetadata(adminClient());
}
}

/**

private void clearILMState() throws Exception {
if (isILMTest()) {
ILMRestTestStateCleaner.clearILMMetadata(adminClient());
}
}

/**
* Executes an API call using the admin context, waiting for it to succeed.
*/
Expand Down Expand Up @@ -339,12 +323,6 @@ protected boolean isMachineLearningTest() {
return testName != null && (testName.contains("=ml/") || testName.contains("=ml\\"));
}

protected boolean isILMTest() {
String testName = getTestName();
return testName != null && (testName.contains("=ilm/") || testName.contains("=ilm\\"))
|| (testName.contains("/ilm/") || testName.contains("\\ilm\\"));
}

/**
* Should each test wait for pending tasks to finish after execution?
* @return Wait for pending tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ protected boolean preserveRollupJobsUponCompletion() {
return true;
}

@Override
protected boolean preserveILMPoliciesUponCompletion() {
return true;
}

enum CLUSTER_TYPE {
OLD,
MIXED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ protected boolean preserveRollupJobsUponCompletion() {
return true;
}

@Override
protected boolean preserveILMPoliciesUponCompletion() {
return true;
}

enum ClusterType {
OLD,
MIXED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ protected boolean preserveRollupJobsUponCompletion() {
return true;
}

@Override
protected boolean preserveILMPoliciesUponCompletion() {
return true;
}

public UpgradeClusterClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}
Expand Down