Skip to content

Commit 5a17987

Browse files
Fix SnapshotStatusApisIT (#45929) (#45971)
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
1 parent 9672ff3 commit 5a17987

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/test/java/org/elasticsearch/snapshots/SnapshotStatusApisIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.elasticsearch.common.unit.TimeValue;
3030

3131
import java.util.List;
32+
import java.util.concurrent.TimeUnit;
3233

3334
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
3435
import static org.hamcrest.Matchers.equalTo;
@@ -75,7 +76,7 @@ public void testStatusApiConsistency() {
7576
assertEquals(snStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime());
7677
}
7778

78-
public void testStatusAPICallInProgressSnapshot() throws InterruptedException {
79+
public void testStatusAPICallInProgressSnapshot() throws Exception {
7980
Client client = client();
8081

8182
logger.info("--> creating repository");
@@ -100,7 +101,7 @@ public void testStatusAPICallInProgressSnapshot() throws InterruptedException {
100101

101102
final List<SnapshotStatus> snapshotStatus = client.admin().cluster().snapshotsStatus(
102103
new SnapshotsStatusRequest("test-repo", new String[]{"test-snap"})).actionGet().getSnapshots();
103-
assertEquals(snapshotStatus.get(0).getState(), SnapshotsInProgress.State.STARTED);
104+
assertBusy(() -> assertEquals(SnapshotsInProgress.State.STARTED, snapshotStatus.get(0).getState()), 1L, TimeUnit.MINUTES);
104105

105106
logger.info("--> unblock all data nodes");
106107
unblockAllDataNodes("test-repo");

0 commit comments

Comments
 (0)