Skip to content

Commit

Permalink
Update changelog and add one more test case
Browse files Browse the repository at this point in the history
Signed-off-by: Liyun Xiu <[email protected]>
  • Loading branch information
chishui committed Jul 24, 2024
1 parent f9e019f commit a7d986e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix constant_keyword field type used when creating index ([#14807](https://github.com/opensearch-project/OpenSearch/pull/14807))
- Use circuit breaker in InternalHistogram when adding empty buckets ([#14754](https://github.com/opensearch-project/OpenSearch/pull/14754))
- Fix searchable snapshot failure with scripted fields ([#14411](https://github.com/opensearch-project/OpenSearch/pull/14411))
- Fix update settings with null replica not honoring cluster setting bug ([#14948](https://github.com/opensearch-project/OpenSearch/pull/14948))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ private void runTestDefaultNumberOfReplicasTest(final boolean closeIndex) {

public void testNullReplicaUpdate() {
internalCluster().ensureAtLeastNumDataNodes(2);

// cluster setting
String defaultNumberOfReplica = "3";
assertAcked(
Expand All @@ -844,7 +845,7 @@ public void testNullReplicaUpdate() {
.setPersistentSettings(Settings.builder().put("cluster.default_number_of_replicas", defaultNumberOfReplica))
.get()
);

// create index with number of replicas will ignore default value
assertAcked(
client().admin()
.indices()
Expand All @@ -858,7 +859,7 @@ public void testNullReplicaUpdate() {
.get()
.getSetting("test", IndexMetadata.SETTING_NUMBER_OF_REPLICAS);
assertEquals("2", numberOfReplicas);

// update setting with null replica will use cluster setting of replica number
assertAcked(
client().admin()
.indices()
Expand All @@ -872,12 +873,27 @@ public void testNullReplicaUpdate() {
.get()
.getSetting("test", IndexMetadata.SETTING_NUMBER_OF_REPLICAS);
assertEquals(defaultNumberOfReplica, numberOfReplicas);

// Clean up cluster setting, then update setting with null replica should pick up default value of 1
assertAcked(
client().admin()
.cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder().putNull("cluster.default_number_of_replicas"))
);
assertAcked(
client().admin()
.indices()
.prepareUpdateSettings("test")
.setSettings(Settings.builder().putNull(IndexMetadata.SETTING_NUMBER_OF_REPLICAS))
);

numberOfReplicas = client().admin()
.indices()
.prepareGetSettings("test")
.get()
.getSetting("test", IndexMetadata.SETTING_NUMBER_OF_REPLICAS);
assertEquals("1", numberOfReplicas);
}

public void testNoopUpdate() {
Expand Down

0 comments on commit a7d986e

Please sign in to comment.