2828import org .elasticsearch .common .unit .TimeValue ;
2929import org .elasticsearch .common .util .MockBigArrays ;
3030import org .elasticsearch .index .IndexNotFoundException ;
31- import org .elasticsearch .repositories .RepositoriesService ;
3231import org .elasticsearch .repositories .RepositoryData ;
3332import org .elasticsearch .snapshots .mockstore .MockRepository ;
3433import org .elasticsearch .test .ESIntegTestCase ;
@@ -79,8 +78,7 @@ public void testShardClone() throws Exception {
7978 final String sourceSnapshot = "source-snapshot" ;
8079 final SnapshotInfo sourceSnapshotInfo = createFullSnapshot (repoName , sourceSnapshot );
8180
82- final BlobStoreRepository repository =
83- (BlobStoreRepository ) internalCluster ().getCurrentMasterNodeInstance (RepositoriesService .class ).repository (repoName );
81+ final BlobStoreRepository repository = getRepositoryOnMaster (repoName );
8482 final RepositoryData repositoryData = getRepositoryData (repoName );
8583 final IndexId indexId = repositoryData .resolveIndexId (indexName );
8684 final int shardId = 0 ;
@@ -167,7 +165,7 @@ public void testClonePreventsSnapshotDelete() throws Exception {
167165 final String targetSnapshot = "target-snapshot" ;
168166 blockNodeOnAnyFiles (repoName , masterName );
169167 final ActionFuture <AcknowledgedResponse > cloneFuture = startClone (repoName , sourceSnapshot , targetSnapshot , indexName );
170- waitForBlock (masterName , repoName , TimeValue . timeValueSeconds ( 30L ) );
168+ waitForBlock (masterName , repoName );
171169 assertFalse (cloneFuture .isDone ());
172170
173171 ConcurrentSnapshotExecutionException ex = expectThrows (ConcurrentSnapshotExecutionException .class ,
@@ -201,7 +199,7 @@ public void testConcurrentCloneAndSnapshot() throws Exception {
201199 final String targetSnapshot = "target-snapshot" ;
202200 final ActionFuture <CreateSnapshotResponse > snapshot2Future =
203201 startFullSnapshotBlockedOnDataNode ("snapshot-2" , repoName , dataNode );
204- waitForBlock (dataNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
202+ waitForBlock (dataNode , repoName );
205203 final ActionFuture <AcknowledgedResponse > cloneFuture = startClone (repoName , sourceSnapshot , targetSnapshot , indexName );
206204 awaitNumberOfSnapshotsInProgress (2 );
207205 unblockNode (repoName , dataNode );
@@ -224,7 +222,7 @@ public void testLongRunningCloneAllowsConcurrentSnapshot() throws Exception {
224222 final String targetSnapshot = "target-snapshot" ;
225223 blockMasterOnShardClone (repoName );
226224 final ActionFuture <AcknowledgedResponse > cloneFuture = startClone (repoName , sourceSnapshot , targetSnapshot , indexSlow );
227- waitForBlock (masterNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
225+ waitForBlock (masterNode , repoName );
228226
229227 final String indexFast = "index-fast" ;
230228 createIndexWithRandomDocs (indexFast , randomIntBetween (20 , 100 ));
@@ -255,7 +253,7 @@ public void testLongRunningSnapshotAllowsConcurrentClone() throws Exception {
255253 blockDataNode (repoName , dataNode );
256254 final ActionFuture <CreateSnapshotResponse > snapshotFuture = clusterAdmin ()
257255 .prepareCreateSnapshot (repoName , "fast-snapshot" ).setIndices (indexFast ).setWaitForCompletion (true ).execute ();
258- waitForBlock (dataNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
256+ waitForBlock (dataNode , repoName );
259257
260258 final String targetSnapshot = "target-snapshot" ;
261259 assertAcked (startClone (repoName , sourceSnapshot , targetSnapshot , indexSlow ).get ());
@@ -282,7 +280,7 @@ public void testDeletePreventsClone() throws Exception {
282280 final String targetSnapshot = "target-snapshot" ;
283281 blockNodeOnAnyFiles (repoName , masterName );
284282 final ActionFuture <AcknowledgedResponse > deleteFuture = startDeleteSnapshot (repoName , sourceSnapshot );
285- waitForBlock (masterName , repoName , TimeValue . timeValueSeconds ( 30L ) );
283+ waitForBlock (masterName , repoName );
286284 assertFalse (deleteFuture .isDone ());
287285
288286 ConcurrentSnapshotExecutionException ex = expectThrows (ConcurrentSnapshotExecutionException .class , () ->
@@ -310,7 +308,7 @@ public void testBackToBackClonesForIndexNotInCluster() throws Exception {
310308 final String targetSnapshot1 = "target-snapshot" ;
311309 blockMasterOnShardClone (repoName );
312310 final ActionFuture <AcknowledgedResponse > cloneFuture1 = startClone (repoName , sourceSnapshot , targetSnapshot1 , indexBlocked );
313- waitForBlock (masterNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
311+ waitForBlock (masterNode , repoName );
314312 assertThat (cloneFuture1 .isDone (), is (false ));
315313
316314 final int extraClones = randomIntBetween (1 , 5 );
@@ -366,7 +364,7 @@ public void testMasterFailoverDuringCloneStep1() throws Exception {
366364 startCloneFromDataNode (repoName , sourceSnapshot , cloneName , testIndex );
367365 awaitNumberOfSnapshotsInProgress (1 );
368366 final String masterNode = internalCluster ().getMasterName ();
369- waitForBlock (masterNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
367+ waitForBlock (masterNode , repoName );
370368 internalCluster ().restartNode (masterNode );
371369 boolean cloneSucceeded = false ;
372370 try {
@@ -377,7 +375,7 @@ public void testMasterFailoverDuringCloneStep1() throws Exception {
377375 // snapshot on disconnect slowly enough for it to work out
378376 }
379377
380- awaitNoMoreRunningOperations (internalCluster (). getMasterName () );
378+ awaitNoMoreRunningOperations ();
381379
382380 // Check if the clone operation worked out by chance as a result of the clone request being retried because of the master failover
383381 cloneSucceeded = cloneSucceeded ||
@@ -418,10 +416,10 @@ public void testMasterFailoverDuringCloneStep2() throws Exception {
418416 final ActionFuture <AcknowledgedResponse > cloneFuture = startCloneFromDataNode (repoName , sourceSnapshot , targetSnapshot , testIndex );
419417 awaitNumberOfSnapshotsInProgress (1 );
420418 final String masterNode = internalCluster ().getMasterName ();
421- waitForBlock (masterNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
419+ waitForBlock (masterNode , repoName );
422420 internalCluster ().restartNode (masterNode );
423421 expectThrows (SnapshotException .class , cloneFuture ::actionGet );
424- awaitNoMoreRunningOperations (internalCluster (). getMasterName () );
422+ awaitNoMoreRunningOperations ();
425423
426424 assertAllSnapshotsSuccessful (getRepositoryData (repoName ), 2 );
427425 }
@@ -443,10 +441,10 @@ public void testExceptionDuringShardClone() throws Exception {
443441 final ActionFuture <AcknowledgedResponse > cloneFuture = startCloneFromDataNode (repoName , sourceSnapshot , targetSnapshot , testIndex );
444442 awaitNumberOfSnapshotsInProgress (1 );
445443 final String masterNode = internalCluster ().getMasterName ();
446- waitForBlock (masterNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
444+ waitForBlock (masterNode , repoName );
447445 unblockNode (repoName , masterNode );
448446 expectThrows (SnapshotException .class , cloneFuture ::actionGet );
449- awaitNoMoreRunningOperations (internalCluster (). getMasterName () );
447+ awaitNoMoreRunningOperations ();
450448 assertAllSnapshotsSuccessful (getRepositoryData (repoName ), 1 );
451449 assertAcked (startDeleteSnapshot (repoName , sourceSnapshot ).get ());
452450 }
@@ -465,7 +463,7 @@ public void testDoesNotStartOnBrokenSourceSnapshot() throws Exception {
465463 final ActionFuture <CreateSnapshotResponse > sourceSnapshotFuture = masterClient .admin ().cluster ()
466464 .prepareCreateSnapshot (repoName , sourceSnapshot ).setWaitForCompletion (true ).execute ();
467465 awaitNumberOfSnapshotsInProgress (1 );
468- waitForBlock (dataNode , repoName , TimeValue . timeValueSeconds ( 30L ) );
466+ waitForBlock (dataNode , repoName );
469467 internalCluster ().restartNode (dataNode );
470468 assertThat (sourceSnapshotFuture .get ().getSnapshotInfo ().state (), is (SnapshotState .PARTIAL ));
471469
@@ -490,7 +488,7 @@ public void testStartSnapshotWithSuccessfulShardClonePendingFinalization() throw
490488 blockMasterOnWriteIndexFile (repoName );
491489 final String cloneName = "clone-blocked" ;
492490 final ActionFuture <AcknowledgedResponse > blockedClone = startClone (repoName , sourceSnapshot , cloneName , indexName );
493- waitForBlock (masterName , repoName , TimeValue . timeValueSeconds ( 30L ) );
491+ waitForBlock (masterName , repoName );
494492 awaitNumberOfSnapshotsInProgress (1 );
495493 blockNodeOnAnyFiles (repoName , dataNode );
496494 final ActionFuture <CreateSnapshotResponse > otherSnapshot = startFullSnapshot (repoName , "other-snapshot" );
@@ -520,7 +518,7 @@ public void testStartCloneWithSuccessfulShardClonePendingFinalization() throws E
520518 blockMasterOnWriteIndexFile (repoName );
521519 final String cloneName = "clone-blocked" ;
522520 final ActionFuture <AcknowledgedResponse > blockedClone = startClone (repoName , sourceSnapshot , cloneName , indexName );
523- waitForBlock (masterName , repoName , TimeValue . timeValueSeconds ( 30L ) );
521+ waitForBlock (masterName , repoName );
524522 awaitNumberOfSnapshotsInProgress (1 );
525523 final String otherCloneName = "other-clone" ;
526524 final ActionFuture <AcknowledgedResponse > otherClone = startClone (repoName , sourceSnapshot , otherCloneName , indexName );
@@ -549,7 +547,7 @@ public void testStartCloneWithSuccessfulShardSnapshotPendingFinalization() throw
549547
550548 blockMasterOnWriteIndexFile (repoName );
551549 final ActionFuture <CreateSnapshotResponse > blockedSnapshot = startFullSnapshot (repoName , "snap-blocked" );
552- waitForBlock (masterName , repoName , TimeValue . timeValueSeconds ( 30L ) );
550+ waitForBlock (masterName , repoName );
553551 awaitNumberOfSnapshotsInProgress (1 );
554552 final String cloneName = "clone" ;
555553 final ActionFuture <AcknowledgedResponse > clone = startClone (repoName , sourceSnapshot , cloneName , indexName );
@@ -589,13 +587,11 @@ private static ActionFuture<AcknowledgedResponse> startClone(Client client, Stri
589587 }
590588
591589 private void blockMasterOnReadIndexMeta (String repoName ) {
592- ((MockRepository )internalCluster ().getCurrentMasterNodeInstance (RepositoriesService .class ).repository (repoName ))
593- .setBlockOnReadIndexMeta ();
590+ AbstractSnapshotIntegTestCase .<MockRepository >getRepositoryOnMaster (repoName ).setBlockOnReadIndexMeta ();
594591 }
595592
596593 private void blockMasterOnShardClone (String repoName ) {
597- ((MockRepository ) internalCluster ().getCurrentMasterNodeInstance (RepositoriesService .class ).repository (repoName ))
598- .setBlockOnWriteShardLevelMeta ();
594+ AbstractSnapshotIntegTestCase .<MockRepository >getRepositoryOnMaster (repoName ).setBlockOnWriteShardLevelMeta ();
599595 }
600596
601597 /**
0 commit comments