|
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;
|
@@ -355,18 +356,24 @@ private void testUnsuccessfulSnapshotRetention(boolean partialSuccess) throws Ex
|
355 | 356 | logger.info("--> waiting for {} snapshot [{}] to be deleted", expectedUnsuccessfulState, failedSnapshotName.get());
|
356 | 357 | assertBusy(() -> {
|
357 | 358 | try {
|
| 359 | + try { |
| 360 | + GetSnapshotsResponse snapshotsStatusResponse = client().admin().cluster() |
| 361 | + .prepareGetSnapshots(REPO).setSnapshots(failedSnapshotName.get()).get(); |
| 362 | + assertThat(snapshotsStatusResponse.getSnapshots(REPO), empty()); |
| 363 | + } catch (SnapshotMissingException e) { |
| 364 | + // This is what we want to happen |
| 365 | + } |
| 366 | + logger.info("--> {} snapshot [{}] has been deleted, checking successful snapshot [{}] still exists", |
| 367 | + expectedUnsuccessfulState, failedSnapshotName.get(), successfulSnapshotName.get()); |
358 | 368 | GetSnapshotsResponse snapshotsStatusResponse = client().admin().cluster()
|
359 |
| - .prepareGetSnapshots(REPO).setSnapshots(failedSnapshotName.get()).get(); |
360 |
| - assertThat(snapshotsStatusResponse.getSnapshots(REPO), empty()); |
361 |
| - } catch (SnapshotMissingException e) { |
362 |
| - // This is what we want to happen |
| 369 | + .prepareGetSnapshots(REPO).setSnapshots(successfulSnapshotName.get()).get(); |
| 370 | + SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots(REPO).get(0); |
| 371 | + assertEquals(SnapshotState.SUCCESS, snapshotInfo.state()); |
| 372 | + } catch (RepositoryException re) { |
| 373 | + // Concurrent status calls and write operations may lead to failures in determining the current repository generation |
| 374 | + // TODO: Remove this hack once tracking the current repository generation has been made consistent |
| 375 | + throw new AssertionError(re); |
363 | 376 | }
|
364 |
| - logger.info("--> {} snapshot [{}] has been deleted, checking successful snapshot [{}] still exists", |
365 |
| - expectedUnsuccessfulState, failedSnapshotName.get(), successfulSnapshotName.get()); |
366 |
| - GetSnapshotsResponse snapshotsStatusResponse = client().admin().cluster() |
367 |
| - .prepareGetSnapshots(REPO).setSnapshots(successfulSnapshotName.get()).get(); |
368 |
| - SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots(REPO).get(0); |
369 |
| - assertEquals(SnapshotState.SUCCESS, snapshotInfo.state()); |
370 | 377 | });
|
371 | 378 | }
|
372 | 379 | }
|
|
0 commit comments