From dfa38a1a2b33c4dbce8b8116e99650b75678fe73 Mon Sep 17 00:00:00 2001 From: Armin Date: Fri, 23 Aug 2019 21:50:30 +0200 Subject: [PATCH] Fix SnapshotStatusApisIT The snapshot status when blocking can still be INIT in rare cases when the new cluster state that has the snapshot in `STARTED` hasn't yet become visible. Fixes #45917 --- .../org/elasticsearch/snapshots/SnapshotStatusApisIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java b/server/src/test/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java index 13a00119f29e7..d8e6cd7070966 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java +++ b/server/src/test/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.unit.TimeValue; import java.util.List; +import java.util.concurrent.TimeUnit; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -76,7 +77,7 @@ public void testStatusApiConsistency() { assertEquals(snStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime()); } - public void testStatusAPICallInProgressSnapshot() throws InterruptedException { + public void testStatusAPICallInProgressSnapshot() throws Exception { Client client = client(); logger.info("--> creating repository"); @@ -101,7 +102,7 @@ public void testStatusAPICallInProgressSnapshot() throws InterruptedException { final List snapshotStatus = client.admin().cluster().snapshotsStatus( new SnapshotsStatusRequest("test-repo", new String[]{"test-snap"})).actionGet().getSnapshots(); - assertEquals(snapshotStatus.get(0).getState(), SnapshotsInProgress.State.STARTED); + assertBusy(() -> assertEquals(SnapshotsInProgress.State.STARTED, snapshotStatus.get(0).getState()), 1L, TimeUnit.MINUTES); logger.info("--> unblock all data nodes"); unblockAllDataNodes("test-repo");