File tree Expand file tree Collapse file tree
server/src/internalClusterTest/java/org/elasticsearch/snapshots Expand file tree Collapse file tree Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments