Skip to content

Commit 2599e23

Browse files
Fix SnapshotStatusApisIT (#45929)
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 fbecbcf commit 2599e23

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;
@@ -76,7 +77,7 @@ public void testStatusApiConsistency() {
7677
assertEquals(snStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime());
7778
}
7879

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

8283
logger.info("--> creating repository");
@@ -101,7 +102,7 @@ public void testStatusAPICallInProgressSnapshot() throws InterruptedException {
101102

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

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

0 commit comments

Comments
 (0)