From 90cbf80fc4e0864d83f3d8ebe9ff14b0f0cecde0 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Wed, 3 Jun 2015 10:05:46 -1000 Subject: [PATCH] Tests: remove race condition in the masterShutdownDuringSnapshotTest --- .../DedicatedClusterSnapshotRestoreTests.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java b/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java index 9716d23a04f..c1c59dda13b 100644 --- a/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java +++ b/src/test/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreTests.java @@ -847,21 +847,22 @@ public class DedicatedClusterSnapshotRestoreTests extends AbstractSnapshotTests logger.info("--> unblocking snapshot execution"); snapshotListener.unblock(); - logger.info("--> wait until the snapshot is done"); - } finally { clusterService.remove(snapshotListener); } + logger.info("--> wait until the snapshot is done"); + assertBusy(new Runnable() { @Override public void run() { - SnapshotsStatusResponse snapshotsStatusResponse = client().admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test-snap").get(); - ImmutableList snapshotStatuses = snapshotsStatusResponse.getSnapshots(); - assertEquals(1, snapshotStatuses.size()); - assertTrue(snapshotStatuses.get(0).getState().completed()); + GetSnapshotsResponse snapshotsStatusResponse = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get(); + SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0); + assertTrue(snapshotInfo.state().completed()); } - }); + }, 1, TimeUnit.MINUTES); + + logger.info("--> verify that snapshot was succesful"); GetSnapshotsResponse snapshotsStatusResponse = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get(); SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0);