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
This commit is contained in:
Armin Braun 2019-08-26 15:59:02 +02:00 committed by GitHub
parent 9672ff388a
commit 5a17987e19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -29,6 +29,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -75,7 +76,7 @@ public class SnapshotStatusApisIT extends AbstractSnapshotIntegTestCase {
assertEquals(snStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime()); assertEquals(snStatus.getStats().getTime(), snapshotInfo.endTime() - snapshotInfo.startTime());
} }
public void testStatusAPICallInProgressSnapshot() throws InterruptedException { public void testStatusAPICallInProgressSnapshot() throws Exception {
Client client = client(); Client client = client();
logger.info("--> creating repository"); logger.info("--> creating repository");
@ -100,7 +101,7 @@ public class SnapshotStatusApisIT extends AbstractSnapshotIntegTestCase {
final List<SnapshotStatus> snapshotStatus = client.admin().cluster().snapshotsStatus( final List<SnapshotStatus> snapshotStatus = client.admin().cluster().snapshotsStatus(
new SnapshotsStatusRequest("test-repo", new String[]{"test-snap"})).actionGet().getSnapshots(); 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"); logger.info("--> unblock all data nodes");
unblockAllDataNodes("test-repo"); unblockAllDataNodes("test-repo");