@@ -401,6 +401,70 @@ public void testCompletedCloneStartsNextClone() throws Exception {
401
401
assertIsNoop (updatedClusterState , completeShardClone );
402
402
}
403
403
404
+ public void testPauseForNodeRemovalWithQueuedShards () throws Exception {
405
+ final var repoName = "test-repo" ;
406
+ final var snapshot1 = snapshot (repoName , "snap-1" );
407
+ final var snapshot2 = snapshot (repoName , "snap-2" );
408
+ final var indexName = "index-1" ;
409
+ final var shardId = new ShardId (index (indexName ), 0 );
410
+ final var repositoryShardId = new RepositoryShardId (indexId (indexName ), 0 );
411
+ final var nodeId = uuid ();
412
+
413
+ final var runningEntry = snapshotEntry (
414
+ snapshot1 ,
415
+ Collections .singletonMap (indexName , repositoryShardId .index ()),
416
+ Map .of (shardId , initShardStatus (nodeId ))
417
+ );
418
+
419
+ final var queuedEntry = snapshotEntry (
420
+ snapshot2 ,
421
+ Collections .singletonMap (indexName , repositoryShardId .index ()),
422
+ Map .of (shardId , SnapshotsInProgress .ShardSnapshotStatus .UNASSIGNED_QUEUED )
423
+ );
424
+
425
+ final var initialState = stateWithSnapshots (
426
+ ClusterState .builder (ClusterState .EMPTY_STATE )
427
+ .nodes (DiscoveryNodes .builder ().add (DiscoveryNodeUtils .create (nodeId )).localNodeId (nodeId ).masterNodeId (nodeId ).build ())
428
+ .routingTable (
429
+ RoutingTable .builder ()
430
+ .add (
431
+ IndexRoutingTable .builder (shardId .getIndex ())
432
+ .addShard (TestShardRouting .newShardRouting (shardId , nodeId , true , ShardRoutingState .STARTED ))
433
+ )
434
+ .build ()
435
+ )
436
+ .build (),
437
+ repoName ,
438
+ runningEntry ,
439
+ queuedEntry
440
+ );
441
+
442
+ final var updatedState = applyUpdates (
443
+ initialState ,
444
+ new SnapshotsService .ShardSnapshotUpdate (
445
+ snapshot1 ,
446
+ shardId ,
447
+ null ,
448
+ new SnapshotsInProgress .ShardSnapshotStatus (
449
+ nodeId ,
450
+ SnapshotsInProgress .ShardState .PAUSED_FOR_NODE_REMOVAL ,
451
+ runningEntry .shards ().get (shardId ).generation ()
452
+ ),
453
+ ActionTestUtils .assertNoFailureListener (t -> {})
454
+ )
455
+ );
456
+
457
+ assertEquals (
458
+ SnapshotsInProgress .ShardState .PAUSED_FOR_NODE_REMOVAL ,
459
+ SnapshotsInProgress .get (updatedState ).snapshot (snapshot1 ).shards ().get (shardId ).state ()
460
+ );
461
+
462
+ assertEquals (
463
+ SnapshotsInProgress .ShardState .QUEUED ,
464
+ SnapshotsInProgress .get (updatedState ).snapshot (snapshot2 ).shards ().get (shardId ).state ()
465
+ );
466
+ }
467
+
404
468
public void testSnapshottingIndicesExcludesClones () {
405
469
final String repoName = "test-repo" ;
406
470
final String indexName = "index" ;
0 commit comments