diff --git a/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java b/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java index 02b37e28e93..a016704bc3a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/snapshots/ConcurrentSnapshotsIT.java @@ -530,7 +530,10 @@ public class ConcurrentSnapshotsIT extends AbstractSnapshotIntegTestCase { final String secondSnapshot = "snapshot-two"; final ActionFuture secondSnapshotResponse = startFullSnapshotFromMasterClient(repoName, secondSnapshot); - + + // make sure second snapshot is in progress before restarting data node + waitUntilInprogress(repoName, secondSnapshot, TimeValue.timeValueSeconds(5L)); + internalCluster().restartNode(dataNode, InternalTestCluster.EMPTY_CALLBACK); assertThat(firstSnapshotResponse.get().getSnapshotInfo().state(), is(SnapshotState.PARTIAL)); @@ -1382,4 +1385,17 @@ public class ConcurrentSnapshotsIT extends AbstractSnapshotIntegTestCase { waitForBlock(internalCluster().getMasterName(), blockedRepoName, TimeValue.timeValueSeconds(30L)); return fut; } + + private static void waitUntilInprogress(final String repoName, final String snapshotName, + TimeValue timeout) throws InterruptedException { + waitUntil(() -> + currentSnapshots(repoName) + .stream() + .filter(s -> s.snapshotId().getName().equals(snapshotName)) + .filter(s -> s.state() == SnapshotState.IN_PROGRESS) + .findAny() + .isPresent(), + timeout.millis(), + TimeUnit.MILLISECONDS); + } }