Skip to content
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

Retry on RepositoryException in SLM tests #48548

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -765,7 +765,6 @@ public void onFailure(Exception e) {
assertTrue(latch.await(30L, TimeUnit.SECONDS));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/46021")
public void testAddSnapshotLifecyclePolicy() throws Exception {
RestHighLevelClient client = highLevelClient();

Expand Down Expand Up @@ -1057,6 +1056,8 @@ private void assertSnapshotExists(final RestHighLevelClient client, final String
} catch (Exception e) {
if (e.getMessage().contains("snapshot_missing_exception")) {
fail("snapshot does not exist: " + snapshotName);
} else if (e.getMessage().contains("repository_exception")) {
fail("got a respository_exception, retrying. original message: " + e.getMessage());
}
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package org.elasticsearch.xpack.slm;

import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
Expand Down Expand Up @@ -124,7 +123,6 @@ public void testSnapshotInProgress() throws Exception {
}
}

@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/48441")
public void testRetentionWhileSnapshotInProgress() throws Exception {
final String indexName = "test";
final String policyId = "slm-policy";
Expand All @@ -144,8 +142,7 @@ public void testRetentionWhileSnapshotInProgress() throws Exception {
logger.info("--> kicked off snapshot {}", completedSnapshotName);
assertBusy(() -> {
try {
SnapshotsStatusResponse s =
client().admin().cluster().prepareSnapshotStatus(REPO).setSnapshots(completedSnapshotName).get();
SnapshotsStatusResponse s = getSnapshotStatus(completedSnapshotName);
assertThat("expected a snapshot but none were returned", s.getSnapshots().size(), equalTo(1));
SnapshotStatus status = s.getSnapshots().get(0);
logger.info("--> waiting for snapshot {} to be completed, got: {}", completedSnapshotName, status.getState());
Expand Down Expand Up @@ -213,13 +210,8 @@ public void testRetentionWhileSnapshotInProgress() throws Exception {
client().admin().cluster().prepareReroute().get();
logger.info("--> waiting for snapshot to be deleted");
try {
SnapshotsStatusResponse s =
client().admin().cluster().prepareSnapshotStatus(REPO).setSnapshots(completedSnapshotName).get();
SnapshotsStatusResponse s = getSnapshotStatus(completedSnapshotName);
assertNull("expected no snapshot but one was returned", s.getSnapshots().get(0));
} catch (RepositoryException e) {
// Concurrent status calls and write operations may lead to failures in determining the current repository generation
// TODO: Remove this hack once tracking the current repository generation has been made consistent
throw new AssertionError(e);
} catch (SnapshotMissingException e) {
// Great, we wanted it to be deleted!
}
Expand Down Expand Up @@ -383,6 +375,18 @@ private void testUnsuccessfulSnapshotRetention(boolean partialSuccess) throws Ex
}
}

private SnapshotsStatusResponse getSnapshotStatus(String snapshotName) {
try {
return client().admin().cluster().prepareSnapshotStatus(REPO).setSnapshots(snapshotName).get();
} catch (RepositoryException e) {
// Convert this to an AssertionError so that it can be retried in an assertBusy - this is often a transient error because
// concurrent status calls and write operations may lead to failures in determining the current repository generation
// TODO: Remove this hack once tracking the current repository generation has been made consistent
logger.warn(e);
throw new AssertionError(e);
}
}

private void createAndPopulateIndex(String indexName) throws InterruptedException {
logger.info("--> creating and populating index [{}]", indexName);
assertAcked(prepareCreate(indexName, 0, Settings.builder()
Expand Down