|
21 | 21 | import org.elasticsearch.index.query.QueryBuilders;
|
22 | 22 | import org.elasticsearch.plugins.Plugin;
|
23 | 23 | import org.elasticsearch.repositories.RepositoriesService;
|
| 24 | +import org.elasticsearch.repositories.RepositoryException; |
24 | 25 | import org.elasticsearch.snapshots.ConcurrentSnapshotExecutionException;
|
25 | 26 | import org.elasticsearch.snapshots.SnapshotInfo;
|
26 | 27 | import org.elasticsearch.snapshots.SnapshotMissingException;
|
@@ -176,8 +177,7 @@ public void testRetentionWhileSnapshotInProgress() throws Exception {
|
176 | 177 | logger.info("--> kicked off snapshot {}", completedSnapshotName);
|
177 | 178 | assertBusy(() -> {
|
178 | 179 | try {
|
179 |
| - SnapshotsStatusResponse s = |
180 |
| - client().admin().cluster().prepareSnapshotStatus(REPO).setSnapshots(completedSnapshotName).get(); |
| 180 | + SnapshotsStatusResponse s = getSnapshotStatus(completedSnapshotName); |
181 | 181 | assertThat("expected a snapshot but none were returned", s.getSnapshots().size(), equalTo(1));
|
182 | 182 | SnapshotStatus status = s.getSnapshots().get(0);
|
183 | 183 | logger.info("--> waiting for snapshot {} to be completed, got: {}", completedSnapshotName, status.getState());
|
@@ -245,8 +245,7 @@ public void testRetentionWhileSnapshotInProgress() throws Exception {
|
245 | 245 | client().admin().cluster().prepareReroute().get();
|
246 | 246 | logger.info("--> waiting for snapshot to be deleted");
|
247 | 247 | try {
|
248 |
| - SnapshotsStatusResponse s = |
249 |
| - client().admin().cluster().prepareSnapshotStatus(REPO).setSnapshots(completedSnapshotName).get(); |
| 248 | + SnapshotsStatusResponse s = getSnapshotStatus(completedSnapshotName); |
250 | 249 | assertNull("expected no snapshot but one was returned", s.getSnapshots().get(0));
|
251 | 250 | } catch (SnapshotMissingException e) {
|
252 | 251 | // Great, we wanted it to be deleted!
|
@@ -406,6 +405,18 @@ private void testUnsuccessfulSnapshotRetention(boolean partialSuccess) throws Ex
|
406 | 405 | }
|
407 | 406 | }
|
408 | 407 |
|
| 408 | + private SnapshotsStatusResponse getSnapshotStatus(String snapshotName) { |
| 409 | + try { |
| 410 | + return client().admin().cluster().prepareSnapshotStatus(REPO).setSnapshots(snapshotName).get(); |
| 411 | + } catch (RepositoryException e) { |
| 412 | + // Convert this to an AssertionError so that it can be retried in an assertBusy - this is often a transient error because |
| 413 | + // concurrent status calls and write operations may lead to failures in determining the current repository generation |
| 414 | + // TODO: Remove this hack once tracking the current repository generation has been made consistent |
| 415 | + logger.warn(e); |
| 416 | + throw new AssertionError(e); |
| 417 | + } |
| 418 | + } |
| 419 | + |
409 | 420 | private void createAndPopulateIndex(String indexName) throws InterruptedException {
|
410 | 421 | logger.info("--> creating and populating index [{}]", indexName);
|
411 | 422 | assertAcked(prepareCreate(indexName, 0, Settings.builder()
|
|
0 commit comments