@@ -444,6 +444,7 @@ public void testReplicaShardPreferenceIters() throws Exception {
444
444
445
445
// When replicas haven't initialized, it comes back with the primary first, then initializing replicas
446
446
GroupShardsIterator <ShardIterator > shardIterators = operationRouting .searchShards (clusterState , new String []{"test" }, null , "_replica_first" );
447
+ assertWarnings ("[_replica_first] has been deprecated in 6.1+, and will be removed in 7.0; use [_only_nodes] or [_prefer_nodes]" );
447
448
assertThat (shardIterators .size (), equalTo (2 )); // two potential shards
448
449
ShardIterator iter = shardIterators .iterator ().next ();
449
450
assertThat (iter .size (), equalTo (3 )); // three potential candidates for the shard
@@ -463,10 +464,8 @@ public void testReplicaShardPreferenceIters() throws Exception {
463
464
464
465
clusterState = strategy .applyStartedShards (clusterState , clusterState .getRoutingNodes ().shardsWithState (INITIALIZING ));
465
466
466
- clusterState = strategy .applyStartedShards (clusterState , clusterState .getRoutingNodes ().shardsWithState (INITIALIZING ));
467
-
468
-
469
467
shardIterators = operationRouting .searchShards (clusterState , new String []{"test" }, null , "_replica" );
468
+ assertWarnings ("[_replica] has been deprecated in 6.1+, and will be removed in 7.0; use [_only_nodes] or [_prefer_nodes]" );
470
469
assertThat (shardIterators .size (), equalTo (2 )); // two potential shards
471
470
iter = shardIterators .iterator ().next ();
472
471
assertThat (iter .size (), equalTo (2 )); // two potential replicas for the shard
@@ -479,6 +478,7 @@ public void testReplicaShardPreferenceIters() throws Exception {
479
478
assertFalse (routing .primary ());
480
479
481
480
shardIterators = operationRouting .searchShards (clusterState , new String []{"test" }, null , "_replica_first" );
481
+ assertWarnings ("[_replica_first] has been deprecated in 6.1+, and will be removed in 7.0; use [_only_nodes] or [_prefer_nodes]" );
482
482
assertThat (shardIterators .size (), equalTo (2 )); // two potential shards
483
483
iter = shardIterators .iterator ().next ();
484
484
assertThat (iter .size (), equalTo (3 )); // three potential candidates for the shard
@@ -495,4 +495,45 @@ public void testReplicaShardPreferenceIters() throws Exception {
495
495
assertTrue (routing .primary ());
496
496
}
497
497
498
+ public void testDeprecatedPreferences () throws Exception {
499
+ AllocationService strategy = createAllocationService (Settings .builder ()
500
+ .put ("cluster.routing.allocation.node_concurrent_recoveries" , 10 )
501
+ .build ());
502
+
503
+ OperationRouting operationRouting = new OperationRouting (Settings .EMPTY , new ClusterSettings (Settings .EMPTY ,
504
+ ClusterSettings .BUILT_IN_CLUSTER_SETTINGS ));
505
+
506
+ MetaData metaData = MetaData .builder ()
507
+ .put (IndexMetaData .builder ("test" ).settings (settings (Version .CURRENT )).numberOfShards (2 ).numberOfReplicas (2 ))
508
+ .build ();
509
+
510
+ RoutingTable routingTable = RoutingTable .builder ()
511
+ .addAsNew (metaData .index ("test" ))
512
+ .build ();
513
+
514
+ ClusterState clusterState = ClusterState .builder (ClusterName .CLUSTER_NAME_SETTING .getDefault (Settings .EMPTY ))
515
+ .metaData (metaData )
516
+ .routingTable (routingTable )
517
+ .build ();
518
+
519
+ clusterState = ClusterState .builder (clusterState ).nodes (DiscoveryNodes .builder ()
520
+ .add (newNode ("node1" ))
521
+ .add (newNode ("node2" ))
522
+ .localNodeId ("node1" )
523
+ ).build ();
524
+
525
+ clusterState = strategy .applyStartedShards (clusterState , clusterState .getRoutingNodes ().shardsWithState (INITIALIZING ));
526
+
527
+ operationRouting .searchShards (clusterState , new String []{"test" }, null , "_primary" );
528
+ assertWarnings ("[_primary] has been deprecated in 6.1+, and will be removed in 7.0; use [_only_nodes] or [_prefer_nodes]" );
529
+
530
+ operationRouting .searchShards (clusterState , new String []{"test" }, null , "_primary_first" );
531
+ assertWarnings ("[_primary_first] has been deprecated in 6.1+, and will be removed in 7.0; use [_only_nodes] or [_prefer_nodes]" );
532
+
533
+ operationRouting .searchShards (clusterState , new String []{"test" }, null , "_replica" );
534
+ assertWarnings ("[_replica] has been deprecated in 6.1+, and will be removed in 7.0; use [_only_nodes] or [_prefer_nodes]" );
535
+
536
+ operationRouting .searchShards (clusterState , new String []{"test" }, null , "_replica_first" );
537
+ assertWarnings ("[_replica_first] has been deprecated in 6.1+, and will be removed in 7.0; use [_only_nodes] or [_prefer_nodes]" );
538
+ }
498
539
}
0 commit comments