Skip to content

Commit 50d7424

Browse files
authored
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.
1 parent 1de49d8 commit 50d7424

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package org.elasticsearch.xpack.slm;
88

99
import org.apache.http.util.EntityUtils;
10-
import org.apache.lucene.util.LuceneTestCase;
1110
import org.elasticsearch.ElasticsearchException;
1211
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
1312
import org.elasticsearch.action.index.IndexRequestBuilder;
@@ -27,6 +26,7 @@
2726
import org.elasticsearch.common.xcontent.XContentParser;
2827
import org.elasticsearch.common.xcontent.XContentType;
2928
import org.elasticsearch.common.xcontent.json.JsonXContent;
29+
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
3030
import org.elasticsearch.test.rest.ESRestTestCase;
3131
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
3232
import org.elasticsearch.xpack.core.ilm.Step;
@@ -195,6 +195,8 @@ public void testPolicyFailure() throws Exception {
195195
}
196196

197197
@SuppressWarnings("unchecked")
198+
@TestIssueLogging(value = "org.elasticsearch.xpack.slm:TRACE,org.elasticsearch.xpack.core.slm:TRACE,org.elasticsearch.snapshots:DEBUG",
199+
issueUrl = "https://github.com/elastic/elasticsearch/issues/48531")
198200
public void testPolicyManualExecution() throws Exception {
199201
final String indexName = "test";
200202
final String policyName = "test-policy";
@@ -204,6 +206,8 @@ public void testPolicyManualExecution() throws Exception {
204206
index(client(), indexName, "" + i, "foo", "bar");
205207
}
206208

209+
logSLMPolicies();
210+
207211
// Create a snapshot repo
208212
initializeRepo(repoId);
209213

@@ -216,6 +220,8 @@ public void testPolicyManualExecution() throws Exception {
216220

217221
final String snapshotName = executePolicy(policyName);
218222

223+
logSLMPolicies();
224+
219225
// Check that the executed snapshot is created
220226
assertBusy(() -> {
221227
try {
@@ -336,7 +342,8 @@ public void testStartStopStatus() throws Exception {
336342
}
337343

338344
@SuppressWarnings("unchecked")
339-
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/48017")
345+
@TestIssueLogging(value = "org.elasticsearch.xpack.slm:TRACE,org.elasticsearch.xpack.core.slm:TRACE,org.elasticsearch.snapshots:TRACE",
346+
issueUrl = "https://github.com/elastic/elasticsearch/issues/48017")
340347
public void testBasicTimeBasedRetenion() throws Exception {
341348
final String indexName = "test";
342349
final String policyName = "test-policy";
@@ -346,6 +353,7 @@ public void testBasicTimeBasedRetenion() throws Exception {
346353
for (int i = 0; i < docCount; i++) {
347354
index(client(), indexName, "" + i, "foo", "bar");
348355
}
356+
logSLMPolicies();
349357

350358
// Create a snapshot repo
351359
initializeRepo(repoId);
@@ -383,8 +391,11 @@ public void testBasicTimeBasedRetenion() throws Exception {
383391
Request r = new Request("PUT", "/_cluster/settings");
384392
r.setJsonEntity(Strings.toString(builder));
385393
Response updateSettingsResp = client().performRequest(r);
394+
assertAcked(updateSettingsResp);
386395
}
387396

397+
logSLMPolicies();
398+
388399
try {
389400
// Check that the snapshot created by the policy has been removed by retention
390401
assertBusy(() -> {
@@ -618,7 +629,8 @@ private void createSnapshotPolicy(String policyName, String snapshotNamePattern,
618629
XContentBuilder lifecycleBuilder = JsonXContent.contentBuilder();
619630
policy.toXContent(lifecycleBuilder, ToXContent.EMPTY_PARAMS);
620631
putLifecycle.setJsonEntity(Strings.toString(lifecycleBuilder));
621-
assertOK(client().performRequest(putLifecycle));
632+
final Response response = client().performRequest(putLifecycle);
633+
assertAcked(response);
622634
}
623635

624636
private void initializeRepo(String repoName) throws IOException {
@@ -659,4 +671,20 @@ private static Map<String, Object> policyStatsAsMap(Map<String, Object> stats) {
659671
m -> (String) m.get(SnapshotLifecycleStats.SnapshotPolicyStats.POLICY_ID.getPreferredName()),
660672
Function.identity()));
661673
}
674+
675+
private void assertAcked(Response response) throws IOException {
676+
assertOK(response);
677+
Map<String, Object> putLifecycleResponseMap;
678+
try (InputStream is = response.getEntity().getContent()) {
679+
putLifecycleResponseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
680+
}
681+
assertThat(putLifecycleResponseMap.get("acknowledged"), equalTo(true));
682+
}
683+
684+
private void logSLMPolicies() throws IOException {
685+
Request request = new Request("GET" , "/_slm/policy?human");
686+
Response response = client().performRequest(request);
687+
assertOK(response);
688+
logger.info("SLM policies: {}", EntityUtils.toString(response.getEntity()));
689+
}
662690
}

0 commit comments

Comments
 (0)