File tree Expand file tree Collapse file tree
server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -406,4 +406,28 @@ public void testIndexNameInResponse() {
406406 assertEquals ("Should have index name in response" , "foo" , response .index ());
407407 }
408408
409+ public void testCreateIndexWithNullReplicaCountPickUpClusterReplica () {
410+ int numReplicas = 3 ;
411+ String indexName = "test-idx-1" ;
412+ assertAcked (
413+ client ().admin ()
414+ .cluster ()
415+ .prepareUpdateSettings ()
416+ .setPersistentSettings (Settings .builder ().put ("cluster.default_number_of_replicas" , numReplicas ).build ())
417+ .get ()
418+ );
419+ Settings settings = Settings .builder ()
420+ .put (IndexMetadata .INDEX_NUMBER_OF_SHARDS_SETTING .getKey (), 1 )
421+ .put (IndexMetadata .INDEX_NUMBER_OF_REPLICAS_SETTING .getKey (), (String ) null )
422+ .build ();
423+ assertAcked (client ().admin ().indices ().prepareCreate (indexName ).setSettings (settings ).get ());
424+ IndicesService indicesService = internalCluster ().getInstance (IndicesService .class , internalCluster ().getClusterManagerName ());
425+ for (IndexService indexService : indicesService ) {
426+ assertEquals (indexName , indexService .index ().getName ());
427+ assertEquals (
428+ numReplicas ,
429+ (int ) indexService .getIndexSettings ().getSettings ().getAsInt (IndexMetadata .SETTING_NUMBER_OF_REPLICAS , null )
430+ );
431+ }
432+ }
409433}
You can’t perform that action at this time.
0 commit comments