Skip to content

Commit 7edb9e6

Browse files
Actually
1 parent 6875de8 commit 7edb9e6

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ public void testDeletesAreBatched() throws Exception {
213213
dataNode
214214
);
215215

216+
// waits for snapshot deletions to batch up
217+
final var deletesEnqueuedListener = ClusterServiceUtils.addTemporaryStateListener(cs -> {
218+
final var entries = SnapshotDeletionsInProgress.get(cs).getEntries();
219+
return entries.size() == 1 && entries.getFirst().snapshots().size() == numSnapshots;
220+
});
221+
216222
final Collection<ListenableFuture<AcknowledgedResponse>> deleteFutures = new ArrayList<>();
217223
while (snapshotNames.isEmpty() == false) {
218224
final Collection<String> toDelete = randomSubsetOf(snapshotNames);
@@ -230,12 +236,8 @@ public void testDeletesAreBatched() throws Exception {
230236
final long repoGenAfterInitialSnapshots = getRepositoryData(repoName).getGenId();
231237
assertThat(repoGenAfterInitialSnapshots, is(numSnapshots - 1L));
232238

233-
// wait for snapshot deletions to batch up, before unblocking the snapshot holding them up
234-
safeAwait(
235-
ClusterServiceUtils.addTemporaryStateListener(
236-
cs -> SnapshotDeletionsInProgress.get(cs).getEntries().getFirst().snapshots().size() == numSnapshots
237-
)
238-
);
239+
// wait for snapshot deletions to batch up before unblocking the snapshot holding them up
240+
safeAwait(deletesEnqueuedListener);
239241
unblockNode(repoName, dataNode);
240242

241243
final SnapshotInfo slowSnapshotInfo = assertSuccessful(createSlowFuture);

0 commit comments

Comments
 (0)