Unmute and increase logging on flaky SLM tests (#48612)
The failures in these tests have been remarkably difficult to track down, in part because they will not reproduce locally. This commit unmutes the flaky tests and increases logging, as well as introducing some additional logging, to attempt to pin down the failures.
This commit is contained in:
parent
1de49d8a70
commit
50d7424e7d
|
@ -7,7 +7,6 @@
|
||||||
package org.elasticsearch.xpack.slm;
|
package org.elasticsearch.xpack.slm;
|
||||||
|
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
|
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
|
||||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
|
@ -27,6 +26,7 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
|
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
|
||||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
|
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
|
||||||
import org.elasticsearch.xpack.core.ilm.Step;
|
import org.elasticsearch.xpack.core.ilm.Step;
|
||||||
|
@ -195,6 +195,8 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@TestIssueLogging(value = "org.elasticsearch.xpack.slm:TRACE,org.elasticsearch.xpack.core.slm:TRACE,org.elasticsearch.snapshots:DEBUG",
|
||||||
|
issueUrl = "https://github.com/elastic/elasticsearch/issues/48531")
|
||||||
public void testPolicyManualExecution() throws Exception {
|
public void testPolicyManualExecution() throws Exception {
|
||||||
final String indexName = "test";
|
final String indexName = "test";
|
||||||
final String policyName = "test-policy";
|
final String policyName = "test-policy";
|
||||||
|
@ -204,6 +206,8 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
index(client(), indexName, "" + i, "foo", "bar");
|
index(client(), indexName, "" + i, "foo", "bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logSLMPolicies();
|
||||||
|
|
||||||
// Create a snapshot repo
|
// Create a snapshot repo
|
||||||
initializeRepo(repoId);
|
initializeRepo(repoId);
|
||||||
|
|
||||||
|
@ -216,6 +220,8 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
|
|
||||||
final String snapshotName = executePolicy(policyName);
|
final String snapshotName = executePolicy(policyName);
|
||||||
|
|
||||||
|
logSLMPolicies();
|
||||||
|
|
||||||
// Check that the executed snapshot is created
|
// Check that the executed snapshot is created
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
try {
|
try {
|
||||||
|
@ -336,7 +342,8 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/48017")
|
@TestIssueLogging(value = "org.elasticsearch.xpack.slm:TRACE,org.elasticsearch.xpack.core.slm:TRACE,org.elasticsearch.snapshots:TRACE",
|
||||||
|
issueUrl = "https://github.com/elastic/elasticsearch/issues/48017")
|
||||||
public void testBasicTimeBasedRetenion() throws Exception {
|
public void testBasicTimeBasedRetenion() throws Exception {
|
||||||
final String indexName = "test";
|
final String indexName = "test";
|
||||||
final String policyName = "test-policy";
|
final String policyName = "test-policy";
|
||||||
|
@ -346,6 +353,7 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
for (int i = 0; i < docCount; i++) {
|
for (int i = 0; i < docCount; i++) {
|
||||||
index(client(), indexName, "" + i, "foo", "bar");
|
index(client(), indexName, "" + i, "foo", "bar");
|
||||||
}
|
}
|
||||||
|
logSLMPolicies();
|
||||||
|
|
||||||
// Create a snapshot repo
|
// Create a snapshot repo
|
||||||
initializeRepo(repoId);
|
initializeRepo(repoId);
|
||||||
|
@ -383,8 +391,11 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
Request r = new Request("PUT", "/_cluster/settings");
|
Request r = new Request("PUT", "/_cluster/settings");
|
||||||
r.setJsonEntity(Strings.toString(builder));
|
r.setJsonEntity(Strings.toString(builder));
|
||||||
Response updateSettingsResp = client().performRequest(r);
|
Response updateSettingsResp = client().performRequest(r);
|
||||||
|
assertAcked(updateSettingsResp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logSLMPolicies();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check that the snapshot created by the policy has been removed by retention
|
// Check that the snapshot created by the policy has been removed by retention
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
|
@ -618,7 +629,8 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
XContentBuilder lifecycleBuilder = JsonXContent.contentBuilder();
|
XContentBuilder lifecycleBuilder = JsonXContent.contentBuilder();
|
||||||
policy.toXContent(lifecycleBuilder, ToXContent.EMPTY_PARAMS);
|
policy.toXContent(lifecycleBuilder, ToXContent.EMPTY_PARAMS);
|
||||||
putLifecycle.setJsonEntity(Strings.toString(lifecycleBuilder));
|
putLifecycle.setJsonEntity(Strings.toString(lifecycleBuilder));
|
||||||
assertOK(client().performRequest(putLifecycle));
|
final Response response = client().performRequest(putLifecycle);
|
||||||
|
assertAcked(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeRepo(String repoName) throws IOException {
|
private void initializeRepo(String repoName) throws IOException {
|
||||||
|
@ -659,4 +671,20 @@ public class SnapshotLifecycleRestIT extends ESRestTestCase {
|
||||||
m -> (String) m.get(SnapshotLifecycleStats.SnapshotPolicyStats.POLICY_ID.getPreferredName()),
|
m -> (String) m.get(SnapshotLifecycleStats.SnapshotPolicyStats.POLICY_ID.getPreferredName()),
|
||||||
Function.identity()));
|
Function.identity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void assertAcked(Response response) throws IOException {
|
||||||
|
assertOK(response);
|
||||||
|
Map<String, Object> putLifecycleResponseMap;
|
||||||
|
try (InputStream is = response.getEntity().getContent()) {
|
||||||
|
putLifecycleResponseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
|
||||||
|
}
|
||||||
|
assertThat(putLifecycleResponseMap.get("acknowledged"), equalTo(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logSLMPolicies() throws IOException {
|
||||||
|
Request request = new Request("GET" , "/_slm/policy?human");
|
||||||
|
Response response = client().performRequest(request);
|
||||||
|
assertOK(response);
|
||||||
|
logger.info("SLM policies: {}", EntityUtils.toString(response.getEntity()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue